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 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2087 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2089 aStudyBuilder->RemoveObjectWithChildren( SO );
2093 } /* listSO back loop */
2095 aStudyBuilder->CommitCommand();
2097 /* Clear any previous selection */
2099 aSel->setSelectedObjects( l1 );
2101 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2105 SMESHGUI_EXPORT CAM_Module* createModule()
2107 return new SMESHGUI();
2110 SMESHGUI_EXPORT char* getModuleVersion() {
2111 return (char*)SMESH_VERSION_STR;
2115 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2117 //=============================================================================
2121 //=============================================================================
2122 SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" )
2124 if ( CORBA::is_nil( myComponentSMESH ) )
2126 CORBA::Boolean anIsEmbeddedMode;
2127 SALOME_NamingService_Abstract *ns = SalomeApp_Application::namingService();
2128 if( dynamic_cast<SALOME_NamingService *>(ns) )
2129 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2132 Engines::EngineComponent_var comp = RetrieveSMESHInstance();
2133 myComponentSMESH = SMESH::SMESH_Gen::_narrow(comp);
2136 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2138 // 0019923: EDF 765 SMESH : default values of hypothesis
2139 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2140 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2141 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2142 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2143 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2145 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2146 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2147 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2149 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2150 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2154 myActiveDialogBox = 0;
2155 myFilterLibraryDlg = 0;
2159 myEventCallbackCommand = vtkCallbackCommand::New();
2160 myEventCallbackCommand->Delete();
2161 myEventCallbackCommand->SetClientData( this );
2162 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2165 /* load resources for all available meshers */
2166 SMESH::InitAvailableHypotheses();
2169 //=============================================================================
2173 //=============================================================================
2174 SMESHGUI::~SMESHGUI()
2178 //=============================================================================
2182 //=============================================================================
2183 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2185 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2187 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2192 //=============================================================================
2196 //=============================================================================
2197 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2199 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2203 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2204 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2205 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2206 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2207 return autoUpdate && !exceeded;
2210 //=============================================================================
2214 //=============================================================================
2215 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2216 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2218 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2222 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2223 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2224 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2226 SMESH::smIdType_array_var info = theMesh->GetMeshInfo();
2227 long nbOdElems = info[SMDSEntity_0D];
2228 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2229 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2230 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2231 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2232 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2233 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2234 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2235 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2236 info[SMDSEntity_Polyhedra] +
2237 info[SMDSEntity_Hexagonal_Prism];
2238 long nbBalls = info[SMDSEntity_Ball];
2240 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2241 *nbElements = requestedSize;
2243 *entities = SMESH_Actor::eAllEntity;
2246 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2248 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2250 if ( incrementalLimit ) {
2253 if ( nbOdElems > 0 ) {
2254 if ( total + nbOdElems > updateLimit ) {
2255 *entities = *entities & ~SMESH_Actor::e0DElements;
2256 *hidden = *hidden | SMESH_Actor::e0DElements;
2263 if ( nbEdges > 0 ) {
2264 if ( total + nbEdges > updateLimit ) {
2265 *entities = *entities & ~SMESH_Actor::eEdges;
2266 *hidden = *hidden | SMESH_Actor::eEdges;
2273 if ( nbFaces > 0 ) {
2274 if ( total + nbFaces > updateLimit ) {
2275 *entities = *entities & ~SMESH_Actor::eFaces;
2276 *hidden = *hidden | SMESH_Actor::eFaces;
2283 if ( nbVolumes > 0 ) {
2284 if ( total + nbVolumes > updateLimit ) {
2285 *entities = *entities & ~SMESH_Actor::eVolumes;
2286 *hidden = *hidden | SMESH_Actor::eVolumes;
2293 if ( nbBalls > 0 ) {
2294 if ( total + nbBalls > updateLimit ) {
2295 *entities = *entities & ~SMESH_Actor::eBallElem;
2296 *hidden = *hidden | SMESH_Actor::eBallElem;
2304 return autoUpdate && !exceeded;
2307 //=============================================================================
2311 //=============================================================================
2312 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2314 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2317 //=============================================================================
2321 //=============================================================================
2322 SMESHGUI* SMESHGUI::GetSMESHGUI()
2324 SMESHGUI* smeshMod = 0;
2325 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2328 CAM_Module* module = app->module( "Mesh" );
2329 smeshMod = dynamic_cast<SMESHGUI*>( module );
2337 Standard_EXPORT SMESHGUI* GetComponentGUI()
2339 return SMESHGUI::GetSMESHGUI();
2343 //=============================================================================
2347 //=============================================================================
2348 void SMESHGUI::SetState(int aState)
2353 //=============================================================================
2357 //=============================================================================
2358 void SMESHGUI::ResetState()
2363 //=============================================================================
2367 //=============================================================================
2368 void SMESHGUI::EmitSignalDeactivateDialog()
2370 emit SignalDeactivateActiveDialog();
2373 //=============================================================================
2377 //=============================================================================
2378 void SMESHGUI::EmitSignalStudyFrameChanged()
2380 emit SignalStudyFrameChanged();
2383 //=============================================================================
2387 //=============================================================================
2388 void SMESHGUI::EmitSignalCloseAllDialogs()
2390 emit SignalCloseAllDialogs();
2393 //=============================================================================
2397 //=============================================================================
2398 void SMESHGUI::EmitSignalVisibilityChanged()
2400 emit SignalVisibilityChanged();
2403 //=============================================================================
2407 //=============================================================================
2408 void SMESHGUI::EmitSignalCloseView()
2410 emit SignalCloseView();
2413 //=============================================================================
2417 //=============================================================================
2418 void SMESHGUI::EmitSignalActivatedViewManager()
2420 emit SignalActivatedViewManager();
2423 //=============================================================================
2427 //=============================================================================
2428 QDialog *SMESHGUI::GetActiveDialogBox()
2430 return myActiveDialogBox;
2433 //=============================================================================
2437 //=============================================================================
2438 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2440 myActiveDialogBox = (QDialog *) aDlg;
2444 //=============================================================================
2448 //=============================================================================
2449 SUIT_Desktop* SMESHGUI::desktop()
2451 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2453 return app->desktop();
2458 //=============================================================================
2462 //=============================================================================
2463 SalomeApp_Study* SMESHGUI::activeStudy()
2465 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2467 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2472 //=============================================================================
2476 //=============================================================================
2477 void SMESHGUI::Modified( bool theIsUpdateActions )
2479 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2480 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2481 appStudy->Modified();
2482 if( theIsUpdateActions )
2483 app->updateActions();
2488 //=============================================================================
2492 //=============================================================================
2493 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2495 /* Here the position is on the bottom right corner - 10 */
2496 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2498 SUIT_Desktop *PP = desktop();
2499 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2500 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2505 * \brief Verifies whether study of operation is locked
2506 * \param theMess - specifies whether message box must be shown if study is locked
2507 * \return State of study.
2509 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2510 * is locked when corresponding message box appears
2512 bool SMESHGUI::isStudyLocked( bool theMessage )
2514 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2517 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2518 QObject::tr( "WRN_WARNING" ),
2519 QObject::tr( "WRN_STUDY_LOCKED" ) );
2525 //=============================================================================
2529 //=============================================================================
2530 bool SMESHGUI::OnGUIEvent( int theCommandID )
2532 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2536 SUIT_ResourceMgr* mgr = resourceMgr();
2540 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2541 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2543 //QAction* act = action( theCommandID );
2545 switch (theCommandID) {
2546 case SMESHOp::OpDelete:
2547 if(isStudyLocked()) break;
2550 case SMESHOp::OpImportDAT:
2551 case SMESHOp::OpImportUNV:
2552 case SMESHOp::OpImportMED:
2553 case SMESHOp::OpImportSTL:
2554 case SMESHOp::OpImportCGNS:
2555 case SMESHOp::OpImportGMF:
2556 case SMESHOp::OpPopupImportDAT:
2557 case SMESHOp::OpPopupImportUNV:
2558 case SMESHOp::OpPopupImportMED:
2559 case SMESHOp::OpPopupImportSTL:
2560 case SMESHOp::OpPopupImportCGNS:
2561 case SMESHOp::OpPopupImportGMF:
2563 if(isStudyLocked()) break;
2564 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2568 case SMESHOp::OpFileInformation:
2570 SALOME_ListIO selected;
2571 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2573 aSel->selectedObjects( selected );
2574 if( selected.Extent() )
2576 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2577 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2578 if ( !aMesh->_is_nil() )
2580 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2586 case SMESHOp::OpExportDAT:
2587 case SMESHOp::OpExportMED:
2588 case SMESHOp::OpExportUNV:
2589 case SMESHOp::OpExportSTL:
2590 case SMESHOp::OpExportCGNS:
2591 case SMESHOp::OpExportGMF:
2592 case SMESHOp::OpPopupExportDAT:
2593 case SMESHOp::OpPopupExportMED:
2594 case SMESHOp::OpPopupExportUNV:
2595 case SMESHOp::OpPopupExportSTL:
2596 case SMESHOp::OpPopupExportCGNS:
2597 case SMESHOp::OpPopupExportGMF:
2599 ::ExportMeshToFile(theCommandID);
2603 case SMESHOp::OpReset: // SCALAR BAR
2605 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2606 SALOME_ListIO selected;
2608 aSel->selectedObjects( selected );
2610 SALOME_ListIteratorOfListIO it(selected);
2611 for( ; it.More(); it.Next()) {
2612 Handle(SALOME_InteractiveObject) anIO = it.Value();
2613 if( anIO->hasEntry() ) {
2614 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2615 anActor->SetControlMode( SMESH_Actor::eNone );
2616 #ifndef DISABLE_PLOT2DVIEWER
2617 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2619 anActor->UpdateFilter();
2623 SMESH::UpdateView();
2626 case SMESHOp::OpScalarBarProperties:
2628 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2631 case SMESHOp::OpShowScalarBar:
2633 // show/hide scalar bar
2634 ::ShowElement(theCommandID);
2637 case SMESHOp::OpSaveDistribution:
2639 // dump control distribution data to the text file
2640 ::SaveDistribution();
2644 case SMESHOp::OpShowDistribution:
2646 // show/hide distribution
2647 ::ShowElement(theCommandID);
2651 #ifndef DISABLE_PLOT2DVIEWER
2652 case SMESHOp::OpPlotDistribution:
2654 // plot distribution
2655 ::PlotDistribution();
2661 case SMESHOp::OpAutoColor:
2665 case SMESHOp::OpDisableAutoColor:
2666 ::DisableAutoColor();
2669 case SMESHOp::OpClipping:
2670 case SMESHOp::OpTransparency:
2671 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2674 case SMESHOp::OpDMWireframe:
2675 case SMESHOp::OpDMShading:
2676 case SMESHOp::OpDMNodes:
2677 case SMESHOp::OpDMShrink:
2678 ::SetDisplayMode(theCommandID, myMarkerMap);
2681 //2D quadratic representation
2682 case SMESHOp::OpRepresentationLines:
2683 case SMESHOp::OpRepresentationArcs:
2684 ::SetDisplayMode(theCommandID, myMarkerMap);
2688 case SMESHOp::OpDE0DElements:
2689 case SMESHOp::OpDEEdges:
2690 case SMESHOp::OpDEFaces:
2691 case SMESHOp::OpDEVolumes:
2692 case SMESHOp::OpDEBalls:
2693 case SMESHOp::OpDEAllEntity:
2694 ::SetDisplayEntity(theCommandID);
2697 // Choose entities to be displayed
2698 case SMESHOp::OpDEChoose:
2700 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2704 case SMESHOp::OpOrientationOnFaces:
2706 SUIT_OverrideCursor wc;
2707 LightApp_SelectionMgr* mgr = selectionMgr();
2708 SALOME_ListIO selected; mgr->selectedObjects( selected );
2710 SALOME_ListIteratorOfListIO it(selected);
2711 for( ; it.More(); it.Next()) {
2712 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2713 if(anIObject->hasEntry()) {
2714 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2715 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2722 case SMESHOp::OpUpdate:
2724 if(isStudyLocked()) break;
2725 SUIT_OverrideCursor wc;
2728 SMESH::UpdateView();
2730 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2731 SMESH::OnVisuException();
2733 catch (...) { // PAL16774 (Crash after display of many groups)
2734 SMESH::OnVisuException();
2738 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2739 aSel->selectedObjects( l );
2740 aSel->setSelectedObjects( l );
2744 case SMESHOp::OpHide:
2745 case SMESHOp::OpShow:
2746 case SMESHOp::OpShowOnly:
2748 SUIT_OverrideCursor wc;
2749 SMESH::EDisplaing anAction;
2750 switch (theCommandID) {
2751 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2752 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2753 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2756 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2757 SALOME_ListIO sel_objects, to_process;
2759 aSel->selectedObjects( sel_objects );
2761 if ( theCommandID==SMESHOp::OpShowOnly )
2763 //MESSAGE("anAction = SMESH::eDisplayOnly");
2764 startOperation( myEraseAll );
2767 extractContainers( sel_objects, to_process );
2772 SALOME_ListIteratorOfListIO It( to_process );
2773 for ( ; It.More(); It.Next())
2775 Handle(SALOME_InteractiveObject) IOS = It.Value();
2776 if ( IOS->hasEntry() )
2778 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2779 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2780 break; // PAL16774 (Crash after display of many groups)
2782 if (anAction == SMESH::eDisplayOnly)
2783 anAction = SMESH::eDisplay;
2788 // PAL13338 + PAL15161 -->
2789 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2790 SMESH::UpdateView();
2791 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2793 // PAL13338 + PAL15161 <--
2795 catch (...) { // PAL16774 (Crash after display of many groups)
2796 SMESH::OnVisuException();
2799 if (anAction == SMESH::eErase) {
2801 aSel->setSelectedObjects( l1 );
2804 aSel->setSelectedObjects( to_process );
2806 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2807 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2808 vtkwnd->GetRenderer()->AdjustActors();
2813 case SMESHOp::OpNode:
2815 if(isStudyLocked()) break;
2818 EmitSignalDeactivateDialog();
2820 ( new SMESHGUI_NodesDlg( this ) )->show();
2823 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2828 case SMESHOp::OpEditMeshOrSubMesh:
2829 case SMESHOp::OpEditMesh:
2830 case SMESHOp::OpEditSubMesh:
2831 case SMESHOp::OpMeshOrder:
2832 case SMESHOp::OpCreateSubMesh:
2833 if ( warnOnGeomModif() )
2834 break; // action forbidden as geometry modified
2836 case SMESHOp::OpCreateMesh:
2837 case SMESHOp::OpCompute:
2838 case SMESHOp::OpComputeSubMesh:
2839 case SMESHOp::OpPreCompute:
2840 case SMESHOp::OpEvaluate:
2841 case SMESHOp::OpShowErrors:
2842 startOperation( theCommandID );
2844 case SMESHOp::OpRecompute:
2846 if ( isStudyLocked() )
2848 SALOME_ListIO selected;
2849 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2850 sel->selectedObjects( selected );
2851 if ( selected.Extent() == 1 ) {
2852 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2853 if ( !aMesh->_is_nil() )
2855 startOperation( SMESHOp::OpCompute );
2859 case SMESHOp::OpCopyMesh:
2861 if (isStudyLocked()) break;
2862 EmitSignalDeactivateDialog();
2863 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2866 case SMESHOp::OpBuildCompoundMesh:
2868 if (isStudyLocked()) break;
2869 EmitSignalDeactivateDialog();
2870 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2874 case SMESHOp::OpDiagonalInversion:
2875 case SMESHOp::OpUnionOfTwoTriangle:
2879 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2883 if ( isStudyLocked() )
2885 if ( warnOnGeomModif() )
2886 break; // action forbidden as geometry modified
2888 /*Standard_Boolean aRes;
2889 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2890 if ( aMesh->_is_nil() )
2892 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2893 tr( "SMESH_BAD_SELECTION" ) );
2897 EmitSignalDeactivateDialog();
2898 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2899 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2901 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2904 case SMESHOp::OpOrientation:
2905 case SMESHOp::OpUnionOfTriangles:
2906 case SMESHOp::OpCuttingOfQuadrangles:
2907 case SMESHOp::OpSplitVolumes:
2911 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2915 if ( isStudyLocked() )
2917 if ( warnOnGeomModif() )
2918 break; // action forbidden as geometry modified
2920 EmitSignalDeactivateDialog();
2921 SMESHGUI_MultiEditDlg* aDlg = NULL;
2922 if ( theCommandID == SMESHOp::OpOrientation )
2923 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2924 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2925 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2926 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2927 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2929 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2934 case SMESHOp::OpSmoothing:
2936 if(isStudyLocked()) break;
2937 if ( warnOnGeomModif() )
2938 break; // action forbidden as geometry modified
2940 EmitSignalDeactivateDialog();
2941 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2944 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2948 case SMESHOp::OpExtrusion:
2950 if (isStudyLocked()) break;
2951 if ( warnOnGeomModif() )
2952 break; // action forbidden as geometry modified
2954 EmitSignalDeactivateDialog();
2955 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2957 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2961 case SMESHOp::OpExtrusionAlongAPath:
2963 if (isStudyLocked()) break;
2964 if ( warnOnGeomModif() )
2965 break; // action forbidden as geometry modified
2967 EmitSignalDeactivateDialog();
2968 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2970 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2974 case SMESHOp::OpRevolution:
2976 if(isStudyLocked()) break;
2977 if ( warnOnGeomModif() )
2978 break; // action forbidden as geometry modified
2980 EmitSignalDeactivateDialog();
2981 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2984 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2988 case SMESHOp::OpPatternMapping:
2990 if ( isStudyLocked() )
2992 if ( warnOnGeomModif() )
2993 break; // action forbidden as geometry modified
2996 EmitSignalDeactivateDialog();
2997 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3000 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3004 // Adaptation - begin
3005 #ifndef DISABLE_MG_ADAPT
3006 case SMESHOp::OpMGAdapt:
3008 if ( isStudyLocked() )
3010 EmitSignalDeactivateDialog();
3012 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3013 bool isCreation = false;
3014 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3019 case SMESHOp::OpSplitBiQuadratic:
3020 case SMESHOp::OpConvertMeshToQuadratic:
3021 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3022 case SMESHOp::OpReorientFaces:
3023 case SMESHOp::OpCreateGeometryGroup:
3025 if ( warnOnGeomModif() )
3026 break; // action forbidden as geometry modified
3027 startOperation( theCommandID );
3030 case SMESHOp::OpCreateGroup:
3034 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3038 if(isStudyLocked()) break;
3039 if ( warnOnGeomModif() )
3040 break; // action forbidden as geometry modified
3041 EmitSignalDeactivateDialog();
3042 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3044 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3045 SALOME_ListIO selected;
3047 aSel->selectedObjects( selected );
3049 int nbSel = selected.Extent();
3051 // check if mesh is selected
3052 aMesh = SMESH::GetMeshByIO( selected.First() );
3054 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3059 case SMESHOp::OpConstructGroup:
3063 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3067 if(isStudyLocked()) break;
3068 if ( warnOnGeomModif() )
3069 break; // action forbidden as geometry modified
3070 EmitSignalDeactivateDialog();
3072 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3073 SALOME_ListIO selected;
3075 aSel->selectedObjects( selected );
3077 int nbSel = selected.Extent();
3079 // check if submesh is selected
3080 Handle(SALOME_InteractiveObject) IObject = selected.First();
3081 if (IObject->hasEntry()) {
3082 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3084 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3085 if (!aSubMesh->_is_nil()) {
3087 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3088 // get submesh elements list by types
3089 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3090 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3091 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3092 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3093 // create group for each type o elements
3094 QString aName = IObject->getName();
3095 QStringList anEntryList;
3096 if (aNodes->length() > 0) {
3097 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3098 aGroup->Add(aNodes.inout());
3099 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3100 anEntryList.append( aSObject->GetID().c_str() );
3102 if (aEdges->length() > 0) {
3103 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3104 aGroup->Add(aEdges.inout());
3105 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3106 anEntryList.append( aSObject->GetID().c_str() );
3108 if (aFaces->length() > 0) {
3109 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3110 aGroup->Add(aFaces.inout());
3111 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3112 anEntryList.append( aSObject->GetID().c_str() );
3114 if (aVolumes->length() > 0) {
3115 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3116 aGroup->Add(aVolumes.inout());
3117 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3118 anEntryList.append( aSObject->GetID().c_str() );
3121 anApp->browseObjects( anEntryList );
3123 catch(const SALOME::SALOME_Exception & S_ex){
3124 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3131 SUIT_MessageBox::warning(desktop(),
3132 tr("SMESH_WRN_WARNING"),
3133 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3138 case SMESHOp::OpEditGroup:
3142 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3146 if(isStudyLocked()) break;
3147 if ( warnOnGeomModif() )
3148 break; // action forbidden as geometry modified
3149 EmitSignalDeactivateDialog();
3151 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3152 SALOME_ListIO selected;
3154 aSel->selectedObjects( selected );
3156 SALOME_ListIteratorOfListIO It (selected);
3157 int nbSelectedGroups = 0;
3158 for ( ; It.More(); It.Next() )
3160 SMESH::SMESH_GroupBase_var aGroup =
3161 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3162 if (!aGroup->_is_nil()) {
3164 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3168 if (nbSelectedGroups == 0)
3170 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3176 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3178 if(isStudyLocked()) break;
3179 if (myState == 800) {
3180 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3181 if (aDlg) aDlg->onAdd();
3186 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3188 if(isStudyLocked()) break;
3189 if (myState == 800) {
3190 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3191 if (aDlg) aDlg->onRemove();
3196 case SMESHOp::OpEditGeomGroupAsGroup:
3200 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3204 if(isStudyLocked()) break;
3205 EmitSignalDeactivateDialog();
3207 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3208 SALOME_ListIO selected;
3210 aSel->selectedObjects( selected );
3212 SALOME_ListIteratorOfListIO It (selected);
3213 for ( ; It.More(); It.Next() )
3215 SMESH::SMESH_GroupOnGeom_var aGroup =
3216 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3217 if (!aGroup->_is_nil()) {
3218 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3223 SMESH::SMESH_GroupOnFilter_var aGroup =
3224 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3225 if (!aGroup->_is_nil()) {
3226 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3234 case SMESHOp::OpUnionGroups:
3235 case SMESHOp::OpIntersectGroups:
3236 case SMESHOp::OpCutGroups:
3240 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3244 if ( isStudyLocked() )
3246 if ( warnOnGeomModif() )
3247 break; // action forbidden as geometry modified
3249 EmitSignalDeactivateDialog();
3251 SMESHGUI_GroupOpDlg* aDlg = 0;
3252 if ( theCommandID == SMESHOp::OpUnionGroups )
3253 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3254 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3255 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3257 aDlg = new SMESHGUI_CutGroupsDlg( this );
3264 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3266 if ( isStudyLocked() )
3268 if ( warnOnGeomModif() )
3269 break; // action forbidden as geometry modified
3271 EmitSignalDeactivateDialog();
3272 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3278 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3280 if ( isStudyLocked() )
3282 if ( warnOnGeomModif() )
3283 break; // action forbidden as geometry modified
3285 EmitSignalDeactivateDialog();
3286 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3292 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3296 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3300 if ( isStudyLocked() )
3303 EmitSignalDeactivateDialog();
3305 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3309 case SMESHOp::OpMeshInformation:
3310 case SMESHOp::OpWhatIs:
3312 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3313 EmitSignalDeactivateDialog();
3314 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3315 SALOME_ListIO selected;
3317 aSel->selectedObjects( selected );
3319 if ( selected.Extent() > 1 ) { // a dlg for each IO
3320 SALOME_ListIteratorOfListIO It( selected );
3321 for ( ; It.More(); It.Next() ) {
3322 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3323 dlg->showInfo( It.Value() );
3328 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3334 case SMESHOp::OpFindElementByPoint:
3336 startOperation( theCommandID );
3340 case SMESHOp::OpEditHypothesis:
3342 if(isStudyLocked()) break;
3343 if ( warnOnGeomModif() )
3344 break; // action forbidden as geometry modified
3346 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3347 SALOME_ListIO selected;
3349 aSel->selectedObjects( selected );
3351 int nbSel = selected.Extent();
3354 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3355 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3357 if ( !aHypothesis->_is_nil() )
3359 SMESHGUI_GenericHypothesisCreator* aCreator =
3360 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3363 // set geometry of mesh and sub-mesh to aCreator
3364 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3365 if ( selected.Extent() == 1 )
3367 QString subGeomID, meshGeomID;
3368 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3369 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3371 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3372 aCreator->setShapeEntry( subGeomID );
3373 aCreator->setMainShapeEntry( meshGeomID );
3377 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3387 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3389 if(isStudyLocked()) break;
3390 if ( warnOnGeomModif() )
3391 break; // action forbidden as geometry modified
3392 SUIT_OverrideCursor wc;
3394 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3395 SALOME_ListIO selected;
3397 aSel->selectedObjects( selected, QString::null, false );
3399 SALOME_ListIteratorOfListIO It(selected);
3400 for (int i = 0; It.More(); It.Next(), i++) {
3401 Handle(SALOME_InteractiveObject) IObject = It.Value();
3402 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3405 aSel->setSelectedObjects( l1 );
3410 case SMESHOp::OpElem0D:
3411 case SMESHOp::OpBall:
3412 case SMESHOp::OpEdge:
3413 case SMESHOp::OpTriangle:
3414 case SMESHOp::OpQuadrangle:
3415 case SMESHOp::OpPolygon:
3416 case SMESHOp::OpTetrahedron:
3417 case SMESHOp::OpHexahedron:
3418 case SMESHOp::OpPentahedron:
3419 case SMESHOp::OpPyramid:
3420 case SMESHOp::OpHexagonalPrism:
3422 if(isStudyLocked()) break;
3423 if ( warnOnGeomModif() )
3424 break; // action forbidden as geometry modified
3426 EmitSignalDeactivateDialog();
3427 SMDSAbs_EntityType type = SMDSEntity_Edge;
3428 switch (theCommandID) {
3429 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3430 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3431 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3432 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3433 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3434 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3435 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3436 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3437 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3438 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3441 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3444 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3448 case SMESHOp::OpPolyhedron:
3450 if(isStudyLocked()) break;
3451 if ( warnOnGeomModif() )
3452 break; // action forbidden as geometry modified
3454 EmitSignalDeactivateDialog();
3455 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3458 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3462 case SMESHOp::OpQuadraticEdge:
3463 case SMESHOp::OpQuadraticTriangle:
3464 case SMESHOp::OpBiQuadraticTriangle:
3465 case SMESHOp::OpQuadraticQuadrangle:
3466 case SMESHOp::OpBiQuadraticQuadrangle:
3467 case SMESHOp::OpQuadraticPolygon:
3468 case SMESHOp::OpQuadraticTetrahedron:
3469 case SMESHOp::OpQuadraticPyramid:
3470 case SMESHOp::OpQuadraticPentahedron:
3471 case SMESHOp::OpBiQuadraticPentahedron:
3472 case SMESHOp::OpQuadraticHexahedron:
3473 case SMESHOp::OpTriQuadraticHexahedron:
3475 if(isStudyLocked()) break;
3476 if ( warnOnGeomModif() )
3477 break; // action forbidden as geometry modified
3479 EmitSignalDeactivateDialog();
3480 SMDSAbs_EntityType type = SMDSEntity_Last;
3482 switch (theCommandID) {
3483 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3484 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3485 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3486 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3487 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3488 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3489 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3490 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3491 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3492 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3493 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3494 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3497 if ( type != SMDSEntity_Last )
3498 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3501 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3502 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3506 case SMESHOp::OpRemoveNodes:
3508 if(isStudyLocked()) break;
3509 if ( warnOnGeomModif() )
3510 break; // action forbidden as geometry modified
3512 EmitSignalDeactivateDialog();
3513 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3516 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3517 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3521 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3523 if(isStudyLocked()) break;
3524 if ( warnOnGeomModif() )
3525 break; // action forbidden as geometry modified
3527 EmitSignalDeactivateDialog();
3528 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3532 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3533 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3537 case SMESHOp::OpClearMesh: {
3539 if(isStudyLocked()) break;
3540 if ( warnOnGeomModif() )
3541 break; // action forbidden as geometry modified
3543 SALOME_ListIO selected;
3544 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3545 aSel->selectedObjects( selected );
3547 SUIT_OverrideCursor wc;
3548 SALOME_ListIteratorOfListIO It (selected);
3549 for ( ; It.More(); It.Next() )
3551 Handle(SALOME_InteractiveObject) IOS = It.Value();
3552 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3553 if ( aMesh->_is_nil()) continue;
3556 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3557 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3558 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3559 // hide groups and submeshes
3560 _PTR(ChildIterator) anIter =
3561 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3562 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3564 _PTR(SObject) so = anIter->Value();
3565 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3568 catch (const SALOME::SALOME_Exception& S_ex){
3570 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3574 SMESH::UpdateView();
3578 case SMESHOp::OpRemoveOrphanNodes:
3580 if(isStudyLocked()) break;
3581 if ( warnOnGeomModif() )
3582 break; // action forbidden as geometry modified
3583 SALOME_ListIO selected;
3584 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3585 aSel->selectedObjects( selected );
3586 if ( selected.Extent() == 1 ) {
3587 Handle(SALOME_InteractiveObject) anIO = selected.First();
3588 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3589 if ( !aMesh->_is_nil() ) {
3590 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3591 tr( "SMESH_WARNING" ),
3592 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3593 SUIT_MessageBox::Yes |
3594 SUIT_MessageBox::No,
3595 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3598 SUIT_OverrideCursor wc;
3599 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3600 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3601 SUIT_MessageBox::information(SMESHGUI::desktop(),
3602 tr("SMESH_INFORMATION"),
3603 tr("NB_NODES_REMOVED").arg(removed));
3604 if ( removed > 0 ) {
3605 SMESH::UpdateView();
3606 SMESHGUI::Modified();
3609 catch (const SALOME::SALOME_Exception& S_ex) {
3610 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3619 case SMESHOp::OpRenumberingNodes:
3621 if(isStudyLocked()) break;
3622 if ( warnOnGeomModif() )
3623 break; // action forbidden as geometry modified
3625 EmitSignalDeactivateDialog();
3626 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3630 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3631 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3635 case SMESHOp::OpRenumberingElements:
3637 if(isStudyLocked()) break;
3638 if ( warnOnGeomModif() )
3639 break; // action forbidden as geometry modified
3641 EmitSignalDeactivateDialog();
3642 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3646 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3647 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3651 case SMESHOp::OpTranslation:
3653 if(isStudyLocked()) break;
3654 if ( warnOnGeomModif() )
3655 break; // action forbidden as geometry modified
3657 EmitSignalDeactivateDialog();
3658 ( new SMESHGUI_TranslationDlg( this ) )->show();
3661 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3662 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3666 case SMESHOp::OpRotation:
3668 if(isStudyLocked()) break;
3669 if ( warnOnGeomModif() )
3670 break; // action forbidden as geometry modified
3672 EmitSignalDeactivateDialog();
3673 ( new SMESHGUI_RotationDlg( this ) )->show();
3676 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3677 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3681 case SMESHOp::OpSymmetry:
3683 if(isStudyLocked()) break;
3684 if ( warnOnGeomModif() )
3685 break; // action forbidden as geometry modified
3687 EmitSignalDeactivateDialog();
3688 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3691 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3692 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3696 case SMESHOp::OpScale:
3698 if(isStudyLocked()) break;
3699 if ( warnOnGeomModif() )
3700 break; // action forbidden as geometry modified
3702 EmitSignalDeactivateDialog();
3703 ( new SMESHGUI_ScaleDlg( this ) )->show();
3706 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3707 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3712 case SMESHOp::OpOffset:
3714 if(isStudyLocked()) break;
3715 if ( warnOnGeomModif() )
3716 break; // action forbidden as geometry modified
3718 EmitSignalDeactivateDialog();
3719 ( new SMESHGUI_OffsetDlg( this ) )->show();
3722 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3723 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3728 case SMESHOp::OpSewing:
3730 if(isStudyLocked()) break;
3731 if ( warnOnGeomModif() )
3732 break; // action forbidden as geometry modified
3734 EmitSignalDeactivateDialog();
3735 ( new SMESHGUI_SewingDlg( this ) )->show();
3738 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3739 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3743 case SMESHOp::OpMergeNodes:
3745 if(isStudyLocked()) break;
3746 if ( warnOnGeomModif() )
3747 break; // action forbidden as geometry modified
3749 EmitSignalDeactivateDialog();
3750 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3753 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3754 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3758 case SMESHOp::OpMergeElements:
3760 if (isStudyLocked()) break;
3761 if ( warnOnGeomModif() )
3762 break; // action forbidden as geometry modified
3764 EmitSignalDeactivateDialog();
3765 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3767 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3768 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3773 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3774 if ( warnOnGeomModif() )
3775 break; // action forbidden as geometry modified
3776 startOperation( SMESHOp::OpMoveNode );
3779 case SMESHOp::OpDuplicateNodes:
3781 if(isStudyLocked()) break;
3782 if ( warnOnGeomModif() )
3783 break; // action forbidden as geometry modified
3785 EmitSignalDeactivateDialog();
3786 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3789 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3790 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3795 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3796 if ( warnOnGeomModif() )
3797 break; // action forbidden as geometry modified
3798 startOperation( SMESHOp::OpElem0DOnElemNodes );
3801 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3803 static QList<int> aTypes;
3804 if ( aTypes.isEmpty() )
3806 aTypes.append( SMESH::NODE );
3807 aTypes.append( SMESH::EDGE );
3808 aTypes.append( SMESH::FACE );
3809 aTypes.append( SMESH::VOLUME );
3811 if (!myFilterLibraryDlg)
3812 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3813 else if (myFilterLibraryDlg->isHidden())
3814 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3815 myFilterLibraryDlg->raise();
3819 case SMESHOp::OpFreeNode:
3820 case SMESHOp::OpEqualNode:
3821 case SMESHOp::OpNodeConnectivityNb:
3822 case SMESHOp::OpFreeEdge:
3823 case SMESHOp::OpFreeBorder:
3824 case SMESHOp::OpLength:
3825 case SMESHOp::OpConnection:
3826 case SMESHOp::OpEqualEdge:
3827 case SMESHOp::OpFreeFace:
3828 case SMESHOp::OpBareBorderFace:
3829 case SMESHOp::OpOverConstrainedFace:
3830 case SMESHOp::OpLength2D:
3831 case SMESHOp::OpDeflection2D:
3832 case SMESHOp::OpConnection2D:
3833 case SMESHOp::OpArea:
3834 case SMESHOp::OpTaper:
3835 case SMESHOp::OpAspectRatio:
3836 case SMESHOp::OpMinimumAngle:
3837 case SMESHOp::OpWarpingAngle:
3838 case SMESHOp::OpSkew:
3839 case SMESHOp::OpMaxElementLength2D:
3840 case SMESHOp::OpEqualFace:
3841 case SMESHOp::OpAspectRatio3D:
3842 case SMESHOp::OpVolume:
3843 case SMESHOp::OpMaxElementLength3D:
3844 case SMESHOp::OpBareBorderVolume:
3845 case SMESHOp::OpOverConstrainedVolume:
3846 case SMESHOp::OpEqualVolume:
3849 LightApp_SelectionMgr* mgr = selectionMgr();
3850 SALOME_ListIO selected; mgr->selectedObjects( selected );
3852 if( !selected.IsEmpty() ) {
3853 SUIT_OverrideCursor wc;
3854 ::Control( theCommandID );
3857 SUIT_MessageBox::warning(desktop(),
3858 tr( "SMESH_WRN_WARNING" ),
3859 tr( "SMESH_BAD_SELECTION" ) );
3863 SUIT_MessageBox::warning(desktop(),
3864 tr( "SMESH_WRN_WARNING" ),
3865 tr( "NOT_A_VTK_VIEWER" ) );
3868 case SMESHOp::OpOverallMeshQuality:
3869 OverallMeshQuality();
3871 case SMESHOp::OpNumberingNodes:
3873 SUIT_OverrideCursor wc;
3874 LightApp_SelectionMgr* mgr = selectionMgr();
3875 SALOME_ListIO selected; mgr->selectedObjects( selected );
3877 SALOME_ListIteratorOfListIO it(selected);
3878 for( ; it.More(); it.Next()) {
3879 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3880 if(anIObject->hasEntry()) {
3881 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3882 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3888 case SMESHOp::OpNumberingElements:
3890 SUIT_OverrideCursor wc;
3891 LightApp_SelectionMgr* mgr = selectionMgr();
3892 SALOME_ListIO selected; mgr->selectedObjects( selected );
3894 SALOME_ListIteratorOfListIO it(selected);
3895 for( ; it.More(); it.Next()) {
3896 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3897 if(anIObject->hasEntry())
3898 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3899 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3904 case SMESHOp::OpPropertiesLength:
3905 case SMESHOp::OpPropertiesArea:
3906 case SMESHOp::OpPropertiesVolume:
3907 case SMESHOp::OpMinimumDistance:
3908 case SMESHOp::OpBoundingBox:
3909 case SMESHOp::OpAngle:
3911 int page = SMESHGUI_MeasureDlg::MinDistance;
3912 if ( theCommandID == SMESHOp::OpBoundingBox )
3913 page = SMESHGUI_MeasureDlg::BoundingBox;
3914 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3915 page = SMESHGUI_MeasureDlg::Length;
3916 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3917 page = SMESHGUI_MeasureDlg::Area;
3918 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3919 page = SMESHGUI_MeasureDlg::Volume;
3920 else if ( theCommandID == SMESHOp::OpAngle )
3921 page = SMESHGUI_MeasureDlg::Angle;
3923 EmitSignalDeactivateDialog();
3924 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3928 case SMESHOp::OpSortChild:
3931 case SMESHOp::OpBreakLink:
3932 ::breakShaperLink();
3937 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3938 //updateObjBrowser();
3942 //=============================================================================
3946 //=============================================================================
3947 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
3952 //=============================================================================
3956 //=============================================================================
3957 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
3962 //=============================================================================
3966 //=============================================================================
3967 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
3972 //=============================================================================
3973 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3974 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3976 //=============================================================================
3977 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3978 SUIT_ViewWindow* wnd )
3980 if(theIO->hasEntry()){
3981 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3982 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3986 //=======================================================================
3987 // function : createSMESHAction
3989 //=======================================================================
3990 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3991 const int key, const bool toggle, const QString& shortcutAction )
3994 QWidget* parent = application()->desktop();
3995 SUIT_ResourceMgr* resMgr = resourceMgr();
3997 if ( !icon_id.isEmpty() )
3998 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4000 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4001 if ( !pix.isNull() )
4002 icon = QIcon( pix );
4004 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4005 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4006 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4008 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4009 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4012 //=======================================================================
4013 // function : createPopupItem
4015 //=======================================================================
4016 void SMESHGUI::createPopupItem( const int id,
4017 const QString& clients,
4018 const QString& types,
4019 const QString& theRule,
4022 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4023 popupMgr()->insert( action( id ), pId, 0 );
4025 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4026 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4027 QString rule = "(%1) and (%2) and (%3)";
4028 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4029 if( clients.isEmpty() )
4030 rule = rule.arg( QString( "true" ) );
4032 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4033 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4036 bool cont = myRules.contains( id );
4038 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4040 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4041 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4044 //=======================================================================
4045 // function : initialize
4047 //=======================================================================
4048 void SMESHGUI::initialize( CAM_Application* app )
4050 SalomeApp_Module::initialize( app );
4052 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4054 /* Automatic Update flag */
4055 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4057 // ----- create actions --------------
4059 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4060 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4061 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4062 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4064 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4066 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4067 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4068 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4069 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4071 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4073 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4075 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4076 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4077 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4078 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4080 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4082 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4083 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4084 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4085 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4086 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4088 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4090 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4091 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4092 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4093 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4094 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4095 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4096 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4097 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4098 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4099 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4100 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4101 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4102 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4103 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4104 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4105 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4106 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4107 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4108 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4109 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4110 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4111 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4112 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4113 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4114 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4115 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4116 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4117 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4118 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4119 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4120 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4121 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4122 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4123 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4124 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4126 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4127 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4128 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4129 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4130 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4131 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4132 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4133 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4134 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4135 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4136 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4137 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4138 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4139 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4140 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4141 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4142 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4143 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4144 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4145 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4146 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4147 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4148 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4149 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4150 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4151 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4152 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4153 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4154 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4156 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4157 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4158 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4159 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4160 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4161 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4162 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4163 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4164 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4165 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4166 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4167 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4168 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4169 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4170 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4171 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4172 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4173 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4174 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4175 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4176 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4177 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4178 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4179 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4180 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4181 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4183 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4184 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4185 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4186 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4188 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4189 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4191 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4192 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4193 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4194 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4195 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4196 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4197 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4198 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4199 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4200 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4201 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4202 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4203 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4204 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4205 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4206 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4207 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4208 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4209 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4210 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4211 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4212 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4213 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4214 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4215 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4217 createSMESHAction( SMESHOp::OpReset, "RESET" );
4218 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4219 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4220 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4221 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4222 #ifndef DISABLE_PLOT2DVIEWER
4223 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4225 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4226 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4227 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4228 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4229 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4230 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4231 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4232 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4233 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4234 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4235 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4236 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4237 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4239 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4240 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4242 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4243 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4244 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4245 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4246 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4247 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4248 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4249 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4250 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4252 // Adaptation - begin
4253 #ifndef DISABLE_MG_ADAPT
4254 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4258 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4259 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4260 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4261 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4262 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4263 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4265 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4266 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4267 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4269 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4271 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4273 QList<int> aCtrlActions;
4274 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4275 << SMESHOp::OpNodeConnectivityNb // node controls
4276 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4277 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4278 << SMESHOp::OpDeflection2D
4279 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4280 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4281 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4282 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4283 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4284 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4285 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4286 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4287 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4288 aCtrlGroup->setExclusive( true );
4289 for( int i = 0; i < aCtrlActions.size(); i++ )
4290 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4292 // ----- create menu --------------
4293 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4294 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4295 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4296 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4297 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4298 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4299 #ifndef DISABLE_MG_ADAPT
4300 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4302 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4303 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4305 createMenu( separator(), fileId );
4307 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4308 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4309 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4310 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4311 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4312 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4313 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4314 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4315 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4316 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4317 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4318 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4319 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4321 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4322 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4323 createMenu( SMESHOp::OpImportMED, importId, -1 );
4324 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4326 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4328 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4329 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4330 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4331 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4332 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4334 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4336 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4337 createMenu( separator(), fileId, 10 );
4339 createMenu( SMESHOp::OpDelete, editId, -1 );
4341 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4343 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4344 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4345 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4346 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4347 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4348 createMenu( separator(), meshId, -1 );
4349 createMenu( SMESHOp::OpCompute, meshId, -1 );
4350 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4351 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4352 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4353 createMenu( separator(), meshId, -1 );
4354 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4355 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4356 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4357 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4358 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4359 createMenu( separator(), meshId, -1 );
4360 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4361 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4362 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4363 createMenu( separator(), meshId, -1 );
4364 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4365 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4366 createMenu( separator(), meshId, -1 );
4367 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4368 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4369 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4370 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4371 createMenu( separator(), meshId, -1 );
4373 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4374 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4375 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4376 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4377 createMenu( SMESHOp::OpLength, edgeId, -1 );
4378 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4379 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4380 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4381 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4382 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4383 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4384 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4385 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4386 createMenu( SMESHOp::OpArea, faceId, -1 );
4387 createMenu( SMESHOp::OpTaper, faceId, -1 );
4388 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4389 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4390 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4391 createMenu( SMESHOp::OpSkew, faceId, -1 );
4392 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4393 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4394 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4395 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4396 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4397 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4398 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4399 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4400 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4401 createMenu( separator(), ctrlId, -1 );
4402 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4403 createMenu( separator(), ctrlId, -1 );
4404 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4406 createMenu( SMESHOp::OpNode, addId, -1 );
4407 createMenu( SMESHOp::OpElem0D, addId, -1 );
4408 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4409 createMenu( SMESHOp::OpBall, addId, -1 );
4410 createMenu( SMESHOp::OpEdge, addId, -1 );
4411 createMenu( SMESHOp::OpTriangle, addId, -1 );
4412 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4413 createMenu( SMESHOp::OpPolygon, addId, -1 );
4414 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4415 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4416 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4417 createMenu( SMESHOp::OpPyramid, addId, -1 );
4418 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4419 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4420 createMenu( separator(), addId, -1 );
4421 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4422 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4423 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4424 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4425 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4426 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4427 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4428 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4429 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4430 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4431 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4432 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4434 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4435 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4436 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4437 createMenu( separator(), removeId, -1 );
4438 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4439 createMenu( separator(), removeId, -1 );
4440 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4442 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4443 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4445 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4446 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4447 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4448 createMenu( SMESHOp::OpRotation, transfId, -1 );
4449 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4450 createMenu( SMESHOp::OpScale, transfId, -1 );
4451 createMenu( SMESHOp::OpOffset, transfId, -1 );
4452 createMenu( SMESHOp::OpSewing, transfId, -1 );
4453 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4455 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4456 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4457 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4458 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4459 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4460 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4461 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4462 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4463 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4464 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4465 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4466 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4467 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4468 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4469 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4470 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4472 // Adaptation - begin
4473 #ifndef DISABLE_MG_ADAPT
4474 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4478 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4479 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4480 createMenu( SMESHOp::OpAngle, measureId, -1 );
4481 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4482 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4483 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4484 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4486 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4487 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4488 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4489 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4491 // ----- create toolbars --------------
4492 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4493 createTool( SMESHOp::OpCreateMesh, meshTb );
4494 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4495 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4496 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4497 createTool( SMESHOp::OpCopyMesh, meshTb );
4498 createTool( separator(), meshTb );
4499 createTool( SMESHOp::OpCompute, meshTb );
4500 createTool( SMESHOp::OpPreCompute, meshTb );
4501 createTool( SMESHOp::OpEvaluate, meshTb );
4502 createTool( SMESHOp::OpMeshOrder, meshTb );
4504 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4505 createTool( SMESHOp::OpMeshInformation, infoTb );
4506 //createTool( SMESHOp::OpStdInfo, meshTb );
4507 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4508 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4510 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4511 createTool( SMESHOp::OpCreateGroup, groupTb );
4512 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4513 createTool( SMESHOp::OpConstructGroup, groupTb );
4514 createTool( SMESHOp::OpEditGroup, groupTb );
4516 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4517 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4518 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4519 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4521 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4522 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4523 createTool( SMESHOp::OpLength, ctrl1dTb );
4524 createTool( SMESHOp::OpConnection, ctrl1dTb );
4525 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4527 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4528 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4529 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4530 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4531 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4532 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4533 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4534 createTool( SMESHOp::OpArea, ctrl2dTb );
4535 createTool( SMESHOp::OpTaper, ctrl2dTb );
4536 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4537 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4538 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4539 createTool( SMESHOp::OpSkew, ctrl2dTb );
4540 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4541 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4542 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4544 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4545 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4546 createTool( SMESHOp::OpVolume, ctrl3dTb );
4547 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4548 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4549 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4550 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4552 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4553 createTool( SMESHOp::OpNode, addElemTb );
4554 createTool( SMESHOp::OpElem0D, addElemTb );
4555 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4556 createTool( SMESHOp::OpBall, addElemTb );
4557 createTool( SMESHOp::OpEdge, addElemTb );
4558 createTool( SMESHOp::OpTriangle, addElemTb );
4559 createTool( SMESHOp::OpQuadrangle, addElemTb );
4560 createTool( SMESHOp::OpPolygon, addElemTb );
4561 createTool( SMESHOp::OpTetrahedron, addElemTb );
4562 createTool( SMESHOp::OpHexahedron, addElemTb );
4563 createTool( SMESHOp::OpPentahedron, addElemTb );
4564 createTool( SMESHOp::OpPyramid, addElemTb );
4565 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4566 createTool( SMESHOp::OpPolyhedron, addElemTb );
4568 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4569 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4570 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4571 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4572 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4573 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4574 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4575 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4576 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4577 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4578 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4579 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4580 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4582 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4583 createTool( SMESHOp::OpRemoveNodes, remTb );
4584 createTool( SMESHOp::OpRemoveElements, remTb );
4585 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4586 createTool( SMESHOp::OpClearMesh, remTb );
4588 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4589 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4590 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4592 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4593 createTool( SMESHOp::OpMergeNodes, transformTb );
4594 createTool( SMESHOp::OpMergeElements, transformTb );
4595 createTool( SMESHOp::OpTranslation, transformTb );
4596 createTool( SMESHOp::OpRotation, transformTb );
4597 createTool( SMESHOp::OpSymmetry, transformTb );
4598 createTool( SMESHOp::OpScale, transformTb );
4599 createTool( SMESHOp::OpOffset, transformTb );
4600 createTool( SMESHOp::OpSewing, transformTb );
4601 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4603 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4604 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4605 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4606 createTool( SMESHOp::OpExtrusion, modifyTb );
4607 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4608 createTool( SMESHOp::OpRevolution, modifyTb );
4609 createTool( SMESHOp::OpOrientation, modifyTb );
4610 createTool( SMESHOp::OpReorientFaces, modifyTb );
4611 createTool( SMESHOp::OpMoveNode, modifyTb );
4612 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4613 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4614 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4615 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4616 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4617 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4618 createTool( SMESHOp::OpSmoothing, modifyTb );
4619 createTool( SMESHOp::OpPatternMapping, modifyTb );
4621 // Adaptation - begin
4622 #ifndef DISABLE_MG_ADAPT
4623 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4624 createTool( SMESHOp::OpMGAdapt, adaptTb );
4628 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4629 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4631 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4632 createTool( SMESHOp::OpUpdate, dispModeTb );
4634 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4635 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4639 OB = "'ObjectBrowser'",
4640 View = "'" + SVTK_Viewer::Type() + "'",
4642 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4643 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4644 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4645 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4646 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4647 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4648 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4649 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4650 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4651 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4652 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4653 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4655 mesh_part = mesh + " " + subMesh + " " + group,
4656 mesh_group = mesh + " " + group,
4657 mesh_submesh = mesh + " " + subMesh,
4658 hyp_alg = hypo + " " + algo;
4660 // popup for object browser
4662 isInvisible("not( isVisible )"),
4663 isEmpty("numberOfNodes = 0"),
4664 isNotEmpty("numberOfNodes <> 0"),
4666 // has nodes, edges, etc in VISIBLE! actor
4667 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4668 hasElems("(count( elemTypes ) > 0)"),
4669 hasDifferentElems("(count( elemTypes ) > 1)"),
4670 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4671 hasBalls("({'BallElem'} in elemTypes)"),
4672 hasElems0d("({'Elem0d'} in elemTypes)"),
4673 hasEdges("({'Edge'} in elemTypes)"),
4674 hasFaces("({'Face'} in elemTypes)"),
4675 hasVolumes("({'Volume'} in elemTypes)"),
4676 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4678 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4679 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4680 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4681 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4682 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4683 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4685 popupMgr()->insert( separator(), -1, 0 );
4686 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4687 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4688 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4689 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4690 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4691 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4692 popupMgr()->insert( separator(), -1, 0 );
4693 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4694 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4695 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4696 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4697 popupMgr()->insert( separator(), -1, 0 );
4698 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4699 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4700 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4701 popupMgr()->insert( separator(), -1, 0 );
4702 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4703 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4704 popupMgr()->insert( separator(), -1, 0 );
4705 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4706 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4708 // Adaptation - begin
4709 #ifndef DISABLE_MG_ADAPT
4710 popupMgr()->insert( separator(), -1, 0 );
4711 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4712 popupMgr()->insert( separator(), -1, 0 );
4716 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4717 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4718 QString only_one_2D = only_one_non_empty + " && dim>1";
4720 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4721 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4722 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4723 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4724 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4726 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4728 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4729 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4731 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4732 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4733 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4734 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4736 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4738 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4739 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4740 popupMgr()->insert( separator(), -1, 0 );
4742 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4743 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4744 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4747 createPopupItem( SMESHOp::OpEditGroup, View, group );
4748 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4749 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4751 popupMgr()->insert( separator(), -1, 0 );
4752 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4753 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4754 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4755 popupMgr()->insert( separator(), -1, 0 );
4757 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
4758 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4759 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4760 popupMgr()->insert( separator(), -1, 0 );
4762 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4763 QString aType = QString( "%1type in {%2}" ).arg( lc );
4764 aType = aType.arg( mesh_part );
4765 QString aMeshInVTK = aClient + "&&" + aType;
4767 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4768 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4769 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4771 //-------------------------------------------------
4773 //-------------------------------------------------
4774 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4776 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4777 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4778 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4780 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4781 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4782 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4784 popupMgr()->insert( separator(), -1, -1 );
4786 //-------------------------------------------------
4788 //-------------------------------------------------
4789 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4791 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4792 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4793 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4795 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4796 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4797 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4799 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4800 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4801 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4803 popupMgr()->insert( separator(), anId, -1 );
4805 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4806 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4807 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4809 //-------------------------------------------------
4811 //-------------------------------------------------
4812 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4814 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4816 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4817 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4818 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4820 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4821 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4822 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4824 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4825 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4826 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4828 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4829 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4830 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4832 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4833 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4834 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4836 popupMgr()->insert( separator(), anId, -1 );
4838 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4839 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4841 popupMgr()->insert( separator(), anId, -1 );
4843 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4844 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4847 //-------------------------------------------------
4848 // Representation of the 2D Quadratic elements
4849 //-------------------------------------------------
4850 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4851 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4852 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4853 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4855 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4856 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4857 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4859 //-------------------------------------------------
4860 // Orientation of faces
4861 //-------------------------------------------------
4862 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4863 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4864 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4866 //-------------------------------------------------
4868 //-------------------------------------------------
4869 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4870 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4872 //-------------------------------------------------
4874 //-------------------------------------------------
4875 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4876 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4878 //-------------------------------------------------
4880 //-------------------------------------------------
4882 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4883 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4884 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4885 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4887 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4889 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4890 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4892 popupMgr()->insert( separator(), anId, -1 );
4894 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4896 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4897 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4898 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4900 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4901 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4902 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4904 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4905 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4906 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4908 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4910 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4911 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4912 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4914 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4915 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4916 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4918 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4919 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4920 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4921 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4922 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4923 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4925 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4927 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4928 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4929 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4931 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4932 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4933 QtxPopupMgr::VisibleRule );
4934 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4936 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4937 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4938 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4940 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4941 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4942 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4944 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4945 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4946 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4948 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4949 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4950 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4952 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4953 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4954 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4956 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4957 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4958 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4960 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4961 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4962 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4964 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4965 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4966 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4968 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4969 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4970 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4972 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4973 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4974 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4976 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4977 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4978 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4980 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4981 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4982 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4984 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
4985 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
4986 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
4988 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4990 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4991 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4992 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4994 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4995 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4996 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4998 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4999 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5000 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5002 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5003 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5004 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5006 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5007 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5008 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5010 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5011 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5012 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5014 popupMgr()->insert( separator(), anId, -1 );
5016 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5017 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5018 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5019 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5020 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5022 popupMgr()->insert( separator(), anId, -1 );
5024 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5026 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5027 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5029 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5030 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5031 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5033 #ifndef DISABLE_PLOT2DVIEWER
5034 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5035 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5038 //-------------------------------------------------
5040 //-------------------------------------------------
5041 popupMgr()->insert( separator(), -1, -1 );
5042 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5043 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5044 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5045 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5047 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5048 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5050 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5051 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5053 popupMgr()->insert( separator(), -1, -1 );
5055 //-------------------------------------------------
5057 //-------------------------------------------------
5058 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5059 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5061 popupMgr()->insert( separator(), -1, -1 );
5063 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5064 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5065 popupMgr()->insert( separator(), -1, -1 );
5067 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5068 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5070 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5071 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5073 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5074 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5077 //================================================================================
5079 * \brief Return true if SMESH or GEOM objects are selected.
5080 * Is called form LightApp_Module::activateModule() which clear selection if
5081 * not isSelectionCompatible()
5083 //================================================================================
5085 bool SMESHGUI::isSelectionCompatible()
5087 bool isCompatible = true;
5088 SALOME_ListIO selected;
5089 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5090 Sel->selectedObjects( selected );
5092 SALOME_ListIteratorOfListIO It( selected );
5093 for ( ; isCompatible && It.More(); It.Next())
5095 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5096 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5097 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5099 return isCompatible;
5103 bool SMESHGUI::reusableOperation( const int id )
5105 // compute, evaluate and precompute are not reusable operations
5106 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5111 QString wrap(const QString& text, const QString& tag)
5112 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5115 bool SMESHGUI::activateModule( SUIT_Study* study )
5117 bool res = SalomeApp_Module::activateModule( study );
5119 setMenuShown( true );
5120 setToolShown( true );
5122 // Fill in Help Panel
5123 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5124 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5126 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5129 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5130 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5131 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5132 lab = lab + tr("INFO_REFINE") + ":";
5133 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5134 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5135 lab = lab + wrap(items.join(""), "ul");
5138 app->infoPanel()->addLabel(lab, gb);
5140 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5141 items << wrap("UNV", "li")
5142 << wrap("MED", "li")
5143 << wrap("STL", "li")
5144 << wrap("CGNS", "li")
5145 << wrap("GMF", "li");
5146 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5149 app->infoPanel()->addLabel(lab, gb);
5151 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5152 lab = tr("INFO_DISPLAY") + "<br/>";
5153 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5154 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5155 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5156 << wrap("...", "li");
5157 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5159 lab = lab + tr("INFO_CLIPPING");
5161 app->infoPanel()->addLabel(lab, gb);
5164 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5165 PyGILState_STATE gstate = PyGILState_Ensure();
5166 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5167 if ( !pluginsmanager ) {
5171 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5176 PyGILState_Release(gstate);
5177 // end of SMESH plugins loading
5179 // Reset actions accelerator keys
5180 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5182 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5183 GetSMESHGen()->UpdateStudy();
5185 // get all view currently opened in the study and connect their signals to
5186 // the corresponding slots of the class.
5187 SUIT_Desktop* aDesk = study->application()->desktop();
5189 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5190 SUIT_ViewWindow* wnd;
5191 foreach ( wnd, wndList )
5195 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5196 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5202 Py_XDECREF(pluginsmanager);
5206 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5208 setMenuShown( false );
5209 setToolShown( false );
5211 EmitSignalCloseAllDialogs();
5213 // Unset actions accelerator keys
5214 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5216 return SalomeApp_Module::deactivateModule( study );
5219 void SMESHGUI::studyClosed( SUIT_Study* s )
5223 SMESH::RemoveVisuData();
5224 SalomeApp_Module::studyClosed( s );
5227 void SMESHGUI::OnGUIEvent()
5229 const QObject* obj = sender();
5230 if ( !obj || !obj->inherits( "QAction" ) )
5232 int id = actionId((QAction*)obj);
5237 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5239 if ( CORBA::is_nil( myComponentSMESH ) )
5241 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5242 return aGUI.myComponentSMESH;
5244 return myComponentSMESH;
5247 QString SMESHGUI::engineIOR() const
5249 CORBA::ORB_var anORB = getApp()->orb();
5250 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5251 return QString( anIOR.in() );
5254 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5256 SalomeApp_Module::contextMenuPopup( client, menu, title );
5258 selectionMgr()->selectedObjects( lst );
5259 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5260 Handle(SALOME_InteractiveObject) io = lst.First();
5261 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5262 _PTR(Study) study = appStudy->studyDS();
5263 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5265 QString aName = SMESH::fromUtf8( obj->GetName());
5266 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5267 aName.remove(( aName.length() - 1 ), 1 );
5273 LightApp_Selection* SMESHGUI::createSelection() const
5275 return new SMESHGUI_Selection();
5278 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5280 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5281 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5282 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5283 #ifndef DISABLE_PYCONSOLE
5284 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5288 void SMESHGUI::viewManagers( QStringList& list ) const
5290 list.append( SVTK_Viewer::Type() );
5293 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5295 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5296 SMESH::UpdateSelectionProp( this );
5298 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5299 for(int i = 0; i < aViews.count() ; i++){
5300 SUIT_ViewWindow *sf = aViews[i];
5303 EmitSignalActivatedViewManager();
5307 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5309 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5310 myClippingPlaneInfoMap.erase( theViewManager );
5313 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5315 theActor->AddObserver( SMESH::DeleteActorEvent,
5316 myEventCallbackCommand.GetPointer(),
5320 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5321 unsigned long theEvent,
5322 void* theClientData,
5323 void* /*theCallData*/ )
5325 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5326 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5327 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5328 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5329 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5330 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5331 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5332 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5333 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5334 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5335 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5336 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5337 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5338 if( anActor == *anIter3 ) {
5339 anActorList.erase( anIter3 );
5350 void SMESHGUI::createPreferences()
5352 // General tab ------------------------------------------------------------------------
5353 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5355 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5356 setPreferenceProperty( autoUpdate, "columns", 2 );
5357 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5358 setPreferenceProperty( lim, "min", 0 );
5359 setPreferenceProperty( lim, "max", 100000000 );
5360 setPreferenceProperty( lim, "step", 1000 );
5361 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5362 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5364 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5365 setPreferenceProperty( dispgroup, "columns", 2 );
5367 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5369 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5371 modes.append( tr("MEN_WIRE") );
5372 modes.append( tr("MEN_SHADE") );
5373 modes.append( tr("MEN_NODES") );
5374 modes.append( tr("MEN_SHRINK") );
5375 QList<QVariant> indices;
5376 indices.append( 0 );
5377 indices.append( 1 );
5378 indices.append( 2 );
5379 indices.append( 3 );
5380 setPreferenceProperty( dispmode, "strings", modes );
5381 setPreferenceProperty( dispmode, "indexes", indices );
5383 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5384 setPreferenceProperty( arcgroup, "columns", 2 );
5385 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5386 QStringList quadraticModes;
5387 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5388 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5390 indices.append( 0 );
5391 indices.append( 1 );
5392 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5393 setPreferenceProperty( quadraticmode, "indexes", indices );
5395 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5396 "SMESH", "max_angle" );
5397 setPreferenceProperty( maxAngle, "min", 1 );
5398 setPreferenceProperty( maxAngle, "max", 90 );
5400 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5401 setPreferenceProperty( qaGroup, "columns", 2 );
5402 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5403 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5404 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5405 setPreferenceProperty( prec, "min", 0 );
5406 setPreferenceProperty( prec, "max", 100 );
5407 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5408 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5409 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5410 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5411 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5414 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5415 setPreferenceProperty( cinc, "min", 0 );
5416 setPreferenceProperty( cinc, "max", 5 );
5419 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5420 setPreferenceProperty( exportgroup, "columns", 2 );
5421 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5422 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5423 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5424 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5425 setPreferenceProperty( zTol, "precision", 10 );
5426 setPreferenceProperty( zTol, "min", 0.0000000001 );
5427 setPreferenceProperty( zTol, "max", 1000000.0 );
5428 setPreferenceProperty( zTol, "step", 1. );
5429 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5431 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5432 setPreferenceProperty( computeGroup, "columns", 2 );
5433 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5435 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5436 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5437 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5439 indices.append( 0 );
5440 indices.append( 1 );
5441 indices.append( 2 );
5442 setPreferenceProperty( notifyMode, "strings", modes );
5443 setPreferenceProperty( notifyMode, "indexes", indices );
5445 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5446 setPreferenceProperty( infoGroup, "columns", 2 );
5447 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5449 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5450 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5452 indices.append( 0 );
5453 indices.append( 1 );
5454 setPreferenceProperty( elemInfo, "strings", modes );
5455 setPreferenceProperty( elemInfo, "indexes", indices );
5456 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5457 setPreferenceProperty( nodesLim, "min", 0 );
5458 setPreferenceProperty( nodesLim, "max", 10000000 );
5459 setPreferenceProperty( nodesLim, "step", 10000 );
5460 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5461 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5462 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5463 setPreferenceProperty( ctrlLim, "min", 0 );
5464 setPreferenceProperty( ctrlLim, "max", 10000000 );
5465 setPreferenceProperty( ctrlLim, "step", 1000 );
5466 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5467 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5468 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5469 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5470 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5472 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5473 setPreferenceProperty( segGroup, "columns", 2 );
5474 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5475 "SMESH", "segmentation" );
5476 setPreferenceProperty( segLen, "min", 1 );
5477 setPreferenceProperty( segLen, "max", 10000000 );
5478 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5479 "SMESH", "nb_segments_per_edge" );
5480 setPreferenceProperty( nbSeg, "min", 1 );
5481 setPreferenceProperty( nbSeg, "max", 10000000 );
5482 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5484 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5485 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5486 "SMESH", "forget_mesh_on_hyp_modif" );
5489 // Quantities with individual precision settings
5490 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5491 setPreferenceProperty( precGroup, "columns", 2 );
5493 const int nbQuantities = 6;
5494 int precs[nbQuantities], ii = 0;
5495 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5496 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5497 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5498 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5499 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5500 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5501 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5502 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5503 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5504 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5505 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5506 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5508 // Set property for precision value for spinboxes
5509 for ( ii = 0; ii < nbQuantities; ii++ ){
5510 setPreferenceProperty( precs[ii], "min", -14 );
5511 setPreferenceProperty( precs[ii], "max", 14 );
5512 setPreferenceProperty( precs[ii], "precision", 2 );
5515 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5516 setPreferenceProperty( previewGroup, "columns", 2 );
5517 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5518 setPreferenceProperty( chunkSize, "min", 1 );
5519 setPreferenceProperty( chunkSize, "max", 1000 );
5520 setPreferenceProperty( chunkSize, "step", 50 );
5522 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5523 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5525 // Mesh tab ------------------------------------------------------------------------
5526 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5527 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5528 setPreferenceProperty( nodeGroup, "columns", 3 );
5530 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5532 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5534 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5535 QList<QVariant> aMarkerTypeIndicesList;
5536 QList<QVariant> aMarkerTypeIconsList;
5537 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5538 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5539 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5540 aMarkerTypeIndicesList << i;
5541 aMarkerTypeIconsList << pixmap;
5543 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5544 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5546 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5548 QList<QVariant> aMarkerScaleIndicesList;
5549 QStringList aMarkerScaleValuesList;
5550 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5551 aMarkerScaleIndicesList << i;
5552 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5553 aMarkerScaleValuesList << QString::number( i );
5555 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5556 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5558 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5559 //setPreferenceProperty( elemGroup, "columns", 2 );
5561 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5562 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5563 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5564 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5565 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5566 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5567 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5568 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5569 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5572 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5573 setPreferenceProperty( grpGroup, "columns", 2 );
5575 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5576 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5578 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5579 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5580 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5581 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5582 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5583 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5584 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5585 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5586 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5587 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5588 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5589 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5590 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5591 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5593 setPreferenceProperty( size0d, "min", 1 );
5594 setPreferenceProperty( size0d, "max", 10 );
5596 // setPreferenceProperty( ballSize, "min", 1 );
5597 // setPreferenceProperty( ballSize, "max", 10 );
5599 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5600 setPreferenceProperty( ballDiameter, "max", 1e9 );
5601 setPreferenceProperty( ballDiameter, "step", 0.1 );
5603 setPreferenceProperty( ballScale, "min", 1e-2 );
5604 setPreferenceProperty( ballScale, "max", 1e7 );
5605 setPreferenceProperty( ballScale, "step", 0.5 );
5607 setPreferenceProperty( elemW, "min", 1 );
5608 setPreferenceProperty( elemW, "max", 5 );
5610 setPreferenceProperty( outW, "min", 1 );
5611 setPreferenceProperty( outW, "max", 5 );
5613 setPreferenceProperty( shrink, "min", 0 );
5614 setPreferenceProperty( shrink, "max", 100 );
5616 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5617 setPreferenceProperty( numGroup, "columns", 2 );
5619 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5620 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5622 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5623 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5625 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5626 setPreferenceProperty( orientGroup, "columns", 1 );
5628 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5629 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5631 setPreferenceProperty( orientScale, "min", 0.05 );
5632 setPreferenceProperty( orientScale, "max", 0.5 );
5633 setPreferenceProperty( orientScale, "step", 0.05 );
5635 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5637 // Selection tab ------------------------------------------------------------------------
5638 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5640 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5641 setPreferenceProperty( selGroup, "columns", 2 );
5643 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5644 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5646 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5647 setPreferenceProperty( preGroup, "columns", 2 );
5649 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5651 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5652 setPreferenceProperty( precSelGroup, "columns", 2 );
5654 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5655 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5656 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5658 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5659 setPreferenceProperty( sinc, "min", 0 );
5660 setPreferenceProperty( sinc, "max", 5 );
5662 // Scalar Bar tab ------------------------------------------------------------------------
5663 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5664 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5665 setPreferenceProperty( fontGr, "columns", 2 );
5667 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5668 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5670 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5671 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5673 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5674 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5676 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5677 setPreferenceProperty( numcol, "min", 2 );
5678 setPreferenceProperty( numcol, "max", 256 );
5680 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5681 setPreferenceProperty( numlab, "min", 2 );
5682 setPreferenceProperty( numlab, "max", 65 );
5684 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5685 setPreferenceProperty( orientGr, "columns", 2 );
5686 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5687 QStringList orients;
5688 orients.append( tr( "SMESH_VERTICAL" ) );
5689 orients.append( tr( "SMESH_HORIZONTAL" ) );
5690 indices.clear(); indices.append( 0 ); indices.append( 1 );
5691 setPreferenceProperty( orient, "strings", orients );
5692 setPreferenceProperty( orient, "indexes", indices );
5694 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5695 setPreferenceProperty( posVSizeGr, "columns", 2 );
5696 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5697 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5698 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5699 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5700 setPreferenceProperty( xv, "step", 0.1 );
5701 setPreferenceProperty( xv, "min", 0.0 );
5702 setPreferenceProperty( xv, "max", 1.0 );
5703 setPreferenceProperty( yv, "step", 0.1 );
5704 setPreferenceProperty( yv, "min", 0.0 );
5705 setPreferenceProperty( yv, "max", 1.0 );
5706 setPreferenceProperty( wv, "step", 0.1 );
5707 setPreferenceProperty( wv, "min", 0.0 );
5708 setPreferenceProperty( wv, "max", 1.0 );
5709 setPreferenceProperty( hv, "min", 0.0 );
5710 setPreferenceProperty( hv, "max", 1.0 );
5711 setPreferenceProperty( hv, "step", 0.1 );
5713 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5714 setPreferenceProperty( posHSizeGr, "columns", 2 );
5715 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5716 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5717 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5718 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5719 setPreferenceProperty( xv, "min", 0.0 );
5720 setPreferenceProperty( xv, "max", 1.0 );
5721 setPreferenceProperty( xv, "step", 0.1 );
5722 setPreferenceProperty( xh, "min", 0.0 );
5723 setPreferenceProperty( xh, "max", 1.0 );
5724 setPreferenceProperty( xh, "step", 0.1 );
5725 setPreferenceProperty( yh, "min", 0.0 );
5726 setPreferenceProperty( yh, "max", 1.0 );
5727 setPreferenceProperty( yh, "step", 0.1 );
5728 setPreferenceProperty( wh, "min", 0.0 );
5729 setPreferenceProperty( wh, "max", 1.0 );
5730 setPreferenceProperty( wh, "step", 0.1 );
5731 setPreferenceProperty( hh, "min", 0.0 );
5732 setPreferenceProperty( hh, "max", 1.0 );
5733 setPreferenceProperty( hh, "step", 0.1 );
5735 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5736 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5737 setPreferenceProperty( distributionGr, "columns", 3 );
5739 types.append( tr( "SMESH_MONOCOLOR" ) );
5740 types.append( tr( "SMESH_MULTICOLOR" ) );
5741 indices.clear(); indices.append( 0 ); indices.append( 1 );
5742 setPreferenceProperty( coloringType, "strings", types );
5743 setPreferenceProperty( coloringType, "indexes", indices );
5744 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5746 // Adaptation - begin
5747 #ifndef DISABLE_MG_ADAPT
5748 // Adaptation tab ------------------------------------------------------------------------
5749 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
5752 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
5753 setPreferenceProperty( bloc, "columns", 1 );
5754 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
5755 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
5756 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
5757 QStringList aListOfSizeMap;
5758 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
5759 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
5760 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
5761 setPreferenceProperty( pref, "strings", aListOfSizeMap );
5762 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
5763 QStringList aListOfTimeStep;
5764 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
5765 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
5766 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
5767 setPreferenceProperty( pref, "strings", aListOfTimeStep );
5772 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5774 if ( sect=="SMESH" ) {
5775 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5776 double aTol = 1.00000009999999;
5777 std::string aWarning;
5778 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5780 if ( name == "selection_object_color" ||
5781 name == "selection_element_color" ||
5782 name == "highlight_color" ||
5783 name == "selection_precision_node" ||
5784 name == "selection_precision_element" ||
5785 name == "selection_precision_object" ||
5786 name == "selection_increment")
5788 SMESH::UpdateSelectionProp( this );
5790 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5792 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5793 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5794 if ( sbX1+sbW > aTol ) {
5795 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5798 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5799 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5802 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5804 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5805 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5806 if ( sbY1 + sbH > aTol ) {
5807 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5808 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5809 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5812 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5814 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5815 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5816 if ( sbX1 + sbW > aTol ) {
5817 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5820 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5821 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5824 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5826 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5827 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5828 if ( sbY1 + sbH > aTol ) {
5829 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5832 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5833 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5836 else if ( name == "segmentation" )
5838 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5839 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5841 else if ( name == "nb_segments_per_edge" )
5843 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5844 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5846 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5848 QString val = aResourceMgr->stringValue( "SMESH", name );
5849 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5851 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5853 SMESH::UpdateFontProp( this );
5855 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5857 SMESH::UpdateFontProp( this );
5860 if ( aWarning.size() != 0 ) {
5861 aWarning += "The default values are applied instead.";
5862 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5863 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5864 QObject::tr(aWarning.c_str()));
5869 //================================================================================
5871 * \brief Update something in accordance with update flags
5872 * \param theFlags - update flags
5874 * Update viewer or/and object browser etc. in accordance with update flags ( see
5875 * LightApp_UpdateFlags enumeration ).
5877 //================================================================================
5878 void SMESHGUI::update( const int flags )
5880 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5881 SMESH::UpdateView();
5883 SalomeApp_Module::update( flags );
5886 //================================================================================
5888 * \brief Set default selection mode
5890 * SLOT called when operation committed. Sets default selection mode
5892 //================================================================================
5893 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5895 SVTK_ViewWindow* vtkWnd =
5896 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5898 vtkWnd->SetSelectionMode( ActorSelection );
5901 //================================================================================
5903 * \brief Set default selection mode
5905 * SLOT called when operation aborted. Sets default selection mode
5907 //================================================================================
5908 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5910 SVTK_ViewWindow* vtkWnd =
5911 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5913 vtkWnd->SetSelectionMode( ActorSelection );
5916 //================================================================================
5918 * \brief Creates operation with given identifier
5919 * \param id - identifier of operation to be started
5920 * \return Pointer on created operation or NULL if operation is not created
5922 * Virtual method redefined from the base class creates operation with given id.
5923 * It is called called automatically from startOperation method of base class.
5925 //================================================================================
5926 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5928 LightApp_Operation* op = 0;
5929 // to do : create operation here
5932 case SMESHOp::OpSplitBiQuadratic:
5933 op = new SMESHGUI_SplitBiQuadOp();
5935 case SMESHOp::OpConvertMeshToQuadratic:
5936 op = new SMESHGUI_ConvToQuadOp();
5938 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5939 op = new SMESHGUI_Make2DFrom3DOp();
5941 case SMESHOp::OpReorientFaces:
5942 op = new SMESHGUI_ReorientFacesOp();
5944 case SMESHOp::OpCreateMesh:
5945 op = new SMESHGUI_MeshOp( true, true );
5947 case SMESHOp::OpCreateSubMesh:
5948 op = new SMESHGUI_MeshOp( true, false );
5950 case SMESHOp::OpEditMeshOrSubMesh:
5951 case SMESHOp::OpEditMesh:
5952 case SMESHOp::OpEditSubMesh:
5953 op = new SMESHGUI_MeshOp( false );
5955 case SMESHOp::OpCompute:
5956 case SMESHOp::OpComputeSubMesh:
5957 op = new SMESHGUI_ComputeOp();
5959 case SMESHOp::OpShowErrors:
5960 op = new SMESHGUI_ShowErrorsOp();
5962 case SMESHOp::OpPreCompute:
5963 op = new SMESHGUI_PrecomputeOp();
5965 case SMESHOp::OpEvaluate:
5966 op = new SMESHGUI_EvaluateOp();
5968 case SMESHOp::OpMeshOrder:
5969 op = new SMESHGUI_MeshOrderOp();
5971 case SMESHOp::OpCreateGeometryGroup:
5972 op = new SMESHGUI_GroupOnShapeOp();
5974 case SMESHOp::OpFindElementByPoint:
5975 op = new SMESHGUI_FindElemByPointOp();
5977 case SMESHOp::OpMoveNode: // Make mesh pass through point
5978 op = new SMESHGUI_MakeNodeAtPointOp();
5980 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5981 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5988 op = SalomeApp_Module::createOperation( id );
5992 //================================================================================
5994 * \brief Stops current operations and starts a given one
5995 * \param id - The id of the operation to start
5997 //================================================================================
5999 void SMESHGUI::switchToOperation(int id)
6001 activeStudy()->abortAllOperations();
6002 startOperation( id );
6005 LightApp_Displayer* SMESHGUI::displayer()
6008 myDisplayer = new SMESHGUI_Displayer( getApp() );
6012 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6015 int aTolerance = 64;
6016 int anIterations = 0;
6022 if( anIterations % aPeriod == 0 )
6025 if( aTolerance < 1 )
6029 aHue = (int)( 360.0 * rand() / RAND_MAX );
6032 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6033 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6034 for( ; it != itEnd; ++it )
6036 SALOMEDS::Color anAutoColor = *it;
6037 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6040 aQColor.getHsv( &h, &s, &v );
6041 if( abs( h - aHue ) < aTolerance )
6053 aColor.setHsv( aHue, 255, 255 );
6055 SALOMEDS::Color aSColor;
6056 aSColor.R = aColor.redF();
6057 aSColor.G = aColor.greenF();
6058 aSColor.B = aColor.blueF();
6063 const char* gSeparator = "_"; // character used to separate parameter names
6064 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6065 const char* gPathSep = "|"; // character used to separate paths
6068 * \brief Store visual parameters
6070 * This method is called just before the study document is saved.
6071 * Store visual parameters in AttributeParameter attribute(s)
6073 void SMESHGUI::storeVisualParameters (int savePoint)
6076 Kernel_Utils::Localizer loc;
6078 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6079 if (!appStudy || !appStudy->studyDS())
6081 _PTR(Study) studyDS = appStudy->studyDS();
6083 // componentName is used for encoding of entries when storing them in IParameters
6084 std::string componentName = myComponentSMESH->ComponentDataType();
6085 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6086 //if (!aSComponent) return;
6089 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6090 componentName.c_str(),
6092 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6094 // store custom markers
6095 if( !myMarkerMap.empty() )
6097 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6098 for( ; anIter != myMarkerMap.end(); anIter++ )
6100 int anId = anIter->first;
6101 VTK::MarkerData aMarkerData = anIter->second;
6102 std::string aMarkerFileName = aMarkerData.first;
6103 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6104 if( aMarkerTexture.size() < 3 )
6105 continue; // should contain at least width, height and the first value
6107 QString aPropertyName( "texture" );
6108 aPropertyName += gSeparator;
6109 aPropertyName += QString::number( anId );
6111 QString aPropertyValue = aMarkerFileName.c_str();
6112 aPropertyValue += gPathSep;
6114 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6115 ushort aWidth = *aTextureIter++;
6116 ushort aHeight = *aTextureIter++;
6117 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6118 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6119 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6120 aPropertyValue += QString::number( *aTextureIter );
6122 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6126 // viewers counters are used for storing view_numbers in IParameters
6129 // main cycle to store parameters of displayed objects
6130 QList<SUIT_ViewManager*> lst;
6131 QList<SUIT_ViewManager*>::Iterator it;
6132 getApp()->viewManagers(lst);
6133 for (it = lst.begin(); it != lst.end(); it++)
6135 SUIT_ViewManager* vman = *it;
6136 QString vType = vman->getType();
6138 // saving VTK actors properties
6139 if (vType == SVTK_Viewer::Type())
6141 // store the clipping planes attached to the view manager
6142 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6143 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6144 if( anIter != myClippingPlaneInfoMap.end() )
6145 aClippingPlaneInfoList = anIter->second;
6147 if( !aClippingPlaneInfoList.empty() ) {
6148 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6149 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6151 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6152 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6154 QString aPropertyName( "ClippingPlane" );
6155 aPropertyName += gSeparator;
6156 aPropertyName += QString::number( vtkViewers );
6157 aPropertyName += gSeparator;
6158 aPropertyName += QString::number( anId );
6160 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6161 aPropertyValue += gDigitsSep;
6162 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6163 aPropertyValue += gDigitsSep;
6164 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6165 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6166 aPropertyValue += gDigitsSep;
6167 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6168 aPropertyValue += gDigitsSep;
6169 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6170 aPropertyValue += gDigitsSep;
6171 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6172 aPropertyValue += gDigitsSep;
6173 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6174 aPropertyValue += gDigitsSep;
6175 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6176 aPropertyValue += gDigitsSep;
6177 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6179 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6180 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6181 aPropertyValue += gDigitsSep;
6182 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6183 aPropertyValue += gDigitsSep;
6184 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6185 aPropertyValue += gDigitsSep;
6186 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6189 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6193 QVector<SUIT_ViewWindow*> views = vman->getViews();
6194 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6196 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6198 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6199 vtkActorCollection* allActors = aCopy.GetActors();
6200 allActors->InitTraversal();
6201 while (vtkActor* actor = allActors->GetNextActor())
6203 if (actor->GetVisibility()) // store only visible actors
6205 SMESH_Actor* aSmeshActor = 0;
6206 if (actor->IsA("SMESH_Actor"))
6207 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6208 if (aSmeshActor && aSmeshActor->hasIO())
6210 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6213 // entry is "encoded" = it does NOT contain component address,
6214 // since it is a subject to change on next component loading
6215 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6217 std::string param, vtkParam = vType.toLatin1().data();
6218 vtkParam += gSeparator;
6219 vtkParam += QString::number(vtkViewers).toLatin1().data();
6220 vtkParam += gSeparator;
6223 param = vtkParam + "Visibility";
6224 ip->setParameter(entry, param, "On");
6227 param = vtkParam + "Representation";
6228 ip->setParameter(entry, param, QString::number
6229 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6232 param = vtkParam + "IsShrunk";
6233 ip->setParameter(entry, param, QString::number
6234 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6236 // Displayed entities
6237 unsigned int aMode = aSmeshActor->GetEntityMode();
6238 bool isE = aMode & SMESH_Actor::eEdges;
6239 bool isF = aMode & SMESH_Actor::eFaces;
6240 bool isV = aMode & SMESH_Actor::eVolumes;
6241 bool is0d = aMode & SMESH_Actor::e0DElements;
6242 bool isB = aMode & SMESH_Actor::eBallElem;
6244 QString modeStr ("e");
6245 modeStr += gDigitsSep; modeStr += QString::number(isE);
6246 modeStr += gDigitsSep; modeStr += "f";
6247 modeStr += gDigitsSep; modeStr += QString::number(isF);
6248 modeStr += gDigitsSep; modeStr += "v";
6249 modeStr += gDigitsSep; modeStr += QString::number(isV);
6250 modeStr += gDigitsSep; modeStr += "0d";
6251 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6252 modeStr += gDigitsSep; modeStr += "b";
6253 modeStr += gDigitsSep; modeStr += QString::number(isB);
6255 param = vtkParam + "Entities";
6256 ip->setParameter(entry, param, modeStr.toLatin1().data());
6262 aSmeshActor->GetSufaceColor(r, g, b, delta);
6263 QStringList colorStr;
6264 colorStr << "surface";
6265 colorStr << QString::number(r);
6266 colorStr << QString::number(g);
6267 colorStr << QString::number(b);
6269 colorStr << "backsurface";
6270 colorStr << QString::number(delta);
6272 aSmeshActor->GetVolumeColor(r, g, b, delta);
6273 colorStr << "volume";
6274 colorStr << QString::number(r);
6275 colorStr << QString::number(g);
6276 colorStr << QString::number(b);
6277 colorStr << QString::number(delta);
6279 aSmeshActor->GetEdgeColor(r, g, b);
6281 colorStr << QString::number(r);
6282 colorStr << QString::number(g);
6283 colorStr << QString::number(b);
6285 aSmeshActor->GetNodeColor(r, g, b);
6287 colorStr << QString::number(r);
6288 colorStr << QString::number(g);
6289 colorStr << QString::number(b);
6291 aSmeshActor->GetOutlineColor(r, g, b);
6292 colorStr << "outline";
6293 colorStr << QString::number(r);
6294 colorStr << QString::number(g);
6295 colorStr << QString::number(b);
6297 aSmeshActor->Get0DColor(r, g, b);
6298 colorStr << "elem0d";
6299 colorStr << QString::number(r);
6300 colorStr << QString::number(g);
6301 colorStr << QString::number(b);
6303 aSmeshActor->GetBallColor(r, g, b);
6305 colorStr << QString::number(r);
6306 colorStr << QString::number(g);
6307 colorStr << QString::number(b);
6309 aSmeshActor->GetFacesOrientationColor(r, g, b);
6310 colorStr << "orientation";
6311 colorStr << QString::number(r);
6312 colorStr << QString::number(g);
6313 colorStr << QString::number(b);
6315 param = vtkParam + "Colors";
6316 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6319 QStringList sizeStr;
6321 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6322 sizeStr << "outline";
6323 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6324 sizeStr << "elem0d";
6325 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6327 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6328 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6329 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6330 sizeStr << "shrink";
6331 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6332 sizeStr << "orientation";
6333 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6334 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6336 param = vtkParam + "Sizes";
6337 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6342 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6343 if( aMarkerType == VTK::MT_USER ) {
6344 markerStr += "custom";
6345 markerStr += gDigitsSep;
6346 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6350 markerStr += gDigitsSep;
6351 markerStr += QString::number( (int)aMarkerType );
6352 markerStr += gDigitsSep;
6353 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6356 param = vtkParam + "PointMarker";
6357 ip->setParameter(entry, param, markerStr.toLatin1().data());
6360 param = vtkParam + "Opacity";
6361 ip->setParameter(entry, param,
6362 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6365 param = vtkParam + "ClippingPlane";
6367 if( !aClippingPlaneInfoList.empty() ) {
6368 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6369 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6371 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6372 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6373 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6374 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6375 if( aSmeshActor == *anIter2 ) {
6376 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6377 QString::number( anId ).toLatin1().constData() );
6384 ip->setParameter( entry, param, "Off" );
6385 } // if (io->hasEntry())
6386 } // SMESH_Actor && hasIO
6388 } // while.. actors traversal
6392 } // if (SVTK view model)
6393 } // for (viewManagers)
6396 // data structures for clipping planes processing
6400 bool isOpenGLClipping;
6401 vtkIdType RelativeOrientation;
6404 int AbsoluteOrientation;
6405 double X, Y, Z, Dx, Dy, Dz;
6407 typedef std::list<TPlaneData> TPlaneDataList;
6408 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6410 typedef std::list<vtkActor*> TActorList;
6413 TActorList ActorList;
6414 SUIT_ViewManager* ViewManager;
6416 typedef std::list<TPlaneInfo> TPlaneInfoList;
6417 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6420 * \brief Restore visual parameters
6422 * This method is called after the study document is opened.
6423 * Restore visual parameters from AttributeParameter attribute(s)
6425 void SMESHGUI::restoreVisualParameters (int savePoint)
6428 Kernel_Utils::Localizer loc;
6430 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6431 if (!appStudy || !appStudy->studyDS())
6433 _PTR(Study) studyDS = appStudy->studyDS();
6435 // componentName is used for encoding of entries when storing them in IParameters
6436 std::string componentName = myComponentSMESH->ComponentDataType();
6439 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6440 componentName.c_str(),
6442 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6444 // restore custom markers and map of clipping planes
6445 TPlaneDataMap aPlaneDataMap;
6447 std::vector<std::string> properties = ip->getProperties();
6448 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6450 std::string property = *propIt;
6451 QString aPropertyName( property.c_str() );
6452 QString aPropertyValue( ip->getProperty( property ).c_str() );
6454 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6455 if( aPropertyNameList.isEmpty() )
6458 QString aPropertyType = aPropertyNameList[0];
6459 if( aPropertyType == "texture" )
6461 if( aPropertyNameList.size() != 2 )
6465 int anId = aPropertyNameList[1].toInt( &ok );
6466 if( !ok || anId < 1 )
6469 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6470 if( aPropertyValueList.size() != 2 )
6473 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6474 QString aMarkerTextureString = aPropertyValueList[1];
6475 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6476 if( aMarkerTextureStringList.size() != 3 )
6480 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6485 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6489 VTK::MarkerTexture aMarkerTexture;
6490 aMarkerTexture.push_back( aWidth );
6491 aMarkerTexture.push_back( aHeight );
6493 QString aMarkerTextureData = aMarkerTextureStringList[2];
6494 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6496 QChar aChar = aMarkerTextureData.at( i );
6497 if( aChar.isDigit() )
6498 aMarkerTexture.push_back( aChar.digitValue() );
6501 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6503 else if( aPropertyType == "ClippingPlane" )
6505 if( aPropertyNameList.size() != 3 )
6509 int aViewId = aPropertyNameList[1].toInt( &ok );
6510 if( !ok || aViewId < 0 )
6514 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6515 if( !ok || aClippingPlaneId < 0 )
6518 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6519 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6522 TPlaneData aPlaneData;
6523 aPlaneData.AbsoluteOrientation = false;
6524 aPlaneData.RelativeOrientation = 0;
6525 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6526 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6527 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6529 aPlaneData.Id = aClippingPlaneId;
6532 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6537 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6541 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6544 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6549 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6554 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6559 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6564 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6569 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6574 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6578 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6580 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6585 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6590 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6595 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6600 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6601 aPlaneDataList.push_back( aPlaneData );
6605 TPlaneInfoMap aPlaneInfoMap;
6607 std::vector<std::string> entries = ip->getEntries();
6609 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6611 // entry is a normal entry - it should be "decoded" (setting base address of component)
6612 QString entry (ip->decodeEntry(*entIt).c_str());
6614 // Check that the entry corresponds to a real object in the Study
6615 // as the object may be deleted or modified after the visual state is saved.
6616 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6617 if (!so) continue; //Skip the not existent entry
6619 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6620 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6622 std::vector<std::string>::iterator namesIt = paramNames.begin();
6623 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6625 // actors are stored in a map after displaying of them for
6626 // quicker access in the future: map < viewID to actor >
6627 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6629 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6631 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6632 // '_' is used as separator and should not be used in viewer type or parameter names.
6633 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6634 if (lst.size() != 3)
6637 QString viewerTypStr = lst[0];
6638 QString viewIndexStr = lst[1];
6639 QString paramNameStr = lst[2];
6642 int viewIndex = viewIndexStr.toUInt(&ok);
6643 if (!ok) // bad conversion of view index to integer
6647 if (viewerTypStr == SVTK_Viewer::Type())
6649 SMESH_Actor* aSmeshActor = 0;
6650 if (vtkActors.IsBound(viewIndex))
6651 aSmeshActor = vtkActors.Find(viewIndex);
6653 QList<SUIT_ViewManager*> lst;
6654 getApp()->viewManagers(viewerTypStr, lst);
6656 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6657 SUIT_ViewManager* vman = NULL;
6658 if (viewIndex >= 0 && viewIndex < lst.count())
6659 vman = lst.at(viewIndex);
6661 if (paramNameStr == "Visibility")
6663 if (!aSmeshActor && displayer() && vman)
6665 SUIT_ViewModel* vmodel = vman->getViewModel();
6666 // SVTK view model can be casted to SALOME_View
6667 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6669 // store displayed actor in a temporary map for quicker
6670 // access later when restoring other parameters
6671 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6672 vtkRenderer* Renderer = vtkView->getRenderer();
6673 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6674 vtkActorCollection* theActors = aCopy.GetActors();
6675 theActors->InitTraversal();
6676 bool isFound = false;
6677 vtkActor *ac = theActors->GetNextActor();
6678 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6679 if (ac->IsA("SMESH_Actor")) {
6680 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6681 if (aGeomAc->hasIO()) {
6682 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6683 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6685 vtkActors.Bind(viewIndex, aGeomAc);
6691 } // if (paramNameStr == "Visibility")
6694 // the rest properties "work" with SMESH_Actor
6697 QString val ((*valuesIt).c_str());
6700 if (paramNameStr == "Representation") {
6701 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6704 else if (paramNameStr == "IsShrunk") {
6706 if (!aSmeshActor->IsShrunk())
6707 aSmeshActor->SetShrink();
6710 if (aSmeshActor->IsShrunk())
6711 aSmeshActor->UnShrink();
6714 // Displayed entities
6715 else if (paramNameStr == "Entities") {
6716 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6717 int aEntityMode = SMESH_Actor::eAllEntity;
6718 for ( int i = 0; i < mode.count(); i+=2 ) {
6719 if ( i < mode.count()-1 ) {
6720 QString type = mode[i];
6721 bool val = mode[i+1].toInt();
6722 if ( type == "e" && !val )
6723 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6724 else if ( type == "f" && !val )
6725 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6726 else if ( type == "v" && !val )
6727 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6728 else if ( type == "0d" && !val )
6729 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6730 else if ( type == "b" && !val )
6731 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6734 aSmeshActor->SetEntityMode( aEntityMode );
6737 else if (paramNameStr == "Colors") {
6738 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6745 QColor outlineColor;
6746 QColor orientationColor;
6752 // below lines are required to get default values for delta coefficients
6753 // of backface color for faces and color of reversed volumes
6754 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6755 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6756 for ( int i = 0; i < colors.count(); i++ ) {
6757 QString type = colors[i];
6758 if ( type == "surface" ) {
6759 // face color is set by 3 values r:g:b, where
6760 // - r,g,b - is rgb color components
6761 if ( i+1 >= colors.count() ) break; // format error
6762 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6763 if ( i+2 >= colors.count() ) break; // format error
6764 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6765 if ( i+3 >= colors.count() ) break; // format error
6766 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6767 faceColor.setRgbF( r, g, b );
6770 else if ( type == "backsurface" ) {
6771 // backface color can be defined in several ways
6772 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6773 // - in latest versions, it is set as delta coefficient
6774 bool rgbOk = false, deltaOk;
6775 if ( i+1 >= colors.count() ) break; // format error
6776 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6777 int delta = colors[i+1].toInt( &deltaOk );
6779 if ( i+1 < colors.count() ) // index is shifted to 1
6780 g = colors[i+1].toDouble( &rgbOk );
6781 if ( rgbOk ) i++; // shift index
6782 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6783 b = colors[i+1].toDouble( &rgbOk );
6785 // - as currently there's no way to set directly backsurface color as it was before,
6786 // we ignore old dump where r,g,b triple was set
6787 // - also we check that delta parameter is set properly
6788 if ( !rgbOk && deltaOk )
6791 else if ( type == "volume" ) {
6792 // volume color is set by 4 values r:g:b:delta, where
6793 // - r,g,b - is a normal volume rgb color components
6794 // - delta - is a reversed volume color delta coefficient
6795 if ( i+1 >= colors.count() ) break; // format error
6796 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6797 if ( i+2 >= colors.count() ) break; // format error
6798 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6799 if ( i+3 >= colors.count() ) break; // format error
6800 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6801 if ( i+4 >= colors.count() ) break; // format error
6802 int delta = colors[i+4].toInt( &bOk );
6803 if ( !bOk ) break; // format error
6804 volumeColor.setRgbF( r, g, b );
6808 else if ( type == "edge" ) {
6809 // edge color is set by 3 values r:g:b, where
6810 // - r,g,b - is rgb color components
6811 if ( i+1 >= colors.count() ) break; // format error
6812 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6813 if ( i+2 >= colors.count() ) break; // format error
6814 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6815 if ( i+3 >= colors.count() ) break; // format error
6816 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6817 edgeColor.setRgbF( r, g, b );
6820 else if ( type == "node" ) {
6821 // node color is set by 3 values r:g:b, where
6822 // - r,g,b - is rgb color components
6823 if ( i+1 >= colors.count() ) break; // format error
6824 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6825 if ( i+2 >= colors.count() ) break; // format error
6826 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6827 if ( i+3 >= colors.count() ) break; // format error
6828 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6829 nodeColor.setRgbF( r, g, b );
6832 else if ( type == "elem0d" ) {
6833 // 0d element color is set by 3 values r:g:b, where
6834 // - r,g,b - is rgb color components
6835 if ( i+1 >= colors.count() ) break; // format error
6836 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6837 if ( i+2 >= colors.count() ) break; // format error
6838 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6839 if ( i+3 >= colors.count() ) break; // format error
6840 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6841 elem0dColor.setRgbF( r, g, b );
6844 else if ( type == "ball" ) {
6845 // ball color is set by 3 values r:g:b, where
6846 // - r,g,b - is rgb color components
6847 if ( i+1 >= colors.count() ) break; // format error
6848 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6849 if ( i+2 >= colors.count() ) break; // format error
6850 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6851 if ( i+3 >= colors.count() ) break; // format error
6852 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6853 ballColor.setRgbF( r, g, b );
6856 else if ( type == "outline" ) {
6857 // outline color is set by 3 values r:g:b, where
6858 // - r,g,b - is rgb color components
6859 if ( i+1 >= colors.count() ) break; // format error
6860 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6861 if ( i+2 >= colors.count() ) break; // format error
6862 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6863 if ( i+3 >= colors.count() ) break; // format error
6864 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6865 outlineColor.setRgbF( r, g, b );
6868 else if ( type == "orientation" ) {
6869 // orientation color is set by 3 values r:g:b, where
6870 // - r,g,b - is rgb color components
6871 if ( i+1 >= colors.count() ) break; // format error
6872 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6873 if ( i+2 >= colors.count() ) break; // format error
6874 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6875 if ( i+3 >= colors.count() ) break; // format error
6876 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6877 orientationColor.setRgbF( r, g, b );
6882 if ( nodeColor.isValid() )
6883 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6885 if ( edgeColor.isValid() )
6886 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6888 if ( faceColor.isValid() )
6889 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6891 if ( volumeColor.isValid() )
6892 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6893 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6894 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6896 if ( elem0dColor.isValid() )
6897 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6899 if ( ballColor.isValid() )
6900 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6902 if ( outlineColor.isValid() )
6903 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6904 // orientation color
6905 if ( orientationColor.isValid() )
6906 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6909 else if (paramNameStr == "Sizes") {
6910 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6913 int outlineWidth = -1;
6914 int elem0dSize = -1;
6915 //int ballSize = -1;
6916 double ballDiameter = -1.0;
6917 double ballScale = -1.0;
6918 double shrinkSize = -1;
6919 double orientationSize = -1;
6920 bool orientation3d = false;
6921 for ( int i = 0; i < sizes.count(); i++ ) {
6922 QString type = sizes[i];
6923 if ( type == "line" ) {
6924 // line (wireframe) width is given as single integer value
6925 if ( i+1 >= sizes.count() ) break; // format error
6926 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6930 if ( type == "outline" ) {
6931 // outline width is given as single integer value
6932 if ( i+1 >= sizes.count() ) break; // format error
6933 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6937 else if ( type == "elem0d" ) {
6938 // 0d element size is given as single integer value
6939 if ( i+1 >= sizes.count() ) break; // format error
6940 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6944 else if ( type == "ball" ) {
6945 // balls are specified by two values: size:scale, where
6946 // - size - is a integer value specifying size
6947 // - scale - is a double value specifying scale factor
6948 if ( i+1 >= sizes.count() ) break; // format error
6949 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6950 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6951 if ( i+2 >= sizes.count() ) break; // format error
6952 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6958 else if ( type == "shrink" ) {
6959 // shrink factor is given as single floating point value
6960 if ( i+1 >= sizes.count() ) break; // format error
6961 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6965 else if ( type == "orientation" ) {
6966 // orientation vectors are specified by two values size:3d, where
6967 // - size - is a floating point value specifying scale factor
6968 // - 3d - is a boolean
6969 if ( i+1 >= sizes.count() ) break; // format error
6970 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6971 if ( i+2 >= sizes.count() ) break; // format error
6972 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6973 orientationSize = v1;
6974 orientation3d = (bool)v2;
6978 // line (wireframe) width
6979 if ( lineWidth > 0 )
6980 aSmeshActor->SetLineWidth( lineWidth );
6982 if ( outlineWidth > 0 )
6983 aSmeshActor->SetOutlineWidth( outlineWidth );
6984 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6985 aSmeshActor->SetOutlineWidth( lineWidth );
6987 if ( elem0dSize > 0 )
6988 aSmeshActor->Set0DSize( elem0dSize );
6990 /*if ( ballSize > 0 )
6991 aSmeshActor->SetBallSize( ballSize );*/
6993 if ( ballDiameter > 0 )
6994 aSmeshActor->SetBallSize( ballDiameter );
6996 if ( ballScale > 0.0 )
6997 aSmeshActor->SetBallScale( ballScale );
6999 if ( shrinkSize > 0 )
7000 aSmeshActor->SetShrinkFactor( shrinkSize );
7001 // orientation vectors
7002 if ( orientationSize > 0 ) {
7003 aSmeshActor->SetFacesOrientationScale( orientationSize );
7004 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7008 else if (paramNameStr == "PointMarker") {
7009 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7010 if( data.count() >= 2 ) {
7012 int aParam1 = data[1].toInt( &ok );
7014 if( data[0] == "std" && data.count() == 3 ) {
7015 int aParam2 = data[2].toInt( &ok );
7016 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7018 else if( data[0] == "custom" ) {
7019 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7020 if( markerIt != myMarkerMap.end() ) {
7021 VTK::MarkerData aMarkerData = markerIt->second;
7022 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7029 else if (paramNameStr == "Opacity") {
7030 aSmeshActor->SetOpacity(val.toFloat());
7033 else if (paramNameStr.startsWith("ClippingPlane")) {
7034 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7035 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7036 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7037 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7038 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7039 // new format - val looks like "Off" or "0" (plane id)
7040 // (note: in new format "Off" value is used only for consistency,
7041 // so it is processed together with values in old format)
7042 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7043 if( anIsOldFormat ) {
7044 if (paramNameStr == "ClippingPlane1" || val == "Off")
7045 aSmeshActor->RemoveAllClippingPlanes();
7047 QList<SUIT_ViewManager*> lst;
7048 getApp()->viewManagers(viewerTypStr, lst);
7049 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7050 if (viewIndex >= 0 && viewIndex < lst.count()) {
7051 SUIT_ViewManager* vman = lst.at(viewIndex);
7052 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7054 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7056 SMESH::TActorList anActorList;
7057 anActorList.push_back( aSmeshActor );
7058 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7059 aPlane->myViewWindow = vtkView;
7060 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7061 aPlane->PlaneMode = aMode;
7062 bool isOpenGLClipping = ( bool )vals[1].toInt();
7063 aPlane->IsOpenGLClipping = isOpenGLClipping;
7064 if ( aMode == SMESH::Absolute ) {
7065 aPlane->myAbsoluteOrientation = vals[2].toInt();
7066 aPlane->X = vals[3].toFloat();
7067 aPlane->Y = vals[4].toFloat();
7068 aPlane->Z = vals[5].toFloat();
7069 aPlane->Dx = vals[6].toFloat();
7070 aPlane->Dy = vals[7].toFloat();
7071 aPlane->Dz = vals[8].toFloat();
7073 else if ( aMode == SMESH::Relative ) {
7074 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7075 aPlane->myDistance = vals[3].toFloat();
7076 aPlane->myAngle[0] = vals[4].toFloat();
7077 aPlane->myAngle[1] = vals[5].toFloat();
7081 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7082 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7083 aClippingPlaneInfo.Plane = aPlane;
7084 aClippingPlaneInfo.ActorList = anActorList;
7085 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7093 int aPlaneId = val.toInt( &ok );
7094 if( ok && aPlaneId >= 0 ) {
7095 bool anIsDefinedPlane = false;
7096 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7097 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7098 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7099 TPlaneInfo& aPlaneInfo = *anIter;
7100 if( aPlaneInfo.PlaneId == aPlaneId ) {
7101 aPlaneInfo.ActorList.push_back( aSmeshActor );
7102 anIsDefinedPlane = true;
7106 if( !anIsDefinedPlane ) {
7107 TPlaneInfo aPlaneInfo;
7108 aPlaneInfo.PlaneId = aPlaneId;
7109 aPlaneInfo.ActorList.push_back( aSmeshActor );
7110 aPlaneInfo.ViewManager = vman;
7112 // to make the list sorted by plane id
7113 anIter = aPlaneInfoList.begin();
7114 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7115 const TPlaneInfo& aPlaneInfoRef = *anIter;
7116 if( aPlaneInfoRef.PlaneId > aPlaneId )
7119 aPlaneInfoList.insert( anIter, aPlaneInfo );
7124 } // if (aSmeshActor)
7125 } // other parameters than Visibility
7127 } // for names/parameters iterator
7128 } // for entries iterator
7130 // take into account planes with empty list of actors referred to them
7131 QList<SUIT_ViewManager*> aVMList;
7132 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7134 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7135 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7136 int aViewId = aPlaneDataIter->first;
7137 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7138 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7140 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7142 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7143 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7144 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7145 const TPlaneData& aPlaneData = *anIter2;
7146 int aPlaneId = aPlaneData.Id;
7148 bool anIsFound = false;
7149 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7150 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7151 const TPlaneInfo& aPlaneInfo = *anIter3;
7152 if( aPlaneInfo.PlaneId == aPlaneId ) {
7159 TPlaneInfo aPlaneInfo; // ActorList field is empty
7160 aPlaneInfo.PlaneId = aPlaneId;
7161 aPlaneInfo.ViewManager = aViewManager;
7163 // to make the list sorted by plane id
7164 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7165 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7166 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7167 if( aPlaneInfoRef.PlaneId > aPlaneId )
7170 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7176 // add clipping planes to actors according to the restored parameters
7177 // and update the clipping plane map
7178 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7179 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7180 int aViewId = anIter1->first;
7181 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7183 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7184 if( anIter2 == aPlaneDataMap.end() )
7186 const TPlaneDataList& aPlaneDataList = anIter2->second;
7188 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7189 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7190 const TPlaneInfo& aPlaneInfo = *anIter3;
7191 int aPlaneId = aPlaneInfo.PlaneId;
7192 const TActorList& anActorList = aPlaneInfo.ActorList;
7193 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7197 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7201 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7203 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7204 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7205 const TPlaneData& aPlaneData = *anIter4;
7206 if( aPlaneData.Id == aPlaneId ) {
7207 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7208 aPlane->myViewWindow = aViewWindow;
7209 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7210 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7211 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7212 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7213 aPlane->X = aPlaneData.X;
7214 aPlane->Y = aPlaneData.Y;
7215 aPlane->Z = aPlaneData.Z;
7216 aPlane->Dx = aPlaneData.Dx;
7217 aPlane->Dy = aPlaneData.Dy;
7218 aPlane->Dz = aPlaneData.Dz;
7220 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7221 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7222 aPlane->myDistance = aPlaneData.Distance;
7223 aPlane->myAngle[0] = aPlaneData.Angle[0];
7224 aPlane->myAngle[1] = aPlaneData.Angle[1];
7227 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7228 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7229 aClippingPlaneInfo.Plane = aPlane;
7230 aClippingPlaneInfo.ActorList = anActorList;
7231 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7242 // update all VTK views
7243 QList<SUIT_ViewManager*> lst;
7244 getApp()->viewManagers(lst);
7245 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7246 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7247 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7248 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7249 // set OpenGL clipping planes
7250 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7251 vtkActorCollection* anAllActors = aCopy.GetActors();
7252 anAllActors->InitTraversal();
7253 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7254 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7255 anActor->SetOpenGLClippingPlane();
7257 vtkView->getRenderer()->ResetCameraClippingRange();
7264 \brief Adds preferences for dfont of VTK viewer
7266 \param pIf group identifier
7267 \param param parameter
7268 \return identifier of preferences
7270 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7272 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7274 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7277 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7278 fam.append( tr( "SMESH_FONT_COURIER" ) );
7279 fam.append( tr( "SMESH_FONT_TIMES" ) );
7281 setPreferenceProperty( tfont, "fonts", fam );
7283 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7284 if ( needSize ) f = f | QtxFontEdit::Size;
7285 setPreferenceProperty( tfont, "features", f );
7291 \brief Actions after hypothesis edition
7292 Updates object browser after hypothesis edition
7294 void SMESHGUI::onHypothesisEdit( int result )
7297 SMESHGUI::Modified();
7298 updateObjBrowser( true );
7302 \brief Actions after choosing menu of control modes
7303 Updates control mode actions according to current selection
7305 void SMESHGUI::onUpdateControlActions()
7307 SALOME_ListIO selected;
7308 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7309 aSel->selectedObjects( selected );
7311 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7312 if ( selected.Extent() ) {
7313 if ( selected.First()->hasEntry() ) {
7314 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7315 aControl = anActor->GetControlMode();
7316 SALOME_ListIteratorOfListIO it(selected);
7317 for ( it.Next(); it.More(); it.Next() ) {
7318 Handle(SALOME_InteractiveObject) anIO = it.Value();
7319 if ( anIO->hasEntry() ) {
7320 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7321 if ( aControl != anActor->GetControlMode() ) {
7322 aControl = SMESH_Actor::eNone;
7332 int anAction = ActionToControl( aControl, true );
7334 action( anAction )->setChecked( true );
7336 QMenu* send = (QMenu*)sender();
7337 QList<QAction*> actions = send->actions();
7338 for ( int i = 0; i < actions.size(); i++ )
7339 actions[i]->setChecked( false );
7345 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7346 \param pview view being closed
7348 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7349 #ifndef DISABLE_PLOT2DVIEWER
7350 //Crear all Plot2d Viewers if need.
7351 SMESH::ClearPlot2Viewers(pview);
7353 EmitSignalCloseView();
7356 void SMESHGUI::message( const QString& msg )
7359 QStringList data = msg.split("/");
7360 if ( data.count() > 0 ) {
7361 if ( data.first() == "mesh_loading" ) {
7363 QString entry = data.count() > 1 ? data[1] : QString();
7364 if ( entry.isEmpty() )
7367 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7369 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7372 name = SMESH::fromUtf8(obj->GetName());
7373 if ( name.isEmpty() )
7376 if ( data.last() == "stop" )
7377 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7379 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7380 QApplication::processEvents();
7386 \brief Connects or disconnects signals about activating and cloning view on the module slots
7387 \param pview view which is connected/disconnected
7389 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7393 SUIT_ViewManager* viewMgr = pview->getViewManager();
7395 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7396 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7398 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7399 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7404 \brief Return \c true if object can be renamed
7406 bool SMESHGUI::renameAllowed( const QString& entry) const {
7407 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7411 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7415 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7420 if(appStudy->isComponent(entry) || obj->isReference())
7423 // check type to prevent renaming of inappropriate objects
7424 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7425 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7426 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7427 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7428 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7429 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7436 Rename object by entry.
7437 \param entry entry of the object
7438 \param name new name of the object
7439 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7441 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7443 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7447 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7452 _PTR(Study) aStudy = appStudy->studyDS();
7457 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7459 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7464 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7465 _PTR(GenericAttribute) anAttr;
7466 _PTR(AttributeName) aName;
7468 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7470 // check type to prevent renaming of inappropriate objects
7471 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7472 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7473 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7474 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7475 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7476 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7477 if ( !name.isEmpty() ) {
7478 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7480 // update name of group object and its actor
7481 Handle(SALOME_InteractiveObject) IObject =
7482 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7484 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7485 if( !aGroupObject->_is_nil() ) {
7486 aGroupObject->SetName( qUtf8Printable(name) );
7487 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7488 anActor->setName( qUtf8Printable(name) );
7498 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7500 static QList<QColor> colors;
7502 if ( colors.isEmpty() ) {
7504 for (int s = 0; s < 2 ; s++)
7506 for (int v = 100; v >= 40; v = v - 20)
7508 for (int h = 0; h < 359 ; h = h + 60)
7510 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7515 static int currentColor = randomize( colors.size() );
7517 SALOMEDS::Color color;
7518 color.R = (double)colors[currentColor].red() / 255.0;
7519 color.G = (double)colors[currentColor].green() / 255.0;
7520 color.B = (double)colors[currentColor].blue() / 255.0;
7522 currentColor = (currentColor+1) % colors.count();