1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddNodeOnSegmentDlg.h"
36 #include "SMESHGUI_AddNodeOnFaceDlg.h"
37 #include "SMESHGUI_AddQuadraticElementDlg.h"
38 #include "SMESHGUI_BuildCompoundDlg.h"
39 #include "SMESHGUI_ClippingDlg.h"
40 #include "SMESHGUI_ComputeDlg.h"
41 #include "SMESHGUI_ConvToQuadOp.h"
42 #include "SMESHGUI_CopyMeshDlg.h"
43 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
44 #include "SMESHGUI_DeleteGroupDlg.h"
45 #include "SMESHGUI_DisplayEntitiesDlg.h"
46 #include "SMESHGUI_Displayer.h"
47 #include "SMESHGUI_DuplicateNodesDlg.h"
48 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
49 #include "SMESHGUI_ExtrusionDlg.h"
50 #include "SMESHGUI_FaceGroupsSeparatedByEdgesDlg.h"
51 #include "SMESHGUI_FieldSelectorWdg.h"
52 #include "SMESHGUI_FileInfoDlg.h"
53 #include "SMESHGUI_FileValidator.h"
54 #include "SMESHGUI_FilterDlg.h"
55 #include "SMESHGUI_FilterLibraryDlg.h"
56 #include "SMESHGUI_FilterUtils.h"
57 #include "SMESHGUI_FindElemByPointDlg.h"
58 #include "SMESHGUI_GEOMGenUtils.h"
59 #include "SMESHGUI_GroupDlg.h"
60 #include "SMESHGUI_GroupOnShapeDlg.h"
61 #include "SMESHGUI_GroupOpDlg.h"
62 #include "SMESHGUI_GroupUtils.h"
63 #include "SMESHGUI_Hypotheses.h"
64 #include "SMESHGUI_HypothesesUtils.h"
65 #include "SMESHGUI_MG_ADAPTDRIVER.h"
66 #include "SMESHGUI_HomardAdaptDlg.h"
67 #include "SMESHGUI_Make2DFrom3DOp.h"
68 #include "SMESHGUI_MakeNodeAtPointDlg.h"
69 #include "SMESHGUI_Measurements.h"
70 #include "SMESHGUI_MergeDlg.h"
71 #include "SMESHGUI_MeshInfo.h"
72 #include "SMESHGUI_MeshOp.h"
73 #include "SMESHGUI_MeshOrderOp.h"
74 #include "SMESHGUI_MeshPatternDlg.h"
75 #include "SMESHGUI_MeshUtils.h"
76 #include "SMESHGUI_MultiEditDlg.h"
77 #include "SMESHGUI_NodesDlg.h"
78 #include "SMESHGUI_OffsetDlg.h"
79 #include "SMESHGUI_Operations.h"
80 #include "SMESHGUI_PatternUtils.h"
81 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
82 #include "SMESHGUI_PropertiesDlg.h"
83 #include "SMESHGUI_RemoveElementsDlg.h"
84 #include "SMESHGUI_RemoveNodeReconnectionDlg.h"
85 #include "SMESHGUI_RemoveNodesDlg.h"
86 #include "SMESHGUI_RenumberingDlg.h"
87 #include "SMESHGUI_ReorientFacesDlg.h"
88 #include "SMESHGUI_RevolutionDlg.h"
89 #include "SMESHGUI_RotationDlg.h"
90 #include "SMESHGUI_ScaleDlg.h"
91 #include "SMESHGUI_Selection.h"
92 #include "SMESHGUI_SewingDlg.h"
93 #include "SMESHGUI_SingleEditDlg.h"
94 #include "SMESHGUI_SmoothingDlg.h"
95 #include "SMESHGUI_SpinBox.h"
96 #include "SMESHGUI_SplitBiQuad.h"
97 #include "SMESHGUI_SymmetryDlg.h"
98 #include "SMESHGUI_TranslationDlg.h"
99 #include "SMESHGUI_TransparencyDlg.h"
100 #include "SMESHGUI_CreateDualMeshDlg.h"
101 #include "SMESHGUI_CreateDualMeshOp.h"
102 #include "SMESHGUI_Utils.h"
103 #include "SMESHGUI_VTKUtils.h"
105 #include "SMESH_version.h"
107 #include "SMESH_Actor.h"
108 #include "SMESH_ActorUtils.h"
109 #include "SMESH_Client.hxx"
110 #include "SMESH_Comment.hxx"
111 #include "SMESH_ControlsDef.hxx"
112 #include "SMESH_ScalarBarActor.h"
113 #include "SMESH_TypeFilter.hxx"
115 // SALOME GUI includes
116 #include <LightApp_DataOwner.h>
117 #include <LightApp_NameDlg.h>
118 #include <LightApp_Preferences.h>
119 #include <LightApp_SelectionMgr.h>
120 #include <LightApp_UpdateFlags.h>
121 #include <QtxFontEdit.h>
122 #include <QtxPopupMgr.h>
123 #include <QtxInfoPanel.h>
124 #include <SALOME_ListIO.hxx>
125 #include <SUIT_Desktop.h>
126 #include <SUIT_FileDlg.h>
127 #include <SUIT_MessageBox.h>
128 #include <SUIT_OverrideCursor.h>
129 #include <SUIT_ResourceMgr.h>
130 #include <SUIT_Session.h>
131 #include <SVTK_Renderer.h>
132 #include <SVTK_ViewManager.h>
133 #include <SVTK_ViewModel.h>
134 #include <SVTK_ViewWindow.h>
135 #include <SalomeApp_Application.h>
136 #include <SalomeApp_CheckFileDlg.h>
137 #include <SalomeApp_DataObject.h>
138 #include <SalomeApp_Study.h>
139 #include <SalomeApp_Tools.h>
140 #include <VTKViewer_Algorithm.h>
142 #ifndef DISABLE_PLOT2DVIEWER
143 #include <SPlot2d_ViewModel.h>
144 #include <SPlot2d_Histogram.h>
148 #include <SALOMEconfig.h>
149 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
150 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
151 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
152 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
153 #include CORBA_CLIENT_HEADER(SMESH_Homard)
156 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
157 #include <QApplication>
159 #include <QDialogButtonBox>
163 #include <QTextStream>
167 #include <boost/shared_ptr.hpp>
170 #include <vtkCallbackCommand.h>
171 #include <vtkCamera.h>
172 #include <vtkLookupTable.h>
173 #include <vtkPlane.h>
174 #include <vtkRenderer.h>
176 // SALOME KERNEL includes
177 #include <Basics_Utils.hxx>
178 #include <SALOMEDSClient_ClientFactory.hxx>
179 #include <SALOMEDSClient_IParameters.hxx>
180 #include <SALOMEDSClient_SComponent.hxx>
181 #include <SALOMEDSClient_StudyBuilder.hxx>
182 #include <SALOMEDS_SObject.hxx>
183 #include <SALOMEDS_Study.hxx>
184 #include <SALOME_GenericObj_wrap.hxx>
185 #include <SALOME_LifeCycleCORBA.hxx>
186 #include <utilities.h>
189 #include <Standard_ErrorHandler.hxx>
190 #include <NCollection_DataMap.hxx>
191 #include <NCollection_DoubleMap.hxx>
193 // Below macro, when uncommented, switches on simplified (more performant) algorithm
194 // of auto-color picking up
195 #define SIMPLE_AUTOCOLOR
200 //=============================================================
201 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
204 void ExportMeshToFile(int theCommandID);
206 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
208 void SetDisplayEntity(int theCommandID);
210 int ActionToControl( int theID, bool theReversed = false );
212 void Control( int theCommandID );
215 //================================================================================
217 * \brief Reads meshes from file
219 //================================================================================
221 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
225 std::string myExtension;
227 if ( theCommandID == SMESHOp::OpImportMED ||
228 theCommandID == SMESHOp::OpPopupImportMED ) {
229 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
230 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
232 else if ( theCommandID == SMESHOp::OpImportUNV ||
233 theCommandID == SMESHOp::OpPopupImportUNV ) {
234 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
236 else if ( theCommandID == SMESHOp::OpImportDAT ||
237 theCommandID == SMESHOp::OpPopupImportDAT ) {
238 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
240 else if ( theCommandID == SMESHOp::OpImportSTL ||
241 theCommandID == SMESHOp::OpPopupImportSTL ) {
242 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
244 else if ( theCommandID == SMESHOp::OpImportCGNS ||
245 theCommandID == SMESHOp::OpPopupImportCGNS ) {
246 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
248 else if ( theCommandID == SMESHOp::OpImportGMF ||
249 theCommandID == SMESHOp::OpPopupImportGMF ) {
250 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
251 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
254 QString anInitialPath = "";
255 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
256 anInitialPath = QDir::currentPath();
258 QStringList filenames;
259 bool toCreateGroups = true;
261 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
262 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
263 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
264 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
265 // fd->setNameFilters( filter );
266 // fd->SetChecked( true );
268 // filenames << fd->selectedFile();
269 // toCreateGroups = fd->IsChecked();
275 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
278 QObject::tr( "SMESH_IMPORT_MESH" ) );
280 if ( filenames.count() > 0 )
282 SUIT_OverrideCursor wc;
283 _PTR(Study) aStudy = SMESH::getStudy();
286 QStringList anEntryList;
287 bool isEmpty = false;
288 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
290 QString filename = *it;
291 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
293 switch ( theCommandID ) {
294 case SMESHOp::OpImportDAT:
295 case SMESHOp::OpPopupImportDAT:
297 // DAT format (currently unsupported)
298 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
299 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
302 case SMESHOp::OpImportUNV:
303 case SMESHOp::OpPopupImportUNV:
306 aMeshes->length( 1 );
307 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
308 if ( aMeshes[0]->_is_nil() )
309 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
310 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
313 case SMESHOp::OpImportMED:
314 case SMESHOp::OpPopupImportMED:
317 SMESH::DriverMED_ReadStatus res;
318 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
319 if ( res != SMESH::DRS_OK ) {
320 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
321 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
325 case SMESHOp::OpImportSTL:
326 case SMESHOp::OpPopupImportSTL:
329 aMeshes->length( 1 );
330 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
331 if ( aMeshes[0]->_is_nil() ) {
332 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
333 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
337 case SMESHOp::OpImportCGNS:
338 case SMESHOp::OpPopupImportCGNS:
341 SMESH::DriverMED_ReadStatus res;
342 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
343 if ( res != SMESH::DRS_OK ) {
344 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
345 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
349 case SMESHOp::OpImportGMF:
350 case SMESHOp::OpPopupImportGMF:
353 SMESH::ComputeError_var res;
354 aMeshes->length( 1 );
355 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
358 if ( res->code != SMESH::DRS_OK ) {
359 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
360 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
361 if ( strlen( res->comment.in() ) > 0 ) {
362 errors.back() += ": ";
363 errors.back() += res->comment.in();
370 catch ( const SALOME::SALOME_Exception& S_ex ) {
371 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
372 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
375 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
377 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
379 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
380 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
381 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
382 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
383 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
385 anEntryList.append( aMeshSO->GetID().c_str() );
393 // update Object browser
394 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
396 // browse to the published meshes
397 if( LightApp_Application* anApp =
398 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
399 anApp->browseObjects( anEntryList );
401 // show Error message box if there were errors
402 if ( errors.count() > 0 ) {
403 SUIT_MessageBox::critical( SMESHGUI::desktop(),
404 QObject::tr( "SMESH_ERROR" ),
405 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
408 // show warning message box, if some imported mesh is empty
410 SUIT_MessageBox::warning( SMESHGUI::desktop(),
411 QObject::tr( "SMESH_WRN_WARNING" ),
412 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
417 //================================================================================
419 * \brief Export selected meshes or groups into a file
421 //================================================================================
423 void ExportMeshToFile( int theCommandID )
425 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
426 SALOME_ListIO selected;
428 aSel->selectedObjects( selected );
430 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
431 theCommandID == SMESHOp::OpPopupExportDAT );
432 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
433 theCommandID == SMESHOp::OpPopupExportMED );
434 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
435 theCommandID == SMESHOp::OpPopupExportUNV );
436 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
437 theCommandID == SMESHOp::OpPopupExportSTL );
438 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
439 theCommandID == SMESHOp::OpPopupExportCGNS );
440 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
441 theCommandID == SMESHOp::OpPopupExportGMF );
443 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
444 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
446 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
447 bool aCheckWarn = true;
449 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
451 // get mesh object from selection and check duplication of their names
452 bool hasDuplicatedMeshNames = false;
453 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
454 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
455 SALOME_ListIteratorOfListIO It( selected );
456 for( ; It.More(); It.Next() )
458 Handle(SALOME_InteractiveObject) anIObject = It.Value();
459 SMESH::SMESH_IDSource_var aMeshItem =
460 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
461 if ( aMeshItem->_is_nil() ) {
462 SUIT_MessageBox::warning( SMESHGUI::desktop(),
463 QObject::tr( "SMESH_WRN_WARNING" ),
464 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
467 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
468 if ( aCheckWarn && !aGroup->_is_nil() )
470 QMessageBox msgBox(SUIT_MessageBox::Warning,
471 QObject::tr("SMESH_WRN_WARNING"),
472 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
473 QMessageBox::StandardButton::NoButton,
474 SMESHGUI::desktop());
475 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
476 msgBox.addButton(QMessageBox::Ok);
477 msgBox.addButton(QMessageBox::Cancel);
478 msgBox.setDefaultButton(QMessageBox::Cancel);
479 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
480 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
481 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
482 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
483 if ( msgBox.exec() != QMessageBox::Ok )
486 if ( dontShowCheckBox.checkState() == Qt::Checked && resMgr )
487 resMgr->setValue( "SMESH", "show_warning", false);
490 QString aMeshName = anIObject->getName();
492 // check for name duplications
493 if ( !hasDuplicatedMeshNames )
494 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
495 if( aMeshName == (*aMeshIter).second ) {
496 hasDuplicatedMeshNames = true;
501 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
504 if( hasDuplicatedMeshNames && isMED ) {
505 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
506 QObject::tr("SMESH_WRN_WARNING"),
507 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
508 QObject::tr("SMESH_BUT_YES"),
509 QObject::tr("SMESH_BUT_NO"), 0, 1);
514 aMeshIter = aMeshList.begin();
515 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
516 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
517 QString aMeshName = (*aMeshIter).second;
519 if ( isMED || isCGNS ) // formats where group names must be unique
521 // check for equal group names within each mesh
522 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
523 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
524 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
525 int aRet = SUIT_MessageBox::warning
526 (SMESHGUI::desktop(),
527 QObject::tr("SMESH_WRN_WARNING"),
528 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
529 QObject::tr("SMESH_BUT_YES"),
530 QObject::tr("SMESH_BUT_NO"), 0, 1);
537 // Warn the user about presence of not supported elements
539 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
543 notSupportedElemTypes.push_back( SMESH::Entity_0D );
544 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
549 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
550 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
551 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
552 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
553 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
554 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
555 notSupportedElemTypes.push_back( SMESH::Entity_0D );
556 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
561 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
562 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
563 notSupportedElemTypes.push_back( SMESH::Entity_0D );
564 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
569 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
574 notSupportedElemTypes.push_back( SMESH::Entity_0D );
575 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
576 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
577 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
578 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
579 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
580 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
581 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
582 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
583 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
585 if ( ! notSupportedElemTypes.empty() )
587 SMESH::smIdType_array_var nbElems = aMeshOrGroup->GetMeshInfo();
588 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
589 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
590 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
592 if ( !presentNotSupported.empty() )
595 const char* typeMsg[] = {
596 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
597 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
598 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
599 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
600 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
601 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
602 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
603 "SMESH_BIQUADRATIC_PENTAHEDRONS",
604 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
606 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
607 static_assert( sizeof(typeMsg) / sizeof(const char*) == SMESH::Entity_Last,
608 "Update names of EntityType's!!!" );
610 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
611 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
612 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
613 if ( iType != presentNotSupported.size() - 1 )
614 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
616 int aRet = SUIT_MessageBox::warning
617 (SMESHGUI::desktop(),
618 QObject::tr("SMESH_WRN_WARNING"),
619 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
620 QObject::tr("SMESH_BUT_YES"),
621 QObject::tr("SMESH_BUT_NO"), 0, 1);
626 // Get parameters of export operation
629 int aFormat =-1; // for MED version used for write
630 bool isOkToWrite = true; // to check MED file version compatibility before adding a mesh in an existing file
632 // Init the parameters with the default values
633 bool aIsASCII_STL = true;
634 bool toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
635 bool toOverwrite = true;
636 bool toFindOutDim = true;
637 bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true );
638 bool toRenumber = true;
639 double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. );
641 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
642 QString anInitialPath = "";
643 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
644 anInitialPath = QDir::currentPath();
646 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
648 // Get a file name to write in and additional options
649 if ( isGMF ) // Export w/o options
651 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
652 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
653 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
655 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
656 anInitialPath + QString("/") + aMeshName,
657 aFilter, aTitle, false);
659 else if ( isCGNS || isUNV || isDAT ) // Export to [ CGNS | UNV | DAT ] - one option
661 const char* theOptionResource = isCGNS ? "cgns_group_elems_by_type" : "export_renumber";
662 bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
664 QStringList checkBoxes;
665 checkBoxes << QObject::tr( isCGNS ? "CGNS_EXPORT_ELEMS_BY_TYPE" : "SMESH_RENUMBER" );
667 SalomeApp_CheckFileDlg* fd =
668 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
669 fd->setWindowTitle( aTitle );
671 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
673 fd->setNameFilter( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
675 fd->setNameFilter( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
676 if ( !anInitialPath.isEmpty() )
677 fd->setDirectory( anInitialPath );
678 fd->selectFile( aMeshName );
679 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
680 fd->setValidator( fv );
681 fd->SetChecked( option, 0 );
684 aFilename = fd->selectedFile();
685 toOverwrite = fv->isOverwrite( aFilename );
686 option = fd->IsChecked( 0 );
687 SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
688 ( isCGNS ? toCreateGroups : toRenumber ) = option;
692 else if ( isSTL ) // Export to STL
694 QMap<QString, int> aFilterMap;
695 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
696 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
699 QMap<QString, int>::const_iterator it = aFilterMap.begin();
700 for ( ; it != aFilterMap.end(); ++it )
701 filters.push_back( it.key() );
703 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
704 fd->setWindowTitle( aTitle );
705 fd->setNameFilters( filters );
706 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
707 if ( !anInitialPath.isEmpty() )
708 fd->setDirectory( anInitialPath );
709 fd->selectFile(aMeshName);
713 aFilename = fd->selectedFile();
714 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
719 else if ( isMED ) // Export to MED
721 int defaultVersion = 0;
722 QMap<QString, int> aFilterMap;
723 //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
724 //QString vmed (aMesh->GetVersionString(-1, 2));
725 SMESH::long_array_var mvok = aMesh->GetMEDVersionsCompatibleForAppend();
726 if ( mvok->length() > 0)
727 defaultVersion = mvok[0]; // the current version to set the default filter on it
728 for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
730 QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
731 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
734 QMap<QString, int>::const_iterator it = aFilterMap.begin();
735 QString aDefaultFilter = it.key();
736 for ( ; it != aFilterMap.end(); ++it ) {
737 filters.push_back( it.key() );
738 if (it.value() == defaultVersion) // explicit default for MED = current MED version
739 aDefaultFilter = it.key();
741 QStringList checkBoxes;
742 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS")
743 << QObject::tr("SMESH_AUTO_DIM")
744 << QObject::tr("SMESH_MED_SAVE_NUMS");
746 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
747 QList< QWidget* > wdgList;
748 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
749 wdgList.append( fieldSelWdg );
751 QWidget* zTolWdg = new QWidget();
752 QCheckBox* zTolCheck = new QCheckBox( QObject::tr( "SMESH_ZTOLERANCE" ), zTolWdg );
753 SMESHGUI_SpinBox* zTolSpin = new SMESHGUI_SpinBox( zTolWdg );
754 QHBoxLayout* zTolLayout = new QHBoxLayout( zTolWdg );
755 zTolLayout->addWidget( zTolCheck );
756 zTolLayout->addWidget( zTolSpin );
757 zTolLayout->setMargin( 0 );
758 zTolSpin->RangeStepAndValidator( 0, 1e+100, 1., "length_precision" );
759 zTolSpin->setValue( zTol );
760 QObject::connect( zTolCheck, SIGNAL( toggled(bool)), zTolSpin, SLOT( setEnabled(bool)));
761 zTolCheck->setChecked( resMgr->booleanValue( "SMESH", "enable_ztolerance", false ));
762 zTolSpin ->setEnabled( zTolCheck->isChecked() );
763 wdgList.append( zTolWdg );
765 SalomeApp_CheckFileDlg* fd =
766 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
767 fd->setWindowTitle( aTitle );
768 fd->setNameFilters( filters );
769 fd->selectNameFilter( aDefaultFilter );
770 fd->SetChecked( toCreateGroups, 0 );
771 fd->SetChecked( toFindOutDim, 1 );
772 fd->SetChecked( saveNumbers, 2 );
773 if ( !anInitialPath.isEmpty() )
774 fd->setDirectory( anInitialPath );
775 fd->selectFile(aMeshName);
778 QListView *lview = fd->findChild<QListView*>("listView");
780 lview->setMinimumHeight(200);
782 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
784 tview->setMinimumHeight(200);
787 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
788 fd->setValidator( fv );
793 //MESSAGE("******* Loop on file dialog ***********");
796 aFilename = fd->selectedFile();
798 aFilename = QString::null;
801 aFormat = aFilterMap[fd->selectedNameFilter()];
802 //MESSAGE("selected version: " << aFormat << " file: " << aFilename.toUtf8().constData());
803 toOverwrite = fv->isOverwrite(aFilename);
804 //MESSAGE("toOverwrite:" << toOverwrite);
806 if ( !aFilename.isEmpty() ) {
808 // append is only possible if the existing file format is compatible
809 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckWriteCompatibility( aFilename.toUtf8().constData() );
810 MESSAGE("Append check, isVersionOk:" << isVersionOk);
811 if ( !isVersionOk ) {
812 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
813 QObject::tr("SMESH_WRN_WARNING"),
814 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
815 QObject::tr("SMESH_BUT_YES"),
816 QObject::tr("SMESH_BUT_NO"), 0, 1);
820 //MESSAGE("incompatible MED file version for add, overwrite accepted");
826 //MESSAGE("incompatible MED file version for add, overwrite refused");
829 QStringList aMeshNamesCollisionList;
830 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
831 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
832 QString anExistingMeshName( aMeshNames[ i ] );
833 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
834 QString anExportMeshName = (*aMeshIter).second;
835 if( anExportMeshName == anExistingMeshName ) {
836 aMeshNamesCollisionList.append( anExportMeshName );
841 if( !aMeshNamesCollisionList.isEmpty() ) {
843 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
844 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
845 QObject::tr("SMESH_WRN_WARNING"),
846 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
847 QObject::tr("SMESH_BUT_YES"),
848 QObject::tr("SMESH_BUT_NO"),
849 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
850 MESSAGE("answer collision name " << aRet);
861 toCreateGroups = fd->IsChecked(0);
862 toFindOutDim = fd->IsChecked(1);
863 saveNumbers = fd->IsChecked(2);
864 zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1;
865 fieldSelWdg->GetSelectedFields();
866 if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() );
868 if ( !fieldSelWdg->parent() )
870 if ( !zTolWdg->parent() )
881 if ( !aFilename.isEmpty() ) {
882 // Check whether the file already exists and delete it if yes
883 QFile aFile( aFilename );
884 if ( aFile.exists() && toOverwrite )
886 SUIT_OverrideCursor wc;
889 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
890 // bool Renumber = false;
891 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
893 // Renumber= resMgr->booleanValue("renumbering");
895 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
896 // aMeshEditor->RenumberNodes();
897 // aMeshEditor->RenumberElements();
898 // if ( SMESHGUI::automaticUpdate() )
899 // SMESH::UpdateView();
901 if ( isMED && isOkToWrite )
903 aMeshIter = aMeshList.begin();
904 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
906 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
907 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
908 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
909 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
911 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
912 toCreateGroups, aFormat,
913 toOverwrite && aMeshIndex == 0, toFindOutDim,
914 fields, geoAssFields.toLatin1().data(), zTol, saveNumbers );
919 if ( aMeshOrGroup->_is_equivalent( aMesh ))
920 aMesh->ExportDAT( aFilename.toUtf8().data(), toRenumber );
922 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
926 if ( aMeshOrGroup->_is_equivalent( aMesh ))
927 aMesh->ExportUNV( aFilename.toUtf8().data(), toRenumber );
929 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
933 if ( aMeshOrGroup->_is_equivalent( aMesh ))
934 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
936 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
940 aMeshIter = aMeshList.begin();
941 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
943 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
944 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
945 aMeshItem->ExportCGNS( aMeshOrGroup,
946 aFilename.toUtf8().data(),
947 toOverwrite && aMeshIndex == 0,
953 toCreateGroups = true;
954 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
957 catch (const SALOME::SALOME_Exception& S_ex)
960 if ( S_ex.details.type == SALOME::COMM && // communicate about too large mesh
961 strncmp( "format=", S_ex.details.sourceFile.in(), 7 ) == 0 )
963 SUIT_MessageBox::critical(SMESHGUI::desktop(),
964 QObject::tr("SMESH_WRN_WARNING"),
965 QObject::tr(S_ex.details.text.in() ));
967 SUIT_MessageBox::warning(SMESHGUI::desktop(),
968 QObject::tr("SMESH_WRN_WARNING"),
969 QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
975 inline void InverseEntityMode(unsigned int& theOutputMode,
976 unsigned int theMode)
978 bool anIsNotPresent = ~theOutputMode & theMode;
980 theOutputMode |= theMode;
982 theOutputMode &= ~theMode;
985 void SetDisplayEntity(int theCommandID)
987 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
988 SALOME_ListIO selected;
990 aSel->selectedObjects( selected );
992 if ( selected.Extent() >= 1 ) {
993 SUIT_OverrideCursor wc;
994 SALOME_ListIteratorOfListIO It( selected );
995 for( ; It.More(); It.Next()){
996 Handle(SALOME_InteractiveObject) IObject = It.Value();
997 if(IObject->hasEntry()){
998 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
999 unsigned int aMode = anActor->GetEntityMode();
1000 switch(theCommandID){
1001 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1002 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1003 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1004 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1005 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1006 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1009 anActor->SetEntityMode(aMode);
1018 SalomeApp_Application* app =
1019 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1023 LightApp_SelectionMgr* aSel = app->selectionMgr();
1024 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1025 if ( !aSel || !appStudy )
1028 SALOME_ListIO selected;
1029 aSel->selectedObjects( selected );
1030 if ( selected.IsEmpty() )
1033 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1035 _PTR(Study) aStudy = appStudy->studyDS();
1036 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1037 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1038 if ( aMainObject->_is_nil() )
1041 SUIT_OverrideCursor wc;
1043 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1045 QList<SALOMEDS::Color> aReservedColors;
1047 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1048 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1050 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1052 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1053 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1054 #else // old algorithm for auto-colors
1055 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1056 aReservedColors.append( aColor );
1057 #endif // SIMPLE_AUTOCOLOR
1058 aGroupObject->SetColor( aColor );
1060 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1061 if ( aGroupSObject ) {
1064 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1065 switch ( aGroupObject->GetType ()) {
1067 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1069 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1071 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1073 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1075 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1076 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1079 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1080 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1086 SMESH::RepaintCurrentView();
1089 void OverallMeshQuality()
1091 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1092 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1093 SALOME_ListIO selected;
1095 aSel->selectedObjects( selected );
1097 if ( selected.IsEmpty() ) return;
1098 SALOME_ListIteratorOfListIO It( selected );
1099 for ( ; It.More(); It.Next() ) {
1100 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1101 ctrlDlg->showInfo( It.Value() );
1106 QString functorToString( SMESH::Controls::FunctorPtr f )
1108 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1109 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1110 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1111 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1112 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1113 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1114 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1115 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1116 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1117 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1118 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1119 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1120 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1121 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1122 type = QObject::tr( "WARP_ELEMENTS" );
1123 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1124 type = QObject::tr( "TAPER_ELEMENTS" );
1125 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1126 type = QObject::tr( "SKEW_ELEMENTS" );
1127 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1128 type = QObject::tr( "AREA_ELEMENTS" );
1129 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1130 type = QObject::tr( "LENGTH_EDGES" );
1131 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1132 type = QObject::tr( "LENGTH2D_EDGES" );
1133 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1134 type = QObject::tr( "DEFLECTION2D_FACES" );
1135 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1136 type = QObject::tr( "MULTI_BORDERS" );
1137 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1138 type = QObject::tr( "MULTI2D_BORDERS" );
1139 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1140 type = QObject::tr( "FREE_NODES" );
1141 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1142 type = QObject::tr( "FREE_EDGES" );
1143 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1144 type = QObject::tr( "FREE_BORDERS" );
1145 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1146 type = QObject::tr( "FREE_FACES" );
1147 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1148 type = QObject::tr( "BARE_BORDER_VOLUME" );
1149 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1150 type = QObject::tr( "BARE_BORDER_FACE" );
1151 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1152 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1153 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1154 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1155 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1156 type = QObject::tr( "EQUAL_NODE" );
1157 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1158 type = QObject::tr( "EQUAL_EDGE" );
1159 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1160 type = QObject::tr( "EQUAL_FACE" );
1161 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1162 type = QObject::tr( "EQUAL_VOLUME" );
1163 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1164 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1168 void SaveDistribution()
1170 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1171 SALOME_ListIO selected;
1173 aSel->selectedObjects( selected );
1175 if ( selected.Extent() == 1 ) {
1176 Handle(SALOME_InteractiveObject) anIO = selected.First();
1177 if ( anIO->hasEntry() ) {
1178 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1180 anActor->GetScalarBarActor() &&
1181 anActor->GetControlMode() != SMESH_Actor::eNone )
1183 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1184 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1185 if ( aScalarBarActor && aFunctor ) {
1186 SMESH::Controls::NumericalFunctor* aNumFun =
1187 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1189 std::vector<smIdType> elements;
1190 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1191 if ( mesh->_is_nil() ) {
1192 SMESH::SMESH_IDSource_var idSource =
1193 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1194 if ( !idSource->_is_nil() )
1196 SMESH::smIdType_array_var ids = idSource->GetIDs();
1197 elements.resize( ids->length() );
1198 for ( unsigned i = 0; i < elements.size(); ++i )
1199 elements[i] = ids[i];
1202 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1203 vtkLookupTable* lookupTable =
1204 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1205 double * minmax = lookupTable->GetRange();
1206 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1207 std::vector<int> nbEvents;
1208 std::vector<double> funValues;
1209 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1210 elements, minmax, isLogarithmic );
1211 QString anInitialPath = "";
1212 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1213 anInitialPath = QDir::currentPath();
1214 QString aMeshName = anIO->getName();
1216 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1217 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1218 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1219 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1220 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1223 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1225 if ( !aFilename.isEmpty() ) {
1226 QFile f( aFilename );
1227 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1228 QTextStream out( &f );
1229 out << "# Mesh: " << aMeshName << endl;
1230 out << "# Control: " << functorToString( aFunctor ) << endl;
1232 out.setFieldWidth( 10 );
1233 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1234 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1245 void ShowElement( int theCommandID )
1247 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1248 SALOME_ListIO selected;
1250 aSel->selectedObjects( selected );
1252 if ( selected.Extent() == 1 ) {
1253 Handle(SALOME_InteractiveObject) anIO = selected.First();
1254 if ( anIO->hasEntry() ) {
1255 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1257 anActor->GetScalarBarActor() &&
1258 anActor->GetControlMode() != SMESH_Actor::eNone )
1260 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1261 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1262 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1264 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1265 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1272 #ifndef DISABLE_PLOT2DVIEWER
1273 void PlotDistribution()
1275 SalomeApp_Application* app =
1276 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1280 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1281 SALOME_ListIO selected;
1283 aSel->selectedObjects( selected );
1285 if ( selected.Extent() == 1 ) {
1286 Handle(SALOME_InteractiveObject) anIO = selected.First();
1287 if ( anIO->hasEntry() ) {
1288 //Find Actor by entry before getting Plot2d viewer,
1289 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1290 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1292 SUIT_ViewManager* aViewManager =
1293 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1297 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1301 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1305 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1307 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1308 QString functorName = functorToString( anActor->GetFunctor());
1309 QString aHistogramName("%1 : %2");
1310 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1311 aHistogram->setName(aHistogramName);
1312 aHistogram->setHorTitle(functorName);
1313 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1314 aPlot->displayObject(aHistogram, true);
1319 #endif //DISABLE_PLOT2DVIEWER
1321 void DisableAutoColor()
1323 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1324 SALOME_ListIO selected;
1326 aSel->selectedObjects( selected );
1328 if ( selected.Extent() ) {
1329 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1330 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1331 if ( !aMesh->_is_nil() ) {
1332 aMesh->SetAutoColor( false );
1339 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1340 SALOME_ListIO selected;
1342 aSel->selectedObjects( selected );
1343 if ( selected.Extent() )
1345 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1346 _PTR(Study) aStudy = SMESH::getStudy();
1347 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1349 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1350 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1357 // Break link with Shaper model
1358 void breakShaperLink()
1360 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1361 SALOME_ListIO selected;
1363 aSel->selectedObjects(selected);
1364 if (selected.Extent()) {
1365 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1366 _PTR(Study) aStudy = SMESH::getStudy();
1367 std::string aEntry = anIObject->getEntry();
1368 _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
1370 std::string aName = aSObj->GetName();
1371 QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
1372 QObject::tr("SMESH_WRN_WARNING"),
1373 QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
1374 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
1375 if (aRes == SUIT_MessageBox::Yes) {
1376 SUIT_DataOwnerPtrList aList;
1377 aSel->selected(aList, "ObjectBrowser", true);
1378 SUIT_DataOwner* aOwn = aList.first();
1379 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
1380 QString aREntry = sowner->entry();
1382 static GEOM::GEOM_Gen_var geomGen;
1383 if (CORBA::is_nil(geomGen)) {
1384 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1385 (SUIT_Session::session()->activeApplication());
1387 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
1388 Engines::EngineComponent_var comp =
1389 ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
1390 geomGen = GEOM::GEOM_Gen::_narrow(comp);
1393 if (!CORBA::is_nil(geomGen))
1395 geomGen->BreakLink(aREntry.toStdString().c_str());
1396 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1398 // remove actors whose objects are removed by BreakLink()
1399 QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
1400 SUIT_ViewWindow* wnd;
1401 foreach(wnd, wndList)
1402 SMESH::UpdateActorsAfterUpdateStudy(wnd);
1410 //================================================================================
1412 * \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
1413 * which means that the mesh can't be modified. It should be either re-computed
1414 * or breakShaperLink()'ed. Warn the user about it.
1416 //================================================================================
1418 bool warnOnGeomModif()
1420 SALOME_ListIO selected;
1421 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1422 aSel->selectedObjects(selected,"",/*convertReferences=*/false);
1424 SALOME_ListIteratorOfListIO It( selected );
1425 for ( ; It.More(); It.Next() )
1427 Handle(SALOME_InteractiveObject) io = It.Value();
1428 if ( !io->hasEntry() ) continue;
1429 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
1430 SMESH::SMESH_Mesh_var mesh;
1431 while ( mesh->_is_nil() && so && so->GetID() != "0:" )
1433 CORBA::Object_var obj = SMESH::SObjectToObject( so );
1434 SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
1435 if ( isrc->_is_nil() )
1436 so = so->GetFather();
1438 mesh = isrc->GetMesh();
1440 if ( mesh->_is_nil() ) continue;
1441 so = SMESH::FindSObject( mesh );
1442 if ( !so ) continue;
1443 _PTR(GenericAttribute) attr;
1444 so->FindAttribute( attr, "AttributePixMap" );
1445 _PTR(AttributePixMap) pixmap = attr;
1446 if ( !pixmap ) continue;
1448 if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
1450 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1451 QObject::tr("SMESH_WRN_WARNING"),
1452 QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
1459 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1461 SALOME_ListIO selected;
1462 SalomeApp_Application* app =
1463 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1467 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1468 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1469 if ( !aSel || !appStudy )
1472 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1473 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1474 aModule->EmitSignalDeactivateDialog();
1475 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1476 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1481 aSel->selectedObjects( selected );
1483 if ( selected.Extent() >= 1 )
1485 switch ( theCommandID ) {
1486 case SMESHOp::OpTransparency:
1488 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1489 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1492 case SMESHOp::OpProperties:
1495 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1496 QColor orientationColor, outlineColor, volumeColor;
1497 int deltaF = 0, deltaV = 0;
1500 double ballScale = 1.0;
1502 int outlineWidth = 1;
1503 double shrinkCoef = 0.0;
1504 double orientationScale = 0.0;
1505 bool orientation3d = false;
1506 VTK::MarkerType markerType = VTK::MT_NONE;
1507 VTK::MarkerScale markerScale = VTK::MS_NONE;
1509 bool hasNodes = false;
1510 int presentEntities = 0;
1511 bool firstTime = true;
1513 SALOME_ListIteratorOfListIO It( selected );
1514 for ( ; It.More(); It.Next() ) {
1515 Handle(SALOME_InteractiveObject) IObject = It.Value();
1516 if ( !IObject->hasEntry() ) continue;
1517 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1518 if ( !anActor || !anActor->GetObject() ) continue;
1521 // nodes: color, marker
1522 anActor->GetNodeColor( color[0], color[1], color[2] );
1523 nodeColor.setRgbF( color[0], color[1], color[2] );
1524 markerType = anActor->GetMarkerType();
1525 markerScale = anActor->GetMarkerScale();
1526 markerId = anActor->GetMarkerTexture();
1527 // edges: color, width
1528 anActor->GetEdgeColor( color[0], color[1], color[2] );
1529 edgeColor.setRgbF( color[0], color[1], color[2] );
1530 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1531 // faces: front color, back color (delta)
1532 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1533 faceColor.setRgbF( color[0], color[1], color[2] );
1534 // faces: front color, back color (delta)
1535 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1536 volumeColor.setRgbF( color[0], color[1], color[2] );
1537 // 0d elements: color, size
1538 anActor->Get0DColor( color[0], color[1], color[2] );
1539 elem0dColor.setRgbF( color[0], color[1], color[2] );
1540 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1541 // balls: color, size
1542 anActor->GetBallColor( color[0], color[1], color[2] );
1543 ballColor.setRgbF( color[0], color[1], color[2] );
1544 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1545 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1547 anActor->GetOutlineColor( color[0], color[1], color[2] );
1548 outlineColor.setRgbF( color[0], color[1], color[2] );
1549 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1550 // orientation vectors: color, scale, 3d flag
1551 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1552 orientationColor.setRgbF( color[0], color[1], color[2] );
1553 orientationScale = anActor->GetFacesOrientationScale();
1554 orientation3d = anActor->GetFacesOrientation3DVectors();
1556 shrinkCoef = anActor->GetShrinkFactor();
1559 firstTime = false; // we only take properties from first object (for performance reasons)
1562 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1563 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1564 presentEntities = presentEntities | SMESH_Actor::eEdges;
1565 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1566 presentEntities = presentEntities | SMESH_Actor::eFaces;
1567 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1568 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1569 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1570 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1571 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1572 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1574 // as we know that all types of elements are present, we can exit the loop
1575 if ( presentEntities == SMESH_Actor::eAllEntity )
1579 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1580 // nodes: color, marker
1581 dlg.setNodeColor( nodeColor );
1582 if( markerType != VTK::MT_USER )
1583 dlg.setNodeMarker( markerType, markerScale );
1585 dlg.setNodeCustomMarker( markerId );
1586 // edges: color, line width
1587 dlg.setEdgeColor( edgeColor );
1588 dlg.setEdgeWidth( edgeWidth );
1589 // faces: front color, back color
1590 dlg.setFaceColor( faceColor, deltaF );
1591 // volumes: normal color, reversed color
1592 dlg.setVolumeColor( volumeColor, deltaV );
1593 // outlines: color, line width
1594 dlg.setOutlineColor( outlineColor );
1595 dlg.setOutlineWidth( outlineWidth );
1596 // 0d elements: color, size
1597 dlg.setElem0dColor( elem0dColor );
1598 dlg.setElem0dSize( elem0dSize );
1599 // balls: color, size
1600 dlg.setBallColor( ballColor );
1601 //dlg.setBallSize( ballSize );
1602 dlg.setBallScale( ballScale );
1603 // orientation: color, scale, 3d flag
1604 dlg.setOrientationColor( orientationColor );
1605 dlg.setOrientationSize( int( orientationScale * 100. ) );
1606 dlg.setOrientation3d( orientation3d );
1607 // shrink: scale factor
1608 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1609 // hide unused controls
1610 dlg.showControls( presentEntities, hasNodes );
1613 nodeColor = dlg.nodeColor();
1614 markerType = dlg.nodeMarkerType();
1615 markerScale = dlg.nodeMarkerScale();
1616 markerId = dlg.nodeMarkerId();
1617 edgeColor = dlg.edgeColor();
1618 edgeWidth = dlg.edgeWidth();
1619 faceColor = dlg.faceColor();
1620 deltaF = dlg.faceColorDelta();
1621 volumeColor = dlg.volumeColor();
1622 deltaV = dlg.volumeColorDelta();
1623 outlineColor = dlg.outlineColor();
1624 outlineWidth = dlg.outlineWidth();
1625 elem0dColor = dlg.elem0dColor();
1626 elem0dSize = dlg.elem0dSize();
1627 ballColor = dlg.ballColor();
1628 // ballSize = dlg.ballSize();
1629 ballScale = dlg.ballScale();
1630 orientationColor = dlg.orientationColor();
1631 orientationScale = dlg.orientationSize() / 100.;
1632 orientation3d = dlg.orientation3d();
1633 shrinkCoef = dlg.shrinkCoef() / 100.;
1635 // store point markers that might be changed by the user
1636 theMarkerMap = dlg.customMarkers();
1638 // set properties from dialog box to the presentations
1639 SALOME_ListIteratorOfListIO It( selected );
1640 for ( ; It.More(); It.Next() ) {
1641 Handle(SALOME_InteractiveObject) IObject = It.Value();
1642 if ( !IObject->hasEntry() ) continue;
1643 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1644 if ( !anActor ) continue;
1646 // nodes: color, marker
1647 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1648 if ( markerType != VTK::MT_USER ) {
1649 anActor->SetMarkerStd( markerType, markerScale );
1652 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1653 if ( iter != theMarkerMap.end() )
1654 anActor->SetMarkerTexture( markerId, iter->second.second );
1656 // volumes: normal color, reversed color (delta)
1657 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1658 // faces: front color, back color (delta)
1659 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1660 // edges: color, width
1661 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1662 anActor->SetLineWidth( edgeWidth );
1664 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1665 anActor->SetOutlineWidth( outlineWidth );
1666 // 0D elements: color, size
1667 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1668 anActor->Set0DSize( elem0dSize );
1669 // balls: color, size
1670 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1671 // anActor->SetBallSize( ballSize );
1672 anActor->SetBallScale( ballScale );
1673 // orientation: color, scale, 3d flag
1674 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1675 anActor->SetFacesOrientationScale( orientationScale );
1676 anActor->SetFacesOrientation3DVectors( orientation3d );
1678 anActor->SetShrinkFactor( shrinkCoef );
1680 // for groups, set also proper color
1681 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1682 if ( !aGroupObject->_is_nil() ) {
1683 SMESH::ElementType anElementType = aGroupObject->GetType();
1685 switch( anElementType ) {
1687 aColor = nodeColor; break;
1689 aColor = edgeColor; break;
1691 aColor = faceColor; break;
1693 aColor = volumeColor; break;
1695 aColor = elem0dColor; break;
1697 aColor = ballColor; break;
1701 if ( aColor.isValid() ) {
1702 SALOMEDS::Color aGroupColor;
1703 aGroupColor.R = aColor.redF();
1704 aGroupColor.G = aColor.greenF();
1705 aGroupColor.B = aColor.blueF();
1706 aGroupObject->SetColor( aGroupColor );
1708 } // if ( !aGroupObject->_is_nil() )
1709 } // for ( ; It.More(); It.Next() )
1710 SMESH::RepaintCurrentView();
1711 } // if ( dlg.exec() )
1713 } // case SMESHOp::OpProperties:
1714 } // switch(theCommandID)
1715 SUIT_OverrideCursor wc;
1716 SALOME_ListIteratorOfListIO It( selected );
1717 for( ; It.More(); It.Next()){
1718 Handle(SALOME_InteractiveObject) IObject = It.Value();
1719 if(IObject->hasEntry()){
1720 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1721 switch(theCommandID){
1722 case SMESHOp::OpDMWireframe:
1723 anActor->SetRepresentation(SMESH_Actor::eEdge);
1725 case SMESHOp::OpDMShading:
1726 anActor->SetRepresentation(SMESH_Actor::eSurface);
1728 case SMESHOp::OpDMShrink:
1729 if(anActor->IsShrunk())
1730 anActor->UnShrink();
1732 anActor->SetShrink();
1734 case SMESHOp::OpDMNodes:
1735 anActor->SetRepresentation(SMESH_Actor::ePoint);
1737 case SMESHOp::OpRepresentationLines:
1738 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1739 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1741 case SMESHOp::OpRepresentationArcs:
1742 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1743 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1749 SMESH::RepaintCurrentView();
1753 int ActionToControl( int theID, bool theReversed )
1755 NCollection_DoubleMap<int,int> ActionControl;
1756 ActionControl.Bind( 0, SMESH_Actor::eNone );
1757 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1758 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1759 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1760 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1761 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1762 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1763 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1764 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1765 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1766 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1767 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1768 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1769 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1770 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1771 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1772 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1773 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1774 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1775 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1776 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1777 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1778 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1779 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1780 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1781 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1782 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1783 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1784 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1787 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1788 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1791 void Control( int theCommandID )
1793 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1794 _PTR(Study) aStudy = SMESH::getStudy();
1796 SALOME_ListIO selected;
1797 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1798 aSel->selectedObjects( selected );
1800 if ( !selected.IsEmpty() ) {
1801 SALOME_ListIteratorOfListIO It(selected);
1802 for ( ; It.More(); It.Next())
1804 Handle(SALOME_InteractiveObject) anIO = It.Value();
1805 if ( !anIO.IsNull() ) {
1806 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1808 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1809 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1810 if ( !anIDSrc->_is_nil() ) {
1811 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1812 if (( !anActor && selected.Extent() == 1 ) &&
1813 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1815 anActor->SetControlMode( aControl );
1816 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1817 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1821 if ( anActor->GetControlMode() != aControl )
1822 anActor->SetControlMode( aControl );
1823 QString functorName = functorToString( anActor->GetFunctor() );
1824 smIdType anEntitiesCount = anActor->GetNumberControlEntities();
1825 if (anEntitiesCount >= 0)
1826 functorName = functorName + ": " + QString::number(anEntitiesCount);
1827 anActor->GetScalarBarActor()->SetTitle( functorName.toUtf8().constData() );
1828 SMESH::RepaintCurrentView();
1829 #ifndef DISABLE_PLOT2DVIEWER
1830 if ( anActor->GetPlot2Histogram() ) {
1831 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1832 QString aHistogramName("%1 : %2");
1833 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1834 aHistogram->setName( aHistogramName );
1835 aHistogram->setHorTitle( functorName );
1836 SMESH::ProcessIn2DViewers( anActor );
1848 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1849 SMESH::MeshObjectType theType,
1850 const QString theInTypeName,
1851 QString & theOutTypeName)
1853 SMESH_TypeFilter aTypeFilter( theType );
1855 if ( !theIO.IsNull() )
1857 entry = theIO->getEntry();
1858 LightApp_DataOwner owner( entry );
1859 if ( aTypeFilter.isOk( &owner )) {
1860 theOutTypeName = theInTypeName;
1868 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1870 _PTR(Study) aStudy = SMESH::getStudy();
1871 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1873 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1874 CORBA::String_var anID = aSComp->GetID().c_str();
1875 if ( !strcmp(anID.in(),theIO->getEntry()) )
1881 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1882 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1883 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1884 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1885 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1893 // QString CheckHomogeneousSelection()
1895 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1896 // SALOME_ListIO selected;
1898 // aSel->selectedObjects( selected );
1900 // QString RefType = CheckTypeObject(selected.First());
1901 // SALOME_ListIteratorOfListIO It(selected);
1902 // for ( ; It.More(); It.Next())
1904 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1905 // QString Type = CheckTypeObject(IObject);
1906 // if ( Type.compare(RefType) != 0 )
1907 // return "Heterogeneous Selection";
1913 uint randomize( uint size )
1915 static bool initialized = false;
1916 if ( !initialized ) {
1917 qsrand( QDateTime::currentDateTime().toTime_t() );
1921 v = uint( (double)( v ) / RAND_MAX * size );
1922 v = qMax( uint(0), qMin ( v, size-1 ) );
1928 void SMESHGUI::OnEditDelete()
1930 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1931 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1932 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1934 _PTR(Study) aStudy = SMESH::getStudy();
1935 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1936 _PTR(GenericAttribute) anAttr;
1937 _PTR(AttributeIOR) anIOR;
1939 const int objectCountLimit = 30; // PAL23599
1940 int objectCount = 0;
1942 QString aParentComponent = QString::null;
1944 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1946 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
1947 if ( anIO.IsNull() ) continue;
1949 QString father = "unknown", name;
1951 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
1953 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
1954 // check if object is reference
1955 _PTR(SObject) aRefSObj;
1956 if ( aSO->ReferencedObject( aRefSObj ) ) {
1957 name = QString::fromStdString ( aRefSObj->GetName() );
1958 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1961 name = anIO->getName();
1964 if ( objectCount < objectCountLimit ) { // avoid occupying the whole screen
1965 aNameList.append("\n - ");
1966 aNameList.append( name );
1969 if( aParentComponent.isNull() )
1970 aParentComponent = father;
1971 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
1972 aParentComponent = "";
1974 if ( objectCount >= objectCountLimit )
1975 aNameList.append("\n - ...");
1977 if ( objectCount == 0 )
1978 return; // No Valid Objects Selected
1980 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1981 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1982 QObject::tr("ERR_ERROR"),
1983 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1986 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1987 if (SUIT_MessageBox::warning
1988 (SMESHGUI::desktop(),
1989 QObject::tr("SMESH_WRN_WARNING"),
1990 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1991 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1992 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1995 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1997 // Put one level of sub-objects of the selected SO's into a list
1998 // in order to get objects inside folders like "Assigned Algorithms"
1999 std::list< _PTR(SObject) > listSO;
2000 SALOME_ListIteratorOfListIO It(selected);
2001 for( ; It.More(); It.Next()) // loop on selected IO's
2003 Handle(SALOME_InteractiveObject) IObject = It.Value();
2004 if(IObject->hasEntry()) {
2005 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
2007 // disable removal of "SMESH" component object
2008 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
2010 if ( engineIOR() == anIOR->Value().c_str() )
2013 //Check the referenced object
2014 _PTR(SObject) aRefSObject;
2015 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
2016 aSO = aRefSObject; // Delete main Object instead of reference
2018 listSO.push_back( aSO );
2020 _PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
2021 for (it->InitEx(false); it->More(); it->Next())
2022 listSO.push_back( it->Value() );
2025 // Check if none of objects to delete is referred from outside
2026 std::list< _PTR(SObject) >::reverse_iterator ritSO;
2027 std::vector< _PTR(SObject) > subSO;
2028 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2030 _PTR(SObject) SO = *ritSO;
2031 if ( !SO ) continue;
2033 int nbChildren = SO->GetLastChildTag();
2035 subSO.reserve( 1 + nbChildren );
2036 subSO.push_back( SO );
2037 if ( nbChildren > 0 )
2039 _PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
2040 for ( it->InitEx( true ); it->More(); it->Next() )
2041 subSO.push_back( it->Value() );
2043 for ( size_t i = 0; i < subSO.size(); ++i )
2045 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
2046 for ( size_t j = 0; j < aReferences.size(); j++ ) {
2047 _PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
2048 std::string type = aComponent->ComponentDataType();
2049 if ( type != "SMESH" )
2051 SUIT_MessageBox::warning( anApp->desktop(),
2052 QObject::tr("WRN_WARNING"),
2053 QObject::tr("DEP_OBJECT") );
2054 return; // outside SMESH, there is an object depending on a SMESH object
2060 // Treat SO's in the list starting from the back
2061 aStudyBuilder->NewCommand(); // There is a transaction
2062 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2064 _PTR(SObject) SO = *ritSO;
2065 if ( !SO ) continue;
2066 std::string anEntry = SO->GetID();
2068 /** Erase graphical object and remove all its data **/
2069 if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
2070 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
2072 /** Remove an object from data structures **/
2073 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
2074 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
2075 if ( !aGroup->_is_nil() ) { // DELETE GROUP
2076 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
2077 aMesh->RemoveGroup( aGroup );
2079 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
2080 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2081 aMesh->RemoveSubMesh( aSubMesh );
2084 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
2085 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
2086 QString objType = CheckTypeObject(IObject);
2087 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
2088 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2089 aStudyBuilder->RemoveObjectWithChildren( SO );
2091 else {// default action: remove SObject from the study
2092 // Find Sub-Meshes and Group and delete corresopning visual objects and actors
2093 _PTR(ChildIterator) it1 = aStudy->NewChildIterator(SO);
2094 for (it1->InitEx(false); it1->More(); it1->Next()) {
2095 _PTR(SObject) SObj = it1->Value();
2096 if (!SObj) continue;
2097 if (SObj->FindAttribute(anAttr, "AttributeIOR")) {
2098 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(SMESH::SObjectToObject(SObj));
2099 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(SMESH::SObjectToObject(SObj));
2100 if (!aGroup->_is_nil() || !aSubMesh->_is_nil()) {
2101 SMESH::RemoveVisualObjectWithActors(SObj->GetID().c_str(), true);
2105 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2106 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2108 aStudyBuilder->RemoveObjectWithChildren( SO );
2112 } /* listSO back loop */
2114 aStudyBuilder->CommitCommand();
2116 /* Clear any previous selection */
2118 aSel->setSelectedObjects( l1 );
2120 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2124 SMESHGUI_EXPORT CAM_Module* createModule()
2126 return new SMESHGUI();
2129 SMESHGUI_EXPORT char* getModuleVersion() {
2130 return (char*)SMESH_VERSION_STR;
2134 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2136 //=============================================================================
2140 //=============================================================================
2141 SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" )
2143 if ( CORBA::is_nil( myComponentSMESH ) )
2145 CORBA::Boolean anIsEmbeddedMode;
2146 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2148 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2150 // 0019923: EDF 765 SMESH : default values of hypothesis
2151 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2152 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2153 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2154 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2155 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2157 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2158 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2159 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2161 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2162 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2166 myActiveDialogBox = 0;
2167 myFilterLibraryDlg = 0;
2171 myEventCallbackCommand = vtkCallbackCommand::New();
2172 myEventCallbackCommand->Delete();
2173 myEventCallbackCommand->SetClientData( this );
2174 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2177 /* load resources for all available meshers */
2178 SMESH::InitAvailableHypotheses();
2181 //=============================================================================
2185 //=============================================================================
2186 SMESHGUI::~SMESHGUI()
2190 //=============================================================================
2194 //=============================================================================
2195 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2197 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2199 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2204 //=============================================================================
2208 //=============================================================================
2209 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2211 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2215 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2216 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2217 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2218 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2219 return autoUpdate && !exceeded;
2222 //=============================================================================
2226 //=============================================================================
2227 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2228 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2230 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2234 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2235 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2236 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2238 SMESH::smIdType_array_var info = theMesh->GetMeshInfo();
2239 long nbOdElems = info[SMDSEntity_0D];
2240 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2241 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2242 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2243 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2244 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2245 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2246 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2247 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2248 info[SMDSEntity_Polyhedra] +
2249 info[SMDSEntity_Hexagonal_Prism];
2250 long nbBalls = info[SMDSEntity_Ball];
2252 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2253 *nbElements = requestedSize;
2255 *entities = SMESH_Actor::eAllEntity;
2258 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2260 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2262 if ( incrementalLimit ) {
2265 if ( nbOdElems > 0 ) {
2266 if ( total + nbOdElems > updateLimit ) {
2267 *entities = *entities & ~SMESH_Actor::e0DElements;
2268 *hidden = *hidden | SMESH_Actor::e0DElements;
2275 if ( nbEdges > 0 ) {
2276 if ( total + nbEdges > updateLimit ) {
2277 *entities = *entities & ~SMESH_Actor::eEdges;
2278 *hidden = *hidden | SMESH_Actor::eEdges;
2285 if ( nbFaces > 0 ) {
2286 if ( total + nbFaces > updateLimit ) {
2287 *entities = *entities & ~SMESH_Actor::eFaces;
2288 *hidden = *hidden | SMESH_Actor::eFaces;
2295 if ( nbVolumes > 0 ) {
2296 if ( total + nbVolumes > updateLimit ) {
2297 *entities = *entities & ~SMESH_Actor::eVolumes;
2298 *hidden = *hidden | SMESH_Actor::eVolumes;
2305 if ( nbBalls > 0 ) {
2306 if ( total + nbBalls > updateLimit ) {
2307 *entities = *entities & ~SMESH_Actor::eBallElem;
2308 *hidden = *hidden | SMESH_Actor::eBallElem;
2316 return autoUpdate && !exceeded;
2319 //=============================================================================
2323 //=============================================================================
2324 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2326 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2329 //=============================================================================
2333 //=============================================================================
2334 SMESHGUI* SMESHGUI::GetSMESHGUI()
2336 SMESHGUI* smeshMod = 0;
2337 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2340 CAM_Module* module = app->module( "Mesh" );
2341 smeshMod = dynamic_cast<SMESHGUI*>( module );
2349 Standard_EXPORT SMESHGUI* GetComponentGUI()
2351 return SMESHGUI::GetSMESHGUI();
2355 //=============================================================================
2359 //=============================================================================
2360 void SMESHGUI::SetState(int aState)
2365 //=============================================================================
2369 //=============================================================================
2370 void SMESHGUI::ResetState()
2375 //=============================================================================
2379 //=============================================================================
2380 void SMESHGUI::EmitSignalDeactivateDialog()
2382 emit SignalDeactivateActiveDialog();
2385 //=============================================================================
2389 //=============================================================================
2390 void SMESHGUI::EmitSignalStudyFrameChanged()
2392 emit SignalStudyFrameChanged();
2395 //=============================================================================
2399 //=============================================================================
2400 void SMESHGUI::EmitSignalCloseAllDialogs()
2402 emit SignalCloseAllDialogs();
2405 //=============================================================================
2409 //=============================================================================
2410 void SMESHGUI::EmitSignalVisibilityChanged()
2412 emit SignalVisibilityChanged();
2415 //=============================================================================
2419 //=============================================================================
2420 void SMESHGUI::EmitSignalCloseView()
2422 emit SignalCloseView();
2425 //=============================================================================
2429 //=============================================================================
2430 void SMESHGUI::EmitSignalActivatedViewManager()
2432 emit SignalActivatedViewManager();
2435 //=============================================================================
2439 //=============================================================================
2440 QDialog *SMESHGUI::GetActiveDialogBox()
2442 return myActiveDialogBox;
2445 //=============================================================================
2449 //=============================================================================
2450 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2452 myActiveDialogBox = (QDialog *) aDlg;
2456 //=============================================================================
2460 //=============================================================================
2461 SUIT_Desktop* SMESHGUI::desktop()
2463 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2465 return app->desktop();
2470 //=============================================================================
2474 //=============================================================================
2475 SalomeApp_Study* SMESHGUI::activeStudy()
2477 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2479 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2484 //=============================================================================
2488 //=============================================================================
2489 void SMESHGUI::Modified( bool theIsUpdateActions )
2491 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2492 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2493 appStudy->Modified();
2494 if( theIsUpdateActions )
2495 app->updateActions();
2500 //=============================================================================
2504 //=============================================================================
2505 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2507 /* Here the position is on the bottom right corner - 10 */
2508 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2510 SUIT_Desktop *PP = desktop();
2511 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2512 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2517 * \brief Verifies whether study of operation is locked
2518 * \param theMess - specifies whether message box must be shown if study is locked
2519 * \return State of study.
2521 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2522 * is locked when corresponding message box appears
2524 bool SMESHGUI::isStudyLocked( bool theMessage )
2526 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2529 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2530 QObject::tr( "WRN_WARNING" ),
2531 QObject::tr( "WRN_STUDY_LOCKED" ) );
2537 //=============================================================================
2541 //=============================================================================
2542 bool SMESHGUI::OnGUIEvent( int theCommandID )
2544 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2548 SUIT_ResourceMgr* mgr = resourceMgr();
2552 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2553 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2555 //QAction* act = action( theCommandID );
2557 switch (theCommandID) {
2558 case SMESHOp::OpDelete:
2559 if(isStudyLocked()) break;
2562 case SMESHOp::OpImportDAT:
2563 case SMESHOp::OpImportUNV:
2564 case SMESHOp::OpImportMED:
2565 case SMESHOp::OpImportSTL:
2566 case SMESHOp::OpImportCGNS:
2567 case SMESHOp::OpImportGMF:
2568 case SMESHOp::OpPopupImportDAT:
2569 case SMESHOp::OpPopupImportUNV:
2570 case SMESHOp::OpPopupImportMED:
2571 case SMESHOp::OpPopupImportSTL:
2572 case SMESHOp::OpPopupImportCGNS:
2573 case SMESHOp::OpPopupImportGMF:
2575 if(isStudyLocked()) break;
2576 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2580 case SMESHOp::OpFileInformation:
2582 SALOME_ListIO selected;
2583 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2585 aSel->selectedObjects( selected );
2586 if( selected.Extent() )
2588 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2589 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2590 if ( !aMesh->_is_nil() )
2592 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2598 case SMESHOp::OpExportDAT:
2599 case SMESHOp::OpExportMED:
2600 case SMESHOp::OpExportUNV:
2601 case SMESHOp::OpExportSTL:
2602 case SMESHOp::OpExportCGNS:
2603 case SMESHOp::OpExportGMF:
2604 case SMESHOp::OpPopupExportDAT:
2605 case SMESHOp::OpPopupExportMED:
2606 case SMESHOp::OpPopupExportUNV:
2607 case SMESHOp::OpPopupExportSTL:
2608 case SMESHOp::OpPopupExportCGNS:
2609 case SMESHOp::OpPopupExportGMF:
2611 ::ExportMeshToFile(theCommandID);
2615 case SMESHOp::OpReset: // SCALAR BAR
2617 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2618 SALOME_ListIO selected;
2620 aSel->selectedObjects( selected );
2622 SALOME_ListIteratorOfListIO it(selected);
2623 for( ; it.More(); it.Next()) {
2624 Handle(SALOME_InteractiveObject) anIO = it.Value();
2625 if( anIO->hasEntry() ) {
2626 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2627 anActor->SetControlMode( SMESH_Actor::eNone );
2628 #ifndef DISABLE_PLOT2DVIEWER
2629 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2631 anActor->UpdateFilter();
2635 SMESH::UpdateView();
2638 case SMESHOp::OpScalarBarProperties:
2640 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2643 case SMESHOp::OpShowScalarBar:
2645 // show/hide scalar bar
2646 ::ShowElement(theCommandID);
2649 case SMESHOp::OpSaveDistribution:
2651 // dump control distribution data to the text file
2652 ::SaveDistribution();
2656 case SMESHOp::OpShowDistribution:
2658 // show/hide distribution
2659 ::ShowElement(theCommandID);
2663 #ifndef DISABLE_PLOT2DVIEWER
2664 case SMESHOp::OpPlotDistribution:
2666 // plot distribution
2667 ::PlotDistribution();
2673 case SMESHOp::OpAutoColor:
2677 case SMESHOp::OpDisableAutoColor:
2678 ::DisableAutoColor();
2681 case SMESHOp::OpClipping:
2682 case SMESHOp::OpTransparency:
2683 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2686 case SMESHOp::OpDMWireframe:
2687 case SMESHOp::OpDMShading:
2688 case SMESHOp::OpDMNodes:
2689 case SMESHOp::OpDMShrink:
2690 ::SetDisplayMode(theCommandID, myMarkerMap);
2693 //2D quadratic representation
2694 case SMESHOp::OpRepresentationLines:
2695 case SMESHOp::OpRepresentationArcs:
2696 ::SetDisplayMode(theCommandID, myMarkerMap);
2700 case SMESHOp::OpDE0DElements:
2701 case SMESHOp::OpDEEdges:
2702 case SMESHOp::OpDEFaces:
2703 case SMESHOp::OpDEVolumes:
2704 case SMESHOp::OpDEBalls:
2705 case SMESHOp::OpDEAllEntity:
2706 ::SetDisplayEntity(theCommandID);
2709 // Choose entities to be displayed
2710 case SMESHOp::OpDEChoose:
2712 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2716 case SMESHOp::OpOrientationOnFaces:
2718 SUIT_OverrideCursor wc;
2719 LightApp_SelectionMgr* mgr = selectionMgr();
2720 SALOME_ListIO selected; mgr->selectedObjects( selected );
2722 SALOME_ListIteratorOfListIO it(selected);
2723 for( ; it.More(); it.Next()) {
2724 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2725 if(anIObject->hasEntry()) {
2726 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2727 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2734 case SMESHOp::OpUpdate:
2736 if(isStudyLocked()) break;
2737 SUIT_OverrideCursor wc;
2740 SMESH::UpdateView();
2742 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2743 SMESH::OnVisuException();
2745 catch (...) { // PAL16774 (Crash after display of many groups)
2746 SMESH::OnVisuException();
2750 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2751 aSel->selectedObjects( l );
2752 aSel->setSelectedObjects( l );
2756 case SMESHOp::OpHide:
2757 case SMESHOp::OpShow:
2758 case SMESHOp::OpShowOnly:
2760 SUIT_OverrideCursor wc;
2761 SMESH::EDisplaing anAction;
2762 switch (theCommandID) {
2763 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2764 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2765 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2768 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2769 SALOME_ListIO sel_objects, to_process;
2771 aSel->selectedObjects( sel_objects );
2773 if ( theCommandID==SMESHOp::OpShowOnly )
2775 //MESSAGE("anAction = SMESH::eDisplayOnly");
2776 startOperation( myEraseAll );
2779 extractContainers( sel_objects, to_process );
2784 SALOME_ListIteratorOfListIO It( to_process );
2785 for ( ; It.More(); It.Next())
2787 Handle(SALOME_InteractiveObject) IOS = It.Value();
2788 if ( IOS->hasEntry() )
2790 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2791 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2792 break; // PAL16774 (Crash after display of many groups)
2794 if (anAction == SMESH::eDisplayOnly)
2795 anAction = SMESH::eDisplay;
2800 // PAL13338 + PAL15161 -->
2801 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2802 SMESH::UpdateView();
2803 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2805 // PAL13338 + PAL15161 <--
2807 catch (...) { // PAL16774 (Crash after display of many groups)
2808 SMESH::OnVisuException();
2811 if (anAction == SMESH::eErase) {
2813 aSel->setSelectedObjects( l1 );
2816 aSel->setSelectedObjects( to_process );
2818 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2819 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2820 vtkwnd->GetRenderer()->AdjustActors();
2825 case SMESHOp::OpNode:
2827 if(isStudyLocked()) break;
2830 EmitSignalDeactivateDialog();
2832 ( new SMESHGUI_NodesDlg( this ) )->show();
2835 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2840 case SMESHOp::OpEditMeshOrSubMesh:
2841 case SMESHOp::OpEditMesh:
2842 case SMESHOp::OpEditSubMesh:
2843 case SMESHOp::OpMeshOrder:
2844 case SMESHOp::OpCreateSubMesh:
2845 if ( warnOnGeomModif() )
2846 break; // action forbidden as geometry modified
2848 case SMESHOp::OpCreateMesh:
2849 case SMESHOp::OpCompute:
2850 case SMESHOp::OpComputeSubMesh:
2851 case SMESHOp::OpPreCompute:
2852 case SMESHOp::OpEvaluate:
2853 case SMESHOp::OpShowErrors:
2854 startOperation( theCommandID );
2856 case SMESHOp::OpRecompute:
2858 if ( isStudyLocked() )
2860 SALOME_ListIO selected;
2861 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2862 sel->selectedObjects( selected );
2863 if ( selected.Extent() == 1 ) {
2864 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2865 if ( !aMesh->_is_nil() )
2867 startOperation( SMESHOp::OpCompute );
2871 case SMESHOp::OpCopyMesh:
2873 if (isStudyLocked()) break;
2874 EmitSignalDeactivateDialog();
2875 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2878 case SMESHOp::OpBuildCompoundMesh:
2880 if (isStudyLocked()) break;
2881 EmitSignalDeactivateDialog();
2882 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2886 case SMESHOp::OpDiagonalInversion:
2887 case SMESHOp::OpUnionOfTwoTriangle:
2891 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2895 if ( isStudyLocked() )
2897 if ( warnOnGeomModif() )
2898 break; // action forbidden as geometry modified
2900 /*Standard_Boolean aRes;
2901 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2902 if ( aMesh->_is_nil() )
2904 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2905 tr( "SMESH_BAD_SELECTION" ) );
2909 EmitSignalDeactivateDialog();
2910 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2911 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2913 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2916 case SMESHOp::OpOrientation:
2917 case SMESHOp::OpUnionOfTriangles:
2918 case SMESHOp::OpCuttingOfQuadrangles:
2919 case SMESHOp::OpSplitVolumes:
2923 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2927 if ( isStudyLocked() )
2929 if ( warnOnGeomModif() )
2930 break; // action forbidden as geometry modified
2932 EmitSignalDeactivateDialog();
2933 SMESHGUI_MultiEditDlg* aDlg = NULL;
2934 if ( theCommandID == SMESHOp::OpOrientation )
2935 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2936 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2937 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2938 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2939 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2941 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2946 case SMESHOp::OpSmoothing:
2948 if(isStudyLocked()) break;
2949 if ( warnOnGeomModif() )
2950 break; // action forbidden as geometry modified
2952 EmitSignalDeactivateDialog();
2953 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2956 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2960 case SMESHOp::OpExtrusion:
2962 if (isStudyLocked()) break;
2963 if ( warnOnGeomModif() )
2964 break; // action forbidden as geometry modified
2966 EmitSignalDeactivateDialog();
2967 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2969 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2973 case SMESHOp::OpExtrusionAlongAPath:
2975 if (isStudyLocked()) break;
2976 if ( warnOnGeomModif() )
2977 break; // action forbidden as geometry modified
2979 EmitSignalDeactivateDialog();
2980 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2982 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2986 case SMESHOp::OpRevolution:
2988 if(isStudyLocked()) break;
2989 if ( warnOnGeomModif() )
2990 break; // action forbidden as geometry modified
2992 EmitSignalDeactivateDialog();
2993 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2996 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3000 case SMESHOp::OpPatternMapping:
3002 if ( isStudyLocked() )
3004 if ( warnOnGeomModif() )
3005 break; // action forbidden as geometry modified
3008 EmitSignalDeactivateDialog();
3009 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3012 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3016 // Adaptation - begin
3017 #ifndef DISABLE_MG_ADAPT
3018 case SMESHOp::OpMGAdapt:
3020 if ( isStudyLocked() )
3022 EmitSignalDeactivateDialog();
3024 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3025 bool isCreation = false;
3026 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3030 #ifndef DISABLE_HOMARD_ADAPT
3031 case SMESHOp::OpHomardAdapt:
3033 if ( isStudyLocked() )
3035 EmitSignalDeactivateDialog();
3037 SALOME::GenericObj_wrap< SMESHHOMARD::HOMARD_Gen > homardGen;
3039 homardGen = GetSMESHGen()->CreateHOMARD_ADAPT();
3041 catch ( const SALOME::SALOME_Exception& S_ex ) {
3042 SUIT_MessageBox::critical(SMESHGUI::desktop(),
3043 QObject::tr("SMESH_ERROR"),
3044 QObject::tr(S_ex.details.text.in()));
3046 if (!homardGen->_is_nil()) {
3047 SMESHGUI_HomardAdaptDlg *aDlg = new SMESHGUI_HomardAdaptDlg(homardGen);
3054 case SMESHOp::OpSplitBiQuadratic:
3055 case SMESHOp::OpConvertMeshToQuadratic:
3056 case SMESHOp::OpCreateDualMesh:
3057 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3058 case SMESHOp::OpReorientFaces:
3059 case SMESHOp::OpCreateGeometryGroup:
3061 if ( warnOnGeomModif() )
3062 break; // action forbidden as geometry modified
3063 startOperation( theCommandID );
3066 case SMESHOp::OpCreateGroup:
3070 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3074 if(isStudyLocked()) break;
3075 if ( warnOnGeomModif() )
3076 break; // action forbidden as geometry modified
3077 EmitSignalDeactivateDialog();
3078 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3080 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3081 SALOME_ListIO selected;
3083 aSel->selectedObjects( selected );
3085 int nbSel = selected.Extent();
3087 // check if mesh is selected
3088 aMesh = SMESH::GetMeshByIO( selected.First() );
3090 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3095 case SMESHOp::OpConstructGroup:
3099 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3103 if(isStudyLocked()) break;
3104 if ( warnOnGeomModif() )
3105 break; // action forbidden as geometry modified
3106 EmitSignalDeactivateDialog();
3108 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3109 SALOME_ListIO selected;
3111 aSel->selectedObjects( selected );
3113 int nbSel = selected.Extent();
3115 // check if submesh is selected
3116 Handle(SALOME_InteractiveObject) IObject = selected.First();
3117 if (IObject->hasEntry()) {
3118 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3120 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3121 if (!aSubMesh->_is_nil()) {
3123 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3124 // get submesh elements list by types
3125 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3126 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3127 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3128 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3129 // create group for each type o elements
3130 QString aName = IObject->getName();
3131 QStringList anEntryList;
3132 if (aNodes->length() > 0) {
3133 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3134 aGroup->Add(aNodes.inout());
3135 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3136 anEntryList.append( aSObject->GetID().c_str() );
3138 if (aEdges->length() > 0) {
3139 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3140 aGroup->Add(aEdges.inout());
3141 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3142 anEntryList.append( aSObject->GetID().c_str() );
3144 if (aFaces->length() > 0) {
3145 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3146 aGroup->Add(aFaces.inout());
3147 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3148 anEntryList.append( aSObject->GetID().c_str() );
3150 if (aVolumes->length() > 0) {
3151 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3152 aGroup->Add(aVolumes.inout());
3153 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3154 anEntryList.append( aSObject->GetID().c_str() );
3157 anApp->browseObjects( anEntryList );
3159 catch(const SALOME::SALOME_Exception & S_ex){
3160 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3167 SUIT_MessageBox::warning(desktop(),
3168 tr("SMESH_WRN_WARNING"),
3169 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3174 case SMESHOp::OpEditGroup:
3178 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3182 if(isStudyLocked()) break;
3183 if ( warnOnGeomModif() )
3184 break; // action forbidden as geometry modified
3185 EmitSignalDeactivateDialog();
3187 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3188 SALOME_ListIO selected;
3190 aSel->selectedObjects( selected );
3192 SALOME_ListIteratorOfListIO It (selected);
3193 int nbSelectedGroups = 0;
3194 for ( ; It.More(); It.Next() )
3196 SMESH::SMESH_GroupBase_var aGroup =
3197 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3198 if (!aGroup->_is_nil()) {
3200 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3204 if (nbSelectedGroups == 0)
3206 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3212 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3214 if(isStudyLocked()) break;
3215 if (myState == 800) {
3216 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3217 if (aDlg) aDlg->onAdd();
3222 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3224 if(isStudyLocked()) break;
3225 if (myState == 800) {
3226 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3227 if (aDlg) aDlg->onRemove();
3232 case SMESHOp::OpEditGeomGroupAsGroup:
3236 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3240 if(isStudyLocked()) break;
3241 EmitSignalDeactivateDialog();
3243 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3244 SALOME_ListIO selected;
3246 aSel->selectedObjects( selected );
3248 SALOME_ListIteratorOfListIO It (selected);
3249 for ( ; It.More(); It.Next() )
3251 SMESH::SMESH_GroupOnGeom_var aGroup =
3252 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3253 if (!aGroup->_is_nil()) {
3254 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3259 SMESH::SMESH_GroupOnFilter_var aGroup =
3260 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3261 if (!aGroup->_is_nil()) {
3262 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3270 case SMESHOp::OpUnionGroups:
3271 case SMESHOp::OpIntersectGroups:
3272 case SMESHOp::OpCutGroups:
3276 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3280 if ( isStudyLocked() )
3282 if ( warnOnGeomModif() )
3283 break; // action forbidden as geometry modified
3285 EmitSignalDeactivateDialog();
3287 SMESHGUI_GroupOpDlg* aDlg = 0;
3288 if ( theCommandID == SMESHOp::OpUnionGroups )
3289 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3290 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3291 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3293 aDlg = new SMESHGUI_CutGroupsDlg( this );
3300 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3302 if ( isStudyLocked() )
3304 if ( warnOnGeomModif() )
3305 break; // action forbidden as geometry modified
3307 EmitSignalDeactivateDialog();
3308 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3314 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3316 if ( isStudyLocked() )
3318 if ( warnOnGeomModif() )
3319 break; // action forbidden as geometry modified
3321 EmitSignalDeactivateDialog();
3322 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3328 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3332 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3336 if ( isStudyLocked() )
3339 EmitSignalDeactivateDialog();
3341 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3345 case SMESHOp::OpMeshInformation:
3346 case SMESHOp::OpWhatIs:
3348 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3349 EmitSignalDeactivateDialog();
3350 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3351 SALOME_ListIO selected;
3353 aSel->selectedObjects( selected );
3355 if ( selected.Extent() > 1 ) { // a dlg for each IO
3356 SALOME_ListIteratorOfListIO It( selected );
3357 for ( ; It.More(); It.Next() ) {
3358 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3359 dlg->showInfo( It.Value() );
3364 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3370 case SMESHOp::OpFindElementByPoint:
3372 startOperation( theCommandID );
3376 case SMESHOp::OpEditHypothesis:
3378 if(isStudyLocked()) break;
3379 if ( warnOnGeomModif() )
3380 break; // action forbidden as geometry modified
3382 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3383 SALOME_ListIO selected;
3385 aSel->selectedObjects( selected );
3387 int nbSel = selected.Extent();
3390 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3391 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3393 if ( !aHypothesis->_is_nil() )
3395 SMESHGUI_GenericHypothesisCreator* aCreator =
3396 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3399 // set geometry of mesh and sub-mesh to aCreator
3400 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3401 if ( selected.Extent() == 1 )
3403 QString subGeomID, meshGeomID;
3404 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3405 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3407 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3408 aCreator->setShapeEntry( subGeomID );
3409 aCreator->setMainShapeEntry( meshGeomID );
3413 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3423 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3425 if(isStudyLocked()) break;
3426 if ( warnOnGeomModif() )
3427 break; // action forbidden as geometry modified
3428 SUIT_OverrideCursor wc;
3430 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3431 SALOME_ListIO selected;
3433 aSel->selectedObjects( selected, QString::null, false );
3435 SALOME_ListIteratorOfListIO It(selected);
3436 for (int i = 0; It.More(); It.Next(), i++) {
3437 Handle(SALOME_InteractiveObject) IObject = It.Value();
3438 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3441 aSel->setSelectedObjects( l1 );
3446 case SMESHOp::OpElem0D:
3447 case SMESHOp::OpBall:
3448 case SMESHOp::OpEdge:
3449 case SMESHOp::OpTriangle:
3450 case SMESHOp::OpQuadrangle:
3451 case SMESHOp::OpPolygon:
3452 case SMESHOp::OpTetrahedron:
3453 case SMESHOp::OpHexahedron:
3454 case SMESHOp::OpPentahedron:
3455 case SMESHOp::OpPyramid:
3456 case SMESHOp::OpHexagonalPrism:
3458 if(isStudyLocked()) break;
3459 if ( warnOnGeomModif() )
3460 break; // action forbidden as geometry modified
3462 EmitSignalDeactivateDialog();
3463 SMDSAbs_EntityType type = SMDSEntity_Edge;
3464 switch (theCommandID) {
3465 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3466 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3467 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3468 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3469 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3470 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3471 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3472 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3473 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3474 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3477 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3480 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3484 case SMESHOp::OpPolyhedron:
3486 if(isStudyLocked()) break;
3487 if ( warnOnGeomModif() )
3488 break; // action forbidden as geometry modified
3490 EmitSignalDeactivateDialog();
3491 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3494 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3498 case SMESHOp::OpQuadraticEdge:
3499 case SMESHOp::OpQuadraticTriangle:
3500 case SMESHOp::OpBiQuadraticTriangle:
3501 case SMESHOp::OpQuadraticQuadrangle:
3502 case SMESHOp::OpBiQuadraticQuadrangle:
3503 case SMESHOp::OpQuadraticPolygon:
3504 case SMESHOp::OpQuadraticTetrahedron:
3505 case SMESHOp::OpQuadraticPyramid:
3506 case SMESHOp::OpQuadraticPentahedron:
3507 case SMESHOp::OpBiQuadraticPentahedron:
3508 case SMESHOp::OpQuadraticHexahedron:
3509 case SMESHOp::OpTriQuadraticHexahedron:
3511 if(isStudyLocked()) break;
3512 if ( warnOnGeomModif() )
3513 break; // action forbidden as geometry modified
3515 EmitSignalDeactivateDialog();
3516 SMDSAbs_EntityType type = SMDSEntity_Last;
3518 switch (theCommandID) {
3519 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3520 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3521 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3522 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3523 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3524 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3525 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3526 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3527 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3528 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3529 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3530 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3533 if ( type != SMDSEntity_Last )
3534 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3537 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3538 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3542 case SMESHOp::OpRemoveNodes:
3544 if(isStudyLocked()) break;
3545 if ( warnOnGeomModif() )
3546 break; // action forbidden as geometry modified
3548 EmitSignalDeactivateDialog();
3549 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3552 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3553 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3557 case SMESHOp::OpRemoveNodeWithReconn:
3559 if(isStudyLocked()) break;
3560 if ( warnOnGeomModif() )
3561 break; // action forbidden as geometry modified
3562 startOperation( SMESHOp::OpRemoveNodeWithReconn );
3565 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3567 if(isStudyLocked()) break;
3568 if ( warnOnGeomModif() )
3569 break; // action forbidden as geometry modified
3571 EmitSignalDeactivateDialog();
3572 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3576 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3577 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3581 case SMESHOp::OpClearMesh: {
3583 if(isStudyLocked()) break;
3584 if ( warnOnGeomModif() )
3585 break; // action forbidden as geometry modified
3587 SALOME_ListIO selected;
3588 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3589 aSel->selectedObjects( selected );
3591 SUIT_OverrideCursor wc;
3592 SALOME_ListIteratorOfListIO It (selected);
3593 for ( ; It.More(); It.Next() )
3595 Handle(SALOME_InteractiveObject) IOS = It.Value();
3596 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3597 if ( aMesh->_is_nil()) continue;
3600 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3601 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3602 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3603 // hide groups and submeshes
3604 _PTR(ChildIterator) anIter =
3605 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3606 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3608 _PTR(SObject) so = anIter->Value();
3609 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3612 catch (const SALOME::SALOME_Exception& S_ex){
3614 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3618 SMESH::UpdateView();
3622 case SMESHOp::OpRemoveOrphanNodes:
3624 if(isStudyLocked()) break;
3625 if ( warnOnGeomModif() )
3626 break; // action forbidden as geometry modified
3627 SALOME_ListIO selected;
3628 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3629 aSel->selectedObjects( selected );
3630 if ( selected.Extent() == 1 ) {
3631 Handle(SALOME_InteractiveObject) anIO = selected.First();
3632 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3633 if ( !aMesh->_is_nil() ) {
3634 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3635 tr( "SMESH_WARNING" ),
3636 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3637 SUIT_MessageBox::Yes |
3638 SUIT_MessageBox::No,
3639 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3642 SUIT_OverrideCursor wc;
3643 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3644 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3645 SUIT_MessageBox::information(SMESHGUI::desktop(),
3646 tr("SMESH_INFORMATION"),
3647 tr("NB_NODES_REMOVED").arg(removed));
3648 if ( removed > 0 ) {
3649 SMESH::UpdateView();
3650 SMESHGUI::Modified();
3653 catch (const SALOME::SALOME_Exception& S_ex) {
3654 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3663 case SMESHOp::OpRenumberingNodes:
3665 if(isStudyLocked()) break;
3666 if ( warnOnGeomModif() )
3667 break; // action forbidden as geometry modified
3669 EmitSignalDeactivateDialog();
3670 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3674 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3675 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3679 case SMESHOp::OpRenumberingElements:
3681 if(isStudyLocked()) break;
3682 if ( warnOnGeomModif() )
3683 break; // action forbidden as geometry modified
3685 EmitSignalDeactivateDialog();
3686 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3690 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3691 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3695 case SMESHOp::OpTranslation:
3697 if(isStudyLocked()) break;
3698 if ( warnOnGeomModif() )
3699 break; // action forbidden as geometry modified
3701 EmitSignalDeactivateDialog();
3702 ( new SMESHGUI_TranslationDlg( this ) )->show();
3705 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3706 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3710 case SMESHOp::OpRotation:
3712 if(isStudyLocked()) break;
3713 if ( warnOnGeomModif() )
3714 break; // action forbidden as geometry modified
3716 EmitSignalDeactivateDialog();
3717 ( new SMESHGUI_RotationDlg( this ) )->show();
3720 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3721 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3725 case SMESHOp::OpSymmetry:
3727 if(isStudyLocked()) break;
3728 if ( warnOnGeomModif() )
3729 break; // action forbidden as geometry modified
3731 EmitSignalDeactivateDialog();
3732 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3735 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3736 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3740 case SMESHOp::OpScale:
3742 if(isStudyLocked()) break;
3743 if ( warnOnGeomModif() )
3744 break; // action forbidden as geometry modified
3746 EmitSignalDeactivateDialog();
3747 ( new SMESHGUI_ScaleDlg( this ) )->show();
3750 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3751 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3756 case SMESHOp::OpOffset:
3758 if(isStudyLocked()) break;
3759 if ( warnOnGeomModif() )
3760 break; // action forbidden as geometry modified
3762 EmitSignalDeactivateDialog();
3763 ( new SMESHGUI_OffsetDlg( this ) )->show();
3766 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3767 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3772 case SMESHOp::OpSewing:
3774 if(isStudyLocked()) break;
3775 if ( warnOnGeomModif() )
3776 break; // action forbidden as geometry modified
3778 EmitSignalDeactivateDialog();
3779 ( new SMESHGUI_SewingDlg( this ) )->show();
3782 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3783 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3787 case SMESHOp::OpMergeNodes:
3789 if(isStudyLocked()) break;
3790 if ( warnOnGeomModif() )
3791 break; // action forbidden as geometry modified
3793 EmitSignalDeactivateDialog();
3794 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3797 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3798 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3802 case SMESHOp::OpMergeElements:
3804 if (isStudyLocked()) break;
3805 if ( warnOnGeomModif() )
3806 break; // action forbidden as geometry modified
3808 EmitSignalDeactivateDialog();
3809 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3811 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3812 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3817 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3818 if ( warnOnGeomModif() )
3819 break; // action forbidden as geometry modified
3820 startOperation( SMESHOp::OpMoveNode );
3823 case SMESHOp::OpMoveNodeInteractive:
3824 if ( warnOnGeomModif() )
3825 break; // action forbidden as geometry modified
3826 startOperation( SMESHOp::OpMoveNodeInteractive );
3829 case SMESHOp::OpSplitEdgeInteract:
3830 if ( warnOnGeomModif() )
3831 break; // action forbidden as geometry modified
3832 startOperation( SMESHOp::OpSplitEdgeInteract );
3835 case SMESHOp::OpSplitFaceInteract:
3836 if ( warnOnGeomModif() )
3837 break; // action forbidden as geometry modified
3838 startOperation( SMESHOp::OpSplitFaceInteract );
3841 case SMESHOp::OpDuplicateNodes:
3843 if(isStudyLocked()) break;
3844 if ( warnOnGeomModif() )
3845 break; // action forbidden as geometry modified
3847 EmitSignalDeactivateDialog();
3848 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3851 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3852 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3857 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3858 if ( warnOnGeomModif() )
3859 break; // action forbidden as geometry modified
3860 startOperation( SMESHOp::OpElem0DOnElemNodes );
3863 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3865 static QList<int> aTypes;
3866 if ( aTypes.isEmpty() )
3868 aTypes.append( SMESH::NODE );
3869 aTypes.append( SMESH::EDGE );
3870 aTypes.append( SMESH::FACE );
3871 aTypes.append( SMESH::VOLUME );
3873 if (!myFilterLibraryDlg)
3874 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3875 else if (myFilterLibraryDlg->isHidden())
3876 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3877 myFilterLibraryDlg->raise();
3881 case SMESHOp::OpFreeNode:
3882 case SMESHOp::OpEqualNode:
3883 case SMESHOp::OpNodeConnectivityNb:
3884 case SMESHOp::OpFreeEdge:
3885 case SMESHOp::OpFreeBorder:
3886 case SMESHOp::OpLength:
3887 case SMESHOp::OpConnection:
3888 case SMESHOp::OpEqualEdge:
3889 case SMESHOp::OpFreeFace:
3890 case SMESHOp::OpBareBorderFace:
3891 case SMESHOp::OpOverConstrainedFace:
3892 case SMESHOp::OpLength2D:
3893 case SMESHOp::OpDeflection2D:
3894 case SMESHOp::OpConnection2D:
3895 case SMESHOp::OpArea:
3896 case SMESHOp::OpTaper:
3897 case SMESHOp::OpAspectRatio:
3898 case SMESHOp::OpMinimumAngle:
3899 case SMESHOp::OpWarpingAngle:
3900 case SMESHOp::OpSkew:
3901 case SMESHOp::OpMaxElementLength2D:
3902 case SMESHOp::OpEqualFace:
3903 case SMESHOp::OpAspectRatio3D:
3904 case SMESHOp::OpVolume:
3905 case SMESHOp::OpMaxElementLength3D:
3906 case SMESHOp::OpBareBorderVolume:
3907 case SMESHOp::OpOverConstrainedVolume:
3908 case SMESHOp::OpEqualVolume:
3911 LightApp_SelectionMgr* mgr = selectionMgr();
3912 SALOME_ListIO selected; mgr->selectedObjects( selected );
3914 if( !selected.IsEmpty() ) {
3915 SUIT_OverrideCursor wc;
3916 ::Control( theCommandID );
3919 SUIT_MessageBox::warning(desktop(),
3920 tr( "SMESH_WRN_WARNING" ),
3921 tr( "SMESH_BAD_SELECTION" ) );
3925 SUIT_MessageBox::warning(desktop(),
3926 tr( "SMESH_WRN_WARNING" ),
3927 tr( "NOT_A_VTK_VIEWER" ) );
3930 case SMESHOp::OpOverallMeshQuality:
3931 OverallMeshQuality();
3933 case SMESHOp::OpNumberingNodes:
3935 SUIT_OverrideCursor wc;
3936 LightApp_SelectionMgr* mgr = selectionMgr();
3937 SALOME_ListIO selected; mgr->selectedObjects( selected );
3939 SALOME_ListIteratorOfListIO it(selected);
3940 for( ; it.More(); it.Next()) {
3941 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3942 if(anIObject->hasEntry()) {
3943 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3944 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3950 case SMESHOp::OpNumberingElements:
3952 SUIT_OverrideCursor wc;
3953 LightApp_SelectionMgr* mgr = selectionMgr();
3954 SALOME_ListIO selected; mgr->selectedObjects( selected );
3956 SALOME_ListIteratorOfListIO it(selected);
3957 for( ; it.More(); it.Next()) {
3958 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3959 if(anIObject->hasEntry())
3960 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3961 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3966 case SMESHOp::OpPropertiesLength:
3967 case SMESHOp::OpPropertiesArea:
3968 case SMESHOp::OpPropertiesVolume:
3969 case SMESHOp::OpMinimumDistance:
3970 case SMESHOp::OpBoundingBox:
3971 case SMESHOp::OpAngle:
3973 int page = SMESHGUI_MeasureDlg::MinDistance;
3974 if ( theCommandID == SMESHOp::OpBoundingBox )
3975 page = SMESHGUI_MeasureDlg::BoundingBox;
3976 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3977 page = SMESHGUI_MeasureDlg::Length;
3978 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3979 page = SMESHGUI_MeasureDlg::Area;
3980 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3981 page = SMESHGUI_MeasureDlg::Volume;
3982 else if ( theCommandID == SMESHOp::OpAngle )
3983 page = SMESHGUI_MeasureDlg::Angle;
3985 EmitSignalDeactivateDialog();
3986 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3990 case SMESHOp::OpSortChild:
3993 case SMESHOp::OpBreakLink:
3994 ::breakShaperLink();
3999 anApp->updateActions(); //SRN: To update a Save button in the toolbar
4000 //updateObjBrowser();
4004 //=============================================================================
4008 //=============================================================================
4009 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4014 //=============================================================================
4018 //=============================================================================
4019 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4024 //=============================================================================
4028 //=============================================================================
4029 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4034 //=============================================================================
4035 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
4036 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
4038 //=============================================================================
4039 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
4040 SUIT_ViewWindow* wnd )
4042 if(theIO->hasEntry()){
4043 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
4044 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
4048 //=======================================================================
4049 // function : createSMESHAction
4051 //=======================================================================
4052 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
4053 const int key, const bool toggle, const QString& shortcutAction )
4056 QWidget* parent = application()->desktop();
4057 SUIT_ResourceMgr* resMgr = resourceMgr();
4059 if ( !icon_id.isEmpty() )
4060 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4062 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4063 if ( !pix.isNull() )
4064 icon = QIcon( pix );
4066 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4067 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4068 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4070 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4071 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4074 //=======================================================================
4075 // function : createPopupItem
4077 //=======================================================================
4078 void SMESHGUI::createPopupItem( const int id,
4079 const QString& clients,
4080 const QString& types,
4081 const QString& theRule,
4084 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4085 popupMgr()->insert( action( id ), pId, 0 );
4087 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4088 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4089 QString rule = "(%1) and (%2) and (%3)";
4090 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4091 if( clients.isEmpty() )
4092 rule = rule.arg( QString( "true" ) );
4094 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4095 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4098 bool cont = myRules.contains( id );
4100 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4102 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4103 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4106 //=======================================================================
4107 // function : initialize
4109 //=======================================================================
4110 void SMESHGUI::initialize( CAM_Application* app )
4112 SalomeApp_Module::initialize( app );
4114 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4116 /* Automatic Update flag */
4117 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4119 // ----- create actions --------------
4121 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4122 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4123 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4124 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4126 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4128 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4129 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4130 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4131 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4133 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4135 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4137 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4138 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4139 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4140 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4142 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4144 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4145 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4146 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4147 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4148 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4150 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4152 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4153 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4154 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4155 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4156 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4157 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4158 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4159 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4160 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4161 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4162 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4163 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4164 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4165 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4166 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4167 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4168 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4169 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4170 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4171 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4172 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4173 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4174 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4175 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4176 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4177 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4178 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4179 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4180 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4181 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4182 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4183 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4184 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4185 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4186 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4188 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4189 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4190 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4191 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4192 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4193 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4194 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4195 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4196 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4197 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4198 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4199 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4200 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4201 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4202 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4203 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4204 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4205 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4206 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4207 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4208 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4209 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4210 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4211 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4212 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4213 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4214 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4215 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4216 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4218 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4219 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4220 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4221 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4222 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4223 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4224 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4225 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4226 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4227 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4228 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4229 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4230 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4231 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4232 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4233 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4234 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4235 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4236 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4237 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4238 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4239 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4240 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4241 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4242 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4243 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4245 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4246 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4247 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4248 createSMESHAction( SMESHOp::OpRemoveNodeWithReconn, "REMOVE_NODE_RECON", "ICON_REM_NODE_RECON" );
4249 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4251 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4252 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4254 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4255 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4256 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4257 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4258 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4259 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4260 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4261 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4262 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4263 createSMESHAction( SMESHOp::OpMoveNodeInteractive, "MOVE_NODE_INTRCT","ICON_DLG_MOVE_NODE_INTERACTIVE" );
4264 createSMESHAction( SMESHOp::OpSplitEdgeInteract, "SPLIT_DIAG_INTRC","ICON_SPLIT_DIAG_INTERACTIVE" );
4265 createSMESHAction( SMESHOp::OpSplitFaceInteract, "SPLIT_FACE_INTRC","ICON_SPLIT_FACE_INTERACTIVE" );
4266 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4267 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4268 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4269 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4270 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4271 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4272 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4273 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4274 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4275 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4276 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4277 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4278 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4279 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4280 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4281 createSMESHAction( SMESHOp::OpCreateDualMesh, "CREATE_DUAL_MESH","ICON_CREATE_DUAL_MESH" );
4282 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4284 createSMESHAction( SMESHOp::OpReset, "RESET" );
4285 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4286 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4287 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4288 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4289 #ifndef DISABLE_PLOT2DVIEWER
4290 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4292 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4293 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4294 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4295 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4296 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4297 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4298 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4299 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4300 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4301 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4302 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4303 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4304 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4306 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4307 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4309 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4310 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4311 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4312 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4313 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4314 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4315 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4316 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4317 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4319 // Adaptation - begin
4320 #ifndef DISABLE_MG_ADAPT
4321 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4323 #ifndef DISABLE_HOMARD_ADAPT
4324 createSMESHAction( SMESHOp::OpHomardAdapt, "HOMARD_ADAPT", "ICON_HOMARD_ADAPT" );
4328 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4329 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4330 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4331 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4332 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4333 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4335 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4336 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4337 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4339 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4341 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4343 QList<int> aCtrlActions;
4344 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4345 << SMESHOp::OpNodeConnectivityNb // node controls
4346 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4347 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4348 << SMESHOp::OpDeflection2D
4349 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4350 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4351 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4352 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4353 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4354 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4355 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4356 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4357 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4358 aCtrlGroup->setExclusive( true );
4359 for( int i = 0; i < aCtrlActions.size(); i++ )
4360 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4362 // ----- create menu --------------
4363 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4364 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4365 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4366 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4367 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4368 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4369 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4370 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4372 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4373 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4375 createMenu( separator(), fileId );
4377 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4378 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4379 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4380 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4381 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4382 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4383 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4384 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4385 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4386 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4387 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4388 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4389 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4391 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4392 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4393 createMenu( SMESHOp::OpImportMED, importId, -1 );
4394 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4396 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4398 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4399 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4400 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4401 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4402 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4404 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4406 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4407 createMenu( separator(), fileId, 10 );
4409 createMenu( SMESHOp::OpDelete, editId, -1 );
4411 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4413 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4414 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4415 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4416 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4417 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4418 createMenu( SMESHOp::OpCreateDualMesh, meshId, -1 );
4419 createMenu( separator(), meshId, -1 );
4420 createMenu( SMESHOp::OpCompute, meshId, -1 );
4421 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4422 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4423 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4424 createMenu( separator(), meshId, -1 );
4425 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4426 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4427 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4428 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4429 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4430 createMenu( separator(), meshId, -1 );
4431 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4432 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4433 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4434 createMenu( separator(), meshId, -1 );
4435 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4436 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4437 createMenu( separator(), meshId, -1 );
4438 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4439 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4440 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4441 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4442 createMenu( separator(), meshId, -1 );
4444 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4445 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4446 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4447 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4448 createMenu( SMESHOp::OpLength, edgeId, -1 );
4449 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4450 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4451 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4452 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4453 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4454 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4455 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4456 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4457 createMenu( SMESHOp::OpArea, faceId, -1 );
4458 createMenu( SMESHOp::OpTaper, faceId, -1 );
4459 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4460 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4461 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4462 createMenu( SMESHOp::OpSkew, faceId, -1 );
4463 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4464 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4465 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4466 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4467 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4468 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4469 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4470 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4471 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4472 createMenu( separator(), ctrlId, -1 );
4473 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4474 createMenu( separator(), ctrlId, -1 );
4475 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4477 createMenu( SMESHOp::OpNode, addId, -1 );
4478 createMenu( SMESHOp::OpElem0D, addId, -1 );
4479 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4480 createMenu( SMESHOp::OpBall, addId, -1 );
4481 createMenu( SMESHOp::OpEdge, addId, -1 );
4482 createMenu( SMESHOp::OpTriangle, addId, -1 );
4483 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4484 createMenu( SMESHOp::OpPolygon, addId, -1 );
4485 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4486 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4487 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4488 createMenu( SMESHOp::OpPyramid, addId, -1 );
4489 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4490 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4491 createMenu( separator(), addId, -1 );
4492 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4493 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4494 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4495 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4496 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4497 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4498 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4499 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4500 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4501 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4502 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4503 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4504 createMenu( separator(), addId, -1 );
4505 createMenu( SMESHOp::OpSplitEdgeInteract, addId, -1 );
4506 createMenu( SMESHOp::OpSplitFaceInteract, addId, -1 );
4508 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4509 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4510 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4511 createMenu( SMESHOp::OpRemoveNodeWithReconn, removeId, -1 );
4512 createMenu( separator(), removeId, -1 );
4513 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4514 createMenu( separator(), removeId, -1 );
4515 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4517 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4518 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4520 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4521 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4522 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4523 createMenu( SMESHOp::OpRotation, transfId, -1 );
4524 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4525 createMenu( SMESHOp::OpScale, transfId, -1 );
4526 createMenu( SMESHOp::OpOffset, transfId, -1 );
4527 createMenu( SMESHOp::OpSewing, transfId, -1 );
4528 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4530 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4531 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4532 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4533 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4534 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4535 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4536 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4537 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4538 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4539 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4540 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4541 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4542 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4543 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4544 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4545 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4547 // Adaptation - begin
4548 #ifndef DISABLE_MG_ADAPT
4549 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4551 #ifndef DISABLE_HOMARD_ADAPT
4552 createMenu( SMESHOp::OpHomardAdapt, adaptId, -1 );
4556 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4557 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4558 createMenu( SMESHOp::OpAngle, measureId, -1 );
4559 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4560 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4561 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4562 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4564 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4565 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4566 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4567 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4569 // ----- create toolbars --------------
4570 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4571 createTool( SMESHOp::OpCreateMesh, meshTb );
4572 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4573 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4574 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4575 createTool( SMESHOp::OpCopyMesh, meshTb );
4576 createTool( separator(), meshTb );
4577 createTool( SMESHOp::OpCompute, meshTb );
4578 createTool( SMESHOp::OpPreCompute, meshTb );
4579 createTool( SMESHOp::OpEvaluate, meshTb );
4580 createTool( SMESHOp::OpMeshOrder, meshTb );
4582 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4583 createTool( SMESHOp::OpMeshInformation, infoTb );
4584 //createTool( SMESHOp::OpStdInfo, meshTb );
4585 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4586 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4588 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4589 createTool( SMESHOp::OpCreateGroup, groupTb );
4590 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4591 createTool( SMESHOp::OpConstructGroup, groupTb );
4592 createTool( SMESHOp::OpEditGroup, groupTb );
4594 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4595 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4596 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4597 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4599 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4600 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4601 createTool( SMESHOp::OpLength, ctrl1dTb );
4602 createTool( SMESHOp::OpConnection, ctrl1dTb );
4603 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4605 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4606 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4607 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4608 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4609 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4610 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4611 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4612 createTool( SMESHOp::OpArea, ctrl2dTb );
4613 createTool( SMESHOp::OpTaper, ctrl2dTb );
4614 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4615 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4616 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4617 createTool( SMESHOp::OpSkew, ctrl2dTb );
4618 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4619 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4620 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4622 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4623 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4624 createTool( SMESHOp::OpVolume, ctrl3dTb );
4625 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4626 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4627 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4628 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4630 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4631 createTool( SMESHOp::OpNode, addElemTb );
4632 createTool( SMESHOp::OpElem0D, addElemTb );
4633 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4634 createTool( SMESHOp::OpBall, addElemTb );
4635 createTool( SMESHOp::OpEdge, addElemTb );
4636 createTool( SMESHOp::OpTriangle, addElemTb );
4637 createTool( SMESHOp::OpQuadrangle, addElemTb );
4638 createTool( SMESHOp::OpPolygon, addElemTb );
4639 createTool( SMESHOp::OpTetrahedron, addElemTb );
4640 createTool( SMESHOp::OpHexahedron, addElemTb );
4641 createTool( SMESHOp::OpPentahedron, addElemTb );
4642 createTool( SMESHOp::OpPyramid, addElemTb );
4643 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4644 createTool( SMESHOp::OpPolyhedron, addElemTb );
4646 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4647 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4648 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4649 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4650 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4651 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4652 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4653 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4654 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4655 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4656 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4657 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4658 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4660 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4661 createTool( SMESHOp::OpRemoveNodes, remTb );
4662 createTool( SMESHOp::OpRemoveElements, remTb );
4663 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4664 createTool( SMESHOp::OpClearMesh, remTb );
4666 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4667 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4668 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4670 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4671 createTool( SMESHOp::OpMergeNodes, transformTb );
4672 createTool( SMESHOp::OpMergeElements, transformTb );
4673 createTool( SMESHOp::OpTranslation, transformTb );
4674 createTool( SMESHOp::OpRotation, transformTb );
4675 createTool( SMESHOp::OpSymmetry, transformTb );
4676 createTool( SMESHOp::OpScale, transformTb );
4677 createTool( SMESHOp::OpOffset, transformTb );
4678 createTool( SMESHOp::OpSewing, transformTb );
4679 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4681 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4682 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4683 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4684 createTool( SMESHOp::OpExtrusion, modifyTb );
4685 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4686 createTool( SMESHOp::OpRevolution, modifyTb );
4687 createTool( SMESHOp::OpOrientation, modifyTb );
4688 createTool( SMESHOp::OpReorientFaces, modifyTb );
4689 createTool( SMESHOp::OpMoveNode, modifyTb );
4690 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4691 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4692 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4693 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4694 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4695 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4696 createTool( SMESHOp::OpSmoothing, modifyTb );
4697 createTool( SMESHOp::OpPatternMapping, modifyTb );
4699 int interactTb = createTool( tr( "TB_INTERACT" ), QString( "SMESHInteractiveToolbar" ) ) ;
4700 createTool( SMESHOp::OpMoveNodeInteractive, interactTb );
4701 createTool( SMESHOp::OpRemoveNodeWithReconn, interactTb );
4702 createTool( SMESHOp::OpSplitEdgeInteract, interactTb );
4703 createTool( SMESHOp::OpSplitFaceInteract, interactTb );
4705 // Adaptation - begin
4706 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4707 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4709 #ifndef DISABLE_MG_ADAPT
4710 createTool( SMESHOp::OpMGAdapt, adaptTb );
4712 #ifndef DISABLE_HOMARD_ADAPT
4713 createTool( SMESHOp::OpHomardAdapt, adaptTb );
4717 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4718 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4720 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4721 createTool( SMESHOp::OpUpdate, dispModeTb );
4723 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4724 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4728 OB = "'ObjectBrowser'",
4729 View = "'" + SVTK_Viewer::Type() + "'",
4731 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4732 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4733 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4734 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4735 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4736 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4737 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4738 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4739 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4740 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4741 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4742 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4744 mesh_part = mesh + " " + subMesh + " " + group,
4745 mesh_group = mesh + " " + group,
4746 mesh_submesh = mesh + " " + subMesh,
4747 hyp_alg = hypo + " " + algo;
4749 // popup for object browser
4751 isInvisible("not( isVisible )"),
4752 isEmpty("numberOfNodes = 0"),
4753 isNotEmpty("numberOfNodes <> 0"),
4755 // has nodes, edges, etc in VISIBLE! actor
4756 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4757 hasElems("(count( elemTypes ) > 0)"),
4758 hasDifferentElems("(count( elemTypes ) > 1)"),
4759 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4760 hasBalls("({'BallElem'} in elemTypes)"),
4761 hasElems0d("({'Elem0d'} in elemTypes)"),
4762 hasEdges("({'Edge'} in elemTypes)"),
4763 hasFaces("({'Face'} in elemTypes)"),
4764 hasVolumes("({'Volume'} in elemTypes)"),
4765 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4767 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4768 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4769 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4770 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4771 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4772 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4774 popupMgr()->insert( separator(), -1, 0 );
4775 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4776 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4777 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4778 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4779 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4780 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4781 popupMgr()->insert( separator(), -1, 0 );
4782 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4783 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4784 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4785 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4786 popupMgr()->insert( separator(), -1, 0 );
4787 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4788 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4789 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4790 popupMgr()->insert( separator(), -1, 0 );
4791 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4792 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4793 popupMgr()->insert( separator(), -1, 0 );
4794 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4795 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4797 // Adaptation - begin
4798 popupMgr()->insert( separator(), -1, 0 );
4799 #ifndef DISABLE_MG_ADAPT
4800 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4802 #ifndef DISABLE_HOMARD_ADAPT
4803 createPopupItem( SMESHOp::OpHomardAdapt, OB, mesh );
4805 popupMgr()->insert( separator(), -1, 0 );
4808 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4809 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4810 QString only_one_2D = only_one_non_empty + " && dim>1";
4812 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4813 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4814 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4815 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4816 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4818 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4820 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4821 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4823 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4824 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4825 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4826 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4828 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4830 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4831 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4832 popupMgr()->insert( separator(), -1, 0 );
4834 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4835 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4836 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4839 createPopupItem( SMESHOp::OpEditGroup, View, group );
4840 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4841 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4843 popupMgr()->insert( separator(), -1, 0 );
4844 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4845 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4846 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4847 popupMgr()->insert( separator(), -1, 0 );
4849 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
4850 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4851 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4852 popupMgr()->insert( separator(), -1, 0 );
4854 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4855 QString aType = QString( "%1type in {%2}" ).arg( lc );
4856 aType = aType.arg( mesh_part );
4857 QString aMeshInVTK = aClient + "&&" + aType;
4859 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4860 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4861 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4863 //-------------------------------------------------
4865 //-------------------------------------------------
4866 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4868 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4869 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4870 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4872 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4873 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4874 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4876 popupMgr()->insert( separator(), -1, -1 );
4878 //-------------------------------------------------
4880 //-------------------------------------------------
4881 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4883 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4884 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4885 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4887 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4888 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4889 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4891 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4892 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4893 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4895 popupMgr()->insert( separator(), anId, -1 );
4897 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4898 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4899 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4901 //-------------------------------------------------
4903 //-------------------------------------------------
4904 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4906 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4908 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4909 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4910 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4912 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4913 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4914 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4916 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4917 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4918 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4920 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4921 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4922 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4924 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4925 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4926 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4928 popupMgr()->insert( separator(), anId, -1 );
4930 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4931 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4933 popupMgr()->insert( separator(), anId, -1 );
4935 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4936 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4939 //-------------------------------------------------
4940 // Representation of the 2D Quadratic elements
4941 //-------------------------------------------------
4942 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4943 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4944 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4945 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4947 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4948 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4949 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4951 //-------------------------------------------------
4952 // Orientation of faces
4953 //-------------------------------------------------
4954 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4955 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4956 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4958 //-------------------------------------------------
4960 //-------------------------------------------------
4961 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4962 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4964 //-------------------------------------------------
4966 //-------------------------------------------------
4967 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4968 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4970 //-------------------------------------------------
4972 //-------------------------------------------------
4974 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4975 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4976 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4977 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4979 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4981 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4982 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4984 popupMgr()->insert( separator(), anId, -1 );
4986 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4988 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4989 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4990 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4992 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4993 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4994 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4996 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4997 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4998 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
5000 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
5002 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
5003 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
5004 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
5006 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
5007 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5008 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
5010 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
5011 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5012 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
5013 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
5014 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5015 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
5017 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
5019 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
5020 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5021 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
5023 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
5024 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
5025 QtxPopupMgr::VisibleRule );
5026 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
5028 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
5029 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5030 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
5032 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
5033 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5034 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
5036 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
5037 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5038 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
5040 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
5041 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5042 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
5044 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
5045 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5046 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
5048 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
5049 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5050 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
5052 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
5053 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5054 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
5056 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
5057 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5058 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
5060 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
5061 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5062 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
5064 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
5065 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5066 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
5068 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
5069 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5070 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
5072 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
5073 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5074 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
5076 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
5077 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
5078 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
5080 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
5082 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
5083 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5084 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
5086 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
5087 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5088 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
5090 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
5091 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5092 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5094 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5095 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5096 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5098 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5099 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5100 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5102 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5103 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5104 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5106 popupMgr()->insert( separator(), anId, -1 );
5108 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5109 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5110 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5111 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5112 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5114 popupMgr()->insert( separator(), anId, -1 );
5116 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5118 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5119 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5121 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5122 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5123 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5125 #ifndef DISABLE_PLOT2DVIEWER
5126 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5127 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5130 //-------------------------------------------------
5132 //-------------------------------------------------
5133 popupMgr()->insert( separator(), -1, -1 );
5134 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5135 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5136 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5137 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5139 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5140 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5142 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5143 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5145 popupMgr()->insert( separator(), -1, -1 );
5147 //-------------------------------------------------
5149 //-------------------------------------------------
5150 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5151 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5153 popupMgr()->insert( separator(), -1, -1 );
5155 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5156 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5157 popupMgr()->insert( separator(), -1, -1 );
5159 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5160 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5162 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5163 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5165 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5166 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5169 //================================================================================
5171 * \brief Return true if SMESH or GEOM objects are selected.
5172 * Is called form LightApp_Module::activateModule() which clear selection if
5173 * not isSelectionCompatible()
5175 //================================================================================
5177 bool SMESHGUI::isSelectionCompatible()
5179 bool isCompatible = true;
5180 SALOME_ListIO selected;
5181 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5182 Sel->selectedObjects( selected );
5184 SALOME_ListIteratorOfListIO It( selected );
5185 for ( ; isCompatible && It.More(); It.Next())
5187 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5188 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5189 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5191 return isCompatible;
5195 bool SMESHGUI::reusableOperation( const int id )
5197 // compute, evaluate and precompute are not reusable operations
5198 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5203 QString wrap(const QString& text, const QString& tag)
5204 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5207 bool SMESHGUI::activateModule( SUIT_Study* study )
5209 bool res = SalomeApp_Module::activateModule( study );
5211 setMenuShown( true );
5212 setToolShown( true );
5214 // Fill in Help Panel
5215 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5216 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5218 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5221 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5222 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5223 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5224 lab = lab + tr("INFO_REFINE") + ":";
5225 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5226 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5227 lab = lab + wrap(items.join(""), "ul");
5230 app->infoPanel()->addLabel(lab, gb);
5232 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5233 items << wrap("UNV", "li")
5234 << wrap("MED", "li")
5235 << wrap("STL", "li")
5236 << wrap("CGNS", "li")
5237 << wrap("GMF", "li");
5238 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5241 app->infoPanel()->addLabel(lab, gb);
5243 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5244 lab = tr("INFO_DISPLAY") + "<br/>";
5245 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5246 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5247 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5248 << wrap("...", "li");
5249 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5251 lab = lab + tr("INFO_CLIPPING");
5253 app->infoPanel()->addLabel(lab, gb);
5256 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5257 PyGILState_STATE gstate = PyGILState_Ensure();
5258 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5259 if ( !pluginsmanager ) {
5263 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5268 PyGILState_Release(gstate);
5269 // end of SMESH plugins loading
5271 // Reset actions accelerator keys
5272 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5274 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5275 GetSMESHGen()->UpdateStudy();
5277 // get all view currently opened in the study and connect their signals to
5278 // the corresponding slots of the class.
5279 SUIT_Desktop* aDesk = study->application()->desktop();
5281 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5282 SUIT_ViewWindow* wnd;
5283 foreach ( wnd, wndList )
5287 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5288 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5294 Py_XDECREF(pluginsmanager);
5298 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5300 setMenuShown( false );
5301 setToolShown( false );
5303 EmitSignalCloseAllDialogs();
5305 // Unset actions accelerator keys
5306 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5308 return SalomeApp_Module::deactivateModule( study );
5311 void SMESHGUI::studyClosed( SUIT_Study* s )
5315 SMESH::RemoveVisuData();
5316 SalomeApp_Module::studyClosed( s );
5319 void SMESHGUI::OnGUIEvent()
5321 const QObject* obj = sender();
5322 if ( !obj || !obj->inherits( "QAction" ) )
5324 int id = actionId((QAction*)obj);
5329 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5331 if ( CORBA::is_nil( myComponentSMESH ) )
5333 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5334 return aGUI.myComponentSMESH;
5336 return myComponentSMESH;
5339 QString SMESHGUI::engineIOR() const
5341 CORBA::ORB_var anORB = getApp()->orb();
5342 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5343 return QString( anIOR.in() );
5346 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5348 SalomeApp_Module::contextMenuPopup( client, menu, title );
5350 selectionMgr()->selectedObjects( lst );
5351 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5352 Handle(SALOME_InteractiveObject) io = lst.First();
5353 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5354 _PTR(Study) study = appStudy->studyDS();
5355 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5357 QString aName = SMESH::fromUtf8( obj->GetName());
5358 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5359 aName.remove(( aName.length() - 1 ), 1 );
5365 LightApp_Selection* SMESHGUI::createSelection() const
5367 return new SMESHGUI_Selection();
5370 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5372 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5373 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5374 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5375 #ifndef DISABLE_PYCONSOLE
5376 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5380 void SMESHGUI::viewManagers( QStringList& list ) const
5382 list.append( SVTK_Viewer::Type() );
5385 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5387 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5388 SMESH::UpdateSelectionProp( this );
5390 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5391 for(int i = 0; i < aViews.count() ; i++){
5392 SUIT_ViewWindow *sf = aViews[i];
5395 EmitSignalActivatedViewManager();
5399 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5401 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5402 myClippingPlaneInfoMap.erase( theViewManager );
5405 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5407 theActor->AddObserver( SMESH::DeleteActorEvent,
5408 myEventCallbackCommand.GetPointer(),
5412 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5413 unsigned long theEvent,
5414 void* theClientData,
5415 void* /*theCallData*/ )
5417 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5418 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5419 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5420 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5421 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5422 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5423 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5424 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5425 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5426 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5427 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5428 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5429 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5430 if( anActor == *anIter3 ) {
5431 anActorList.erase( anIter3 );
5442 void SMESHGUI::createPreferences()
5444 // General tab ------------------------------------------------------------------------
5445 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5447 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5448 setPreferenceProperty( autoUpdate, "columns", 2 );
5449 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5450 setPreferenceProperty( lim, "min", 0 );
5451 setPreferenceProperty( lim, "max", 100000000 );
5452 setPreferenceProperty( lim, "step", 1000 );
5453 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5454 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5456 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5457 setPreferenceProperty( dispgroup, "columns", 2 );
5459 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5461 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5463 modes.append( tr("MEN_WIRE") );
5464 modes.append( tr("MEN_SHADE") );
5465 modes.append( tr("MEN_NODES") );
5466 modes.append( tr("MEN_SHRINK") );
5467 QList<QVariant> indices;
5468 indices.append( 0 );
5469 indices.append( 1 );
5470 indices.append( 2 );
5471 indices.append( 3 );
5472 setPreferenceProperty( dispmode, "strings", modes );
5473 setPreferenceProperty( dispmode, "indexes", indices );
5475 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5476 setPreferenceProperty( arcgroup, "columns", 2 );
5477 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5478 QStringList quadraticModes;
5479 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5480 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5482 indices.append( 0 );
5483 indices.append( 1 );
5484 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5485 setPreferenceProperty( quadraticmode, "indexes", indices );
5487 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5488 "SMESH", "max_angle" );
5489 setPreferenceProperty( maxAngle, "min", 1 );
5490 setPreferenceProperty( maxAngle, "max", 90 );
5492 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5493 setPreferenceProperty( qaGroup, "columns", 2 );
5494 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5495 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5496 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5497 setPreferenceProperty( prec, "min", 0 );
5498 setPreferenceProperty( prec, "max", 100 );
5499 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5500 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5501 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5502 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5503 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5506 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5507 setPreferenceProperty( cinc, "min", 0 );
5508 setPreferenceProperty( cinc, "max", 5 );
5511 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5512 setPreferenceProperty( exportgroup, "columns", 2 );
5513 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5514 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5515 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5516 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5517 setPreferenceProperty( zTol, "precision", 10 );
5518 setPreferenceProperty( zTol, "min", 0.0000000001 );
5519 setPreferenceProperty( zTol, "max", 1000000.0 );
5520 setPreferenceProperty( zTol, "step", 1. );
5521 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5523 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5524 setPreferenceProperty( computeGroup, "columns", 2 );
5525 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5527 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5528 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5529 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5531 indices.append( 0 );
5532 indices.append( 1 );
5533 indices.append( 2 );
5534 setPreferenceProperty( notifyMode, "strings", modes );
5535 setPreferenceProperty( notifyMode, "indexes", indices );
5537 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5538 setPreferenceProperty( infoGroup, "columns", 2 );
5539 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5541 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5542 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5544 indices.append( 0 );
5545 indices.append( 1 );
5546 setPreferenceProperty( elemInfo, "strings", modes );
5547 setPreferenceProperty( elemInfo, "indexes", indices );
5548 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5549 setPreferenceProperty( nodesLim, "min", 0 );
5550 setPreferenceProperty( nodesLim, "max", 10000000 );
5551 setPreferenceProperty( nodesLim, "step", 10000 );
5552 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5553 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5554 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5555 setPreferenceProperty( ctrlLim, "min", 0 );
5556 setPreferenceProperty( ctrlLim, "max", 10000000 );
5557 setPreferenceProperty( ctrlLim, "step", 1000 );
5558 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5559 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5560 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5561 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5562 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5564 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5565 setPreferenceProperty( segGroup, "columns", 2 );
5566 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5567 "SMESH", "segmentation" );
5568 setPreferenceProperty( segLen, "min", 1 );
5569 setPreferenceProperty( segLen, "max", 10000000 );
5570 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5571 "SMESH", "nb_segments_per_edge" );
5572 setPreferenceProperty( nbSeg, "min", 1 );
5573 setPreferenceProperty( nbSeg, "max", 10000000 );
5574 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5576 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5577 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5578 "SMESH", "forget_mesh_on_hyp_modif" );
5581 // Quantities with individual precision settings
5582 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5583 setPreferenceProperty( precGroup, "columns", 2 );
5585 const int nbQuantities = 6;
5586 int precs[nbQuantities], ii = 0;
5587 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5588 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5589 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5590 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5591 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5592 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5593 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5594 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5595 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5596 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5597 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5598 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5600 // Set property for precision value for spinboxes
5601 for ( ii = 0; ii < nbQuantities; ii++ ){
5602 setPreferenceProperty( precs[ii], "min", -14 );
5603 setPreferenceProperty( precs[ii], "max", 14 );
5604 setPreferenceProperty( precs[ii], "precision", 2 );
5607 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5608 setPreferenceProperty( previewGroup, "columns", 2 );
5609 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5610 setPreferenceProperty( chunkSize, "min", 1 );
5611 setPreferenceProperty( chunkSize, "max", 1000 );
5612 setPreferenceProperty( chunkSize, "step", 50 );
5614 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5615 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5617 // Mesh tab ------------------------------------------------------------------------
5618 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5619 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5620 setPreferenceProperty( nodeGroup, "columns", 3 );
5622 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5624 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5626 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5627 QList<QVariant> aMarkerTypeIndicesList;
5628 QList<QVariant> aMarkerTypeIconsList;
5629 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5630 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5631 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5632 aMarkerTypeIndicesList << i;
5633 aMarkerTypeIconsList << pixmap;
5635 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5636 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5638 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5640 QList<QVariant> aMarkerScaleIndicesList;
5641 QStringList aMarkerScaleValuesList;
5642 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5643 aMarkerScaleIndicesList << i;
5644 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5645 aMarkerScaleValuesList << QString::number( i );
5647 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5648 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5650 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5651 //setPreferenceProperty( elemGroup, "columns", 2 );
5653 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5654 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5655 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5656 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5657 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5658 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5659 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5660 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5661 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5664 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5665 setPreferenceProperty( grpGroup, "columns", 2 );
5667 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5668 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5670 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5671 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5672 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5673 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5674 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5675 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5676 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5677 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5678 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5679 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5680 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5681 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5682 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5683 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5685 setPreferenceProperty( size0d, "min", 1 );
5686 setPreferenceProperty( size0d, "max", 10 );
5688 // setPreferenceProperty( ballSize, "min", 1 );
5689 // setPreferenceProperty( ballSize, "max", 10 );
5691 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5692 setPreferenceProperty( ballDiameter, "max", 1e9 );
5693 setPreferenceProperty( ballDiameter, "step", 0.1 );
5695 setPreferenceProperty( ballScale, "min", 1e-2 );
5696 setPreferenceProperty( ballScale, "max", 1e7 );
5697 setPreferenceProperty( ballScale, "step", 0.5 );
5699 setPreferenceProperty( elemW, "min", 1 );
5700 setPreferenceProperty( elemW, "max", 5 );
5702 setPreferenceProperty( outW, "min", 1 );
5703 setPreferenceProperty( outW, "max", 5 );
5705 setPreferenceProperty( shrink, "min", 0 );
5706 setPreferenceProperty( shrink, "max", 100 );
5708 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5709 setPreferenceProperty( numGroup, "columns", 2 );
5711 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5712 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5714 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5715 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5717 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5718 setPreferenceProperty( orientGroup, "columns", 1 );
5720 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5721 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5723 setPreferenceProperty( orientScale, "min", 0.05 );
5724 setPreferenceProperty( orientScale, "max", 0.5 );
5725 setPreferenceProperty( orientScale, "step", 0.05 );
5727 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5729 // Selection tab ------------------------------------------------------------------------
5730 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5732 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5733 setPreferenceProperty( selGroup, "columns", 2 );
5735 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5736 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5738 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5739 setPreferenceProperty( preGroup, "columns", 2 );
5741 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5743 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5744 setPreferenceProperty( precSelGroup, "columns", 2 );
5746 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5747 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5748 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5750 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5751 setPreferenceProperty( sinc, "min", 0 );
5752 setPreferenceProperty( sinc, "max", 5 );
5754 // Scalar Bar tab ------------------------------------------------------------------------
5755 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5756 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5757 setPreferenceProperty( fontGr, "columns", 2 );
5759 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5760 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5762 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5763 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5765 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5766 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5768 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5769 setPreferenceProperty( numcol, "min", 2 );
5770 setPreferenceProperty( numcol, "max", 256 );
5772 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5773 setPreferenceProperty( numlab, "min", 2 );
5774 setPreferenceProperty( numlab, "max", 65 );
5776 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5777 setPreferenceProperty( orientGr, "columns", 2 );
5778 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5779 QStringList orients;
5780 orients.append( tr( "SMESH_VERTICAL" ) );
5781 orients.append( tr( "SMESH_HORIZONTAL" ) );
5782 indices.clear(); indices.append( 0 ); indices.append( 1 );
5783 setPreferenceProperty( orient, "strings", orients );
5784 setPreferenceProperty( orient, "indexes", indices );
5786 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5787 setPreferenceProperty( posVSizeGr, "columns", 2 );
5788 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5789 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5790 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5791 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5792 setPreferenceProperty( xv, "step", 0.1 );
5793 setPreferenceProperty( xv, "min", 0.0 );
5794 setPreferenceProperty( xv, "max", 1.0 );
5795 setPreferenceProperty( yv, "step", 0.1 );
5796 setPreferenceProperty( yv, "min", 0.0 );
5797 setPreferenceProperty( yv, "max", 1.0 );
5798 setPreferenceProperty( wv, "step", 0.1 );
5799 setPreferenceProperty( wv, "min", 0.0 );
5800 setPreferenceProperty( wv, "max", 1.0 );
5801 setPreferenceProperty( hv, "min", 0.0 );
5802 setPreferenceProperty( hv, "max", 1.0 );
5803 setPreferenceProperty( hv, "step", 0.1 );
5805 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5806 setPreferenceProperty( posHSizeGr, "columns", 2 );
5807 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5808 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5809 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5810 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5811 setPreferenceProperty( xv, "min", 0.0 );
5812 setPreferenceProperty( xv, "max", 1.0 );
5813 setPreferenceProperty( xv, "step", 0.1 );
5814 setPreferenceProperty( xh, "min", 0.0 );
5815 setPreferenceProperty( xh, "max", 1.0 );
5816 setPreferenceProperty( xh, "step", 0.1 );
5817 setPreferenceProperty( yh, "min", 0.0 );
5818 setPreferenceProperty( yh, "max", 1.0 );
5819 setPreferenceProperty( yh, "step", 0.1 );
5820 setPreferenceProperty( wh, "min", 0.0 );
5821 setPreferenceProperty( wh, "max", 1.0 );
5822 setPreferenceProperty( wh, "step", 0.1 );
5823 setPreferenceProperty( hh, "min", 0.0 );
5824 setPreferenceProperty( hh, "max", 1.0 );
5825 setPreferenceProperty( hh, "step", 0.1 );
5827 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5828 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5829 setPreferenceProperty( distributionGr, "columns", 3 );
5831 types.append( tr( "SMESH_MONOCOLOR" ) );
5832 types.append( tr( "SMESH_MULTICOLOR" ) );
5833 indices.clear(); indices.append( 0 ); indices.append( 1 );
5834 setPreferenceProperty( coloringType, "strings", types );
5835 setPreferenceProperty( coloringType, "indexes", indices );
5836 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5838 // Adaptation - begin
5839 #ifndef DISABLE_MG_ADAPT
5840 // Adaptation tab ------------------------------------------------------------------------
5841 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
5844 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
5845 setPreferenceProperty( bloc, "columns", 1 );
5846 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
5847 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
5848 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
5849 QStringList aListOfSizeMap;
5850 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
5851 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
5852 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
5853 setPreferenceProperty( pref, "strings", aListOfSizeMap );
5854 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
5855 QStringList aListOfTimeStep;
5856 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
5857 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
5858 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
5859 setPreferenceProperty( pref, "strings", aListOfTimeStep );
5864 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5866 if ( sect=="SMESH" ) {
5867 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5868 double aTol = 1.00000009999999;
5869 std::string aWarning;
5870 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5872 if ( name == "selection_object_color" ||
5873 name == "selection_element_color" ||
5874 name == "highlight_color" ||
5875 name == "selection_precision_node" ||
5876 name == "selection_precision_element" ||
5877 name == "selection_precision_object" ||
5878 name == "selection_increment")
5880 SMESH::UpdateSelectionProp( this );
5882 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5884 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5885 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5886 if ( sbX1+sbW > aTol ) {
5887 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5890 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5891 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5894 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5896 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5897 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5898 if ( sbY1 + sbH > aTol ) {
5899 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5900 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5901 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5904 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5906 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5907 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5908 if ( sbX1 + sbW > aTol ) {
5909 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5912 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5913 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5916 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5918 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5919 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5920 if ( sbY1 + sbH > aTol ) {
5921 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5924 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5925 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5928 else if ( name == "segmentation" )
5930 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5931 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5933 else if ( name == "nb_segments_per_edge" )
5935 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5936 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5938 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5940 QString val = aResourceMgr->stringValue( "SMESH", name );
5941 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5943 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5945 SMESH::UpdateFontProp( this );
5947 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5949 SMESH::UpdateFontProp( this );
5952 if ( aWarning.size() != 0 ) {
5953 aWarning += "The default values are applied instead.";
5954 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5955 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5956 QObject::tr(aWarning.c_str()));
5961 //================================================================================
5963 * \brief Update something in accordance with update flags
5964 * \param theFlags - update flags
5966 * Update viewer or/and object browser etc. in accordance with update flags ( see
5967 * LightApp_UpdateFlags enumeration ).
5969 //================================================================================
5970 void SMESHGUI::update( const int flags )
5972 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5973 SMESH::UpdateView();
5975 SalomeApp_Module::update( flags );
5978 //================================================================================
5980 * \brief Set default selection mode
5982 * SLOT called when operation committed. Sets default selection mode
5984 //================================================================================
5985 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5987 SVTK_ViewWindow* vtkWnd =
5988 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5990 vtkWnd->SetSelectionMode( ActorSelection );
5993 //================================================================================
5995 * \brief Set default selection mode
5997 * SLOT called when operation aborted. Sets default selection mode
5999 //================================================================================
6000 void SMESHGUI::onOperationAborted( SUIT_Operation* )
6002 SVTK_ViewWindow* vtkWnd =
6003 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6005 vtkWnd->SetSelectionMode( ActorSelection );
6008 //================================================================================
6010 * \brief Creates operation with given identifier
6011 * \param id - identifier of operation to be started
6012 * \return Pointer on created operation or NULL if operation is not created
6014 * Virtual method redefined from the base class creates operation with given id.
6015 * It is called called automatically from startOperation method of base class.
6017 //================================================================================
6018 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
6020 LightApp_Operation* op = 0;
6021 // to do : create operation here
6024 case SMESHOp::OpSplitBiQuadratic:
6025 op = new SMESHGUI_SplitBiQuadOp();
6027 case SMESHOp::OpConvertMeshToQuadratic:
6028 op = new SMESHGUI_ConvToQuadOp();
6030 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
6031 op = new SMESHGUI_Make2DFrom3DOp();
6033 case SMESHOp::OpCreateDualMesh:
6034 op = new SMESHGUI_CreateDualMeshOp();
6036 case SMESHOp::OpReorientFaces:
6037 op = new SMESHGUI_ReorientFacesOp();
6039 case SMESHOp::OpCreateMesh:
6040 op = new SMESHGUI_MeshOp( true, true );
6042 case SMESHOp::OpCreateSubMesh:
6043 op = new SMESHGUI_MeshOp( true, false );
6045 case SMESHOp::OpEditMeshOrSubMesh:
6046 case SMESHOp::OpEditMesh:
6047 case SMESHOp::OpEditSubMesh:
6048 op = new SMESHGUI_MeshOp( false );
6050 case SMESHOp::OpCompute:
6051 case SMESHOp::OpComputeSubMesh:
6052 op = new SMESHGUI_ComputeOp();
6054 case SMESHOp::OpShowErrors:
6055 op = new SMESHGUI_ShowErrorsOp();
6057 case SMESHOp::OpPreCompute:
6058 op = new SMESHGUI_PrecomputeOp();
6060 case SMESHOp::OpEvaluate:
6061 op = new SMESHGUI_EvaluateOp();
6063 case SMESHOp::OpMeshOrder:
6064 op = new SMESHGUI_MeshOrderOp();
6066 case SMESHOp::OpCreateGeometryGroup:
6067 op = new SMESHGUI_GroupOnShapeOp();
6069 case SMESHOp::OpFindElementByPoint:
6070 op = new SMESHGUI_FindElemByPointOp();
6072 case SMESHOp::OpMoveNode: // Make mesh pass through point
6073 op = new SMESHGUI_MakeNodeAtPointOp();
6075 case SMESHOp::OpMoveNodeInteractive: // Make mesh pass through point / by mouse
6076 op = new SMESHGUI_MakeNodeAtPointOp( 2 );
6078 case SMESHOp::OpRemoveNodeWithReconn:
6079 op = new SMESHGUI_RemoveNodeReconnectionOp();
6081 case SMESHOp::OpSplitEdgeInteract:
6082 op = new SMESHGUI_AddNodeOnSegmentOp();
6084 case SMESHOp::OpSplitFaceInteract:
6085 op = new SMESHGUI_AddNodeOnFaceOp();
6087 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
6088 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
6095 op = SalomeApp_Module::createOperation( id );
6099 //================================================================================
6101 * \brief Stops current operations and starts a given one
6102 * \param id - The id of the operation to start
6104 //================================================================================
6106 void SMESHGUI::switchToOperation(int id)
6108 activeStudy()->abortAllOperations();
6109 startOperation( id );
6112 LightApp_Displayer* SMESHGUI::displayer()
6115 myDisplayer = new SMESHGUI_Displayer( getApp() );
6119 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6122 int aTolerance = 64;
6123 int anIterations = 0;
6129 if( anIterations % aPeriod == 0 )
6132 if( aTolerance < 1 )
6136 aHue = (int)( 360.0 * rand() / RAND_MAX );
6139 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6140 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6141 for( ; it != itEnd; ++it )
6143 SALOMEDS::Color anAutoColor = *it;
6144 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6147 aQColor.getHsv( &h, &s, &v );
6148 if( abs( h - aHue ) < aTolerance )
6160 aColor.setHsv( aHue, 255, 255 );
6162 SALOMEDS::Color aSColor;
6163 aSColor.R = aColor.redF();
6164 aSColor.G = aColor.greenF();
6165 aSColor.B = aColor.blueF();
6170 const char* gSeparator = "_"; // character used to separate parameter names
6171 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6172 const char* gPathSep = "|"; // character used to separate paths
6175 * \brief Store visual parameters
6177 * This method is called just before the study document is saved.
6178 * Store visual parameters in AttributeParameter attribute(s)
6180 void SMESHGUI::storeVisualParameters (int savePoint)
6183 Kernel_Utils::Localizer loc;
6185 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6186 if (!appStudy || !appStudy->studyDS())
6188 _PTR(Study) studyDS = appStudy->studyDS();
6190 // componentName is used for encoding of entries when storing them in IParameters
6191 std::string componentName = myComponentSMESH->ComponentDataType();
6192 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6193 //if (!aSComponent) return;
6196 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6197 componentName.c_str(),
6199 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6201 // store custom markers
6202 if( !myMarkerMap.empty() )
6204 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6205 for( ; anIter != myMarkerMap.end(); anIter++ )
6207 int anId = anIter->first;
6208 VTK::MarkerData aMarkerData = anIter->second;
6209 std::string aMarkerFileName = aMarkerData.first;
6210 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6211 if( aMarkerTexture.size() < 3 )
6212 continue; // should contain at least width, height and the first value
6214 QString aPropertyName( "texture" );
6215 aPropertyName += gSeparator;
6216 aPropertyName += QString::number( anId );
6218 QString aPropertyValue = aMarkerFileName.c_str();
6219 aPropertyValue += gPathSep;
6221 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6222 ushort aWidth = *aTextureIter++;
6223 ushort aHeight = *aTextureIter++;
6224 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6225 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6226 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6227 aPropertyValue += QString::number( *aTextureIter );
6229 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6233 // viewers counters are used for storing view_numbers in IParameters
6236 // main cycle to store parameters of displayed objects
6237 QList<SUIT_ViewManager*> lst;
6238 QList<SUIT_ViewManager*>::Iterator it;
6239 getApp()->viewManagers(lst);
6240 for (it = lst.begin(); it != lst.end(); it++)
6242 SUIT_ViewManager* vman = *it;
6243 QString vType = vman->getType();
6245 // saving VTK actors properties
6246 if (vType == SVTK_Viewer::Type())
6248 // store the clipping planes attached to the view manager
6249 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6250 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6251 if( anIter != myClippingPlaneInfoMap.end() )
6252 aClippingPlaneInfoList = anIter->second;
6254 if( !aClippingPlaneInfoList.empty() ) {
6255 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6256 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6258 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6259 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6261 QString aPropertyName( "ClippingPlane" );
6262 aPropertyName += gSeparator;
6263 aPropertyName += QString::number( vtkViewers );
6264 aPropertyName += gSeparator;
6265 aPropertyName += QString::number( anId );
6267 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6268 aPropertyValue += gDigitsSep;
6269 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6270 aPropertyValue += gDigitsSep;
6271 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6272 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6273 aPropertyValue += gDigitsSep;
6274 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6275 aPropertyValue += gDigitsSep;
6276 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6277 aPropertyValue += gDigitsSep;
6278 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6279 aPropertyValue += gDigitsSep;
6280 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6281 aPropertyValue += gDigitsSep;
6282 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6283 aPropertyValue += gDigitsSep;
6284 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6286 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6287 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6288 aPropertyValue += gDigitsSep;
6289 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6290 aPropertyValue += gDigitsSep;
6291 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6292 aPropertyValue += gDigitsSep;
6293 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6296 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6300 QVector<SUIT_ViewWindow*> views = vman->getViews();
6301 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6303 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6305 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6306 vtkActorCollection* allActors = aCopy.GetActors();
6307 allActors->InitTraversal();
6308 while (vtkActor* actor = allActors->GetNextActor())
6310 if (actor->GetVisibility()) // store only visible actors
6312 SMESH_Actor* aSmeshActor = 0;
6313 if (actor->IsA("SMESH_Actor"))
6314 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6315 if (aSmeshActor && aSmeshActor->hasIO())
6317 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6320 // entry is "encoded" = it does NOT contain component address,
6321 // since it is a subject to change on next component loading
6322 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6324 std::string param, vtkParam = vType.toLatin1().data();
6325 vtkParam += gSeparator;
6326 vtkParam += QString::number(vtkViewers).toLatin1().data();
6327 vtkParam += gSeparator;
6330 param = vtkParam + "Visibility";
6331 ip->setParameter(entry, param, "On");
6334 param = vtkParam + "Representation";
6335 ip->setParameter(entry, param, QString::number
6336 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6339 param = vtkParam + "IsShrunk";
6340 ip->setParameter(entry, param, QString::number
6341 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6343 // Displayed entities
6344 unsigned int aMode = aSmeshActor->GetEntityMode();
6345 bool isE = aMode & SMESH_Actor::eEdges;
6346 bool isF = aMode & SMESH_Actor::eFaces;
6347 bool isV = aMode & SMESH_Actor::eVolumes;
6348 bool is0d = aMode & SMESH_Actor::e0DElements;
6349 bool isB = aMode & SMESH_Actor::eBallElem;
6351 QString modeStr ("e");
6352 modeStr += gDigitsSep; modeStr += QString::number(isE);
6353 modeStr += gDigitsSep; modeStr += "f";
6354 modeStr += gDigitsSep; modeStr += QString::number(isF);
6355 modeStr += gDigitsSep; modeStr += "v";
6356 modeStr += gDigitsSep; modeStr += QString::number(isV);
6357 modeStr += gDigitsSep; modeStr += "0d";
6358 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6359 modeStr += gDigitsSep; modeStr += "b";
6360 modeStr += gDigitsSep; modeStr += QString::number(isB);
6362 param = vtkParam + "Entities";
6363 ip->setParameter(entry, param, modeStr.toLatin1().data());
6369 aSmeshActor->GetSufaceColor(r, g, b, delta);
6370 QStringList colorStr;
6371 colorStr << "surface";
6372 colorStr << QString::number(r);
6373 colorStr << QString::number(g);
6374 colorStr << QString::number(b);
6376 colorStr << "backsurface";
6377 colorStr << QString::number(delta);
6379 aSmeshActor->GetVolumeColor(r, g, b, delta);
6380 colorStr << "volume";
6381 colorStr << QString::number(r);
6382 colorStr << QString::number(g);
6383 colorStr << QString::number(b);
6384 colorStr << QString::number(delta);
6386 aSmeshActor->GetEdgeColor(r, g, b);
6388 colorStr << QString::number(r);
6389 colorStr << QString::number(g);
6390 colorStr << QString::number(b);
6392 aSmeshActor->GetNodeColor(r, g, b);
6394 colorStr << QString::number(r);
6395 colorStr << QString::number(g);
6396 colorStr << QString::number(b);
6398 aSmeshActor->GetOutlineColor(r, g, b);
6399 colorStr << "outline";
6400 colorStr << QString::number(r);
6401 colorStr << QString::number(g);
6402 colorStr << QString::number(b);
6404 aSmeshActor->Get0DColor(r, g, b);
6405 colorStr << "elem0d";
6406 colorStr << QString::number(r);
6407 colorStr << QString::number(g);
6408 colorStr << QString::number(b);
6410 aSmeshActor->GetBallColor(r, g, b);
6412 colorStr << QString::number(r);
6413 colorStr << QString::number(g);
6414 colorStr << QString::number(b);
6416 aSmeshActor->GetFacesOrientationColor(r, g, b);
6417 colorStr << "orientation";
6418 colorStr << QString::number(r);
6419 colorStr << QString::number(g);
6420 colorStr << QString::number(b);
6422 param = vtkParam + "Colors";
6423 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6426 QStringList sizeStr;
6428 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6429 sizeStr << "outline";
6430 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6431 sizeStr << "elem0d";
6432 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6434 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6435 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6436 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6437 sizeStr << "shrink";
6438 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6439 sizeStr << "orientation";
6440 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6441 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6443 param = vtkParam + "Sizes";
6444 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6449 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6450 if( aMarkerType == VTK::MT_USER ) {
6451 markerStr += "custom";
6452 markerStr += gDigitsSep;
6453 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6457 markerStr += gDigitsSep;
6458 markerStr += QString::number( (int)aMarkerType );
6459 markerStr += gDigitsSep;
6460 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6463 param = vtkParam + "PointMarker";
6464 ip->setParameter(entry, param, markerStr.toLatin1().data());
6467 param = vtkParam + "Opacity";
6468 ip->setParameter(entry, param,
6469 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6472 param = vtkParam + "ClippingPlane";
6474 if( !aClippingPlaneInfoList.empty() ) {
6475 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6476 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6478 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6479 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6480 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6481 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6482 if( aSmeshActor == *anIter2 ) {
6483 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6484 QString::number( anId ).toLatin1().constData() );
6491 ip->setParameter( entry, param, "Off" );
6492 } // if (io->hasEntry())
6493 } // SMESH_Actor && hasIO
6495 } // while.. actors traversal
6499 } // if (SVTK view model)
6500 } // for (viewManagers)
6503 // data structures for clipping planes processing
6507 bool isOpenGLClipping;
6508 vtkIdType RelativeOrientation;
6511 int AbsoluteOrientation;
6512 double X, Y, Z, Dx, Dy, Dz;
6514 typedef std::list<TPlaneData> TPlaneDataList;
6515 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6517 typedef std::list<vtkActor*> TActorList;
6520 TActorList ActorList;
6521 SUIT_ViewManager* ViewManager;
6523 typedef std::list<TPlaneInfo> TPlaneInfoList;
6524 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6527 * \brief Restore visual parameters
6529 * This method is called after the study document is opened.
6530 * Restore visual parameters from AttributeParameter attribute(s)
6532 void SMESHGUI::restoreVisualParameters (int savePoint)
6535 Kernel_Utils::Localizer loc;
6537 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6538 if (!appStudy || !appStudy->studyDS())
6540 _PTR(Study) studyDS = appStudy->studyDS();
6542 // componentName is used for encoding of entries when storing them in IParameters
6543 std::string componentName = myComponentSMESH->ComponentDataType();
6546 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6547 componentName.c_str(),
6549 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6551 // restore custom markers and map of clipping planes
6552 TPlaneDataMap aPlaneDataMap;
6554 std::vector<std::string> properties = ip->getProperties();
6555 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6557 std::string property = *propIt;
6558 QString aPropertyName( property.c_str() );
6559 QString aPropertyValue( ip->getProperty( property ).c_str() );
6561 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6562 if( aPropertyNameList.isEmpty() )
6565 QString aPropertyType = aPropertyNameList[0];
6566 if( aPropertyType == "texture" )
6568 if( aPropertyNameList.size() != 2 )
6572 int anId = aPropertyNameList[1].toInt( &ok );
6573 if( !ok || anId < 1 )
6576 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6577 if( aPropertyValueList.size() != 2 )
6580 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6581 QString aMarkerTextureString = aPropertyValueList[1];
6582 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6583 if( aMarkerTextureStringList.size() != 3 )
6587 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6592 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6596 VTK::MarkerTexture aMarkerTexture;
6597 aMarkerTexture.push_back( aWidth );
6598 aMarkerTexture.push_back( aHeight );
6600 QString aMarkerTextureData = aMarkerTextureStringList[2];
6601 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6603 QChar aChar = aMarkerTextureData.at( i );
6604 if( aChar.isDigit() )
6605 aMarkerTexture.push_back( aChar.digitValue() );
6608 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6610 else if( aPropertyType == "ClippingPlane" )
6612 if( aPropertyNameList.size() != 3 )
6616 int aViewId = aPropertyNameList[1].toInt( &ok );
6617 if( !ok || aViewId < 0 )
6621 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6622 if( !ok || aClippingPlaneId < 0 )
6625 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6626 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6629 TPlaneData aPlaneData;
6630 aPlaneData.AbsoluteOrientation = false;
6631 aPlaneData.RelativeOrientation = 0;
6632 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6633 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6634 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6636 aPlaneData.Id = aClippingPlaneId;
6639 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6644 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6648 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6651 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6656 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6661 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6666 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6671 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6676 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6681 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6685 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6687 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6692 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6697 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6702 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6707 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6708 aPlaneDataList.push_back( aPlaneData );
6712 TPlaneInfoMap aPlaneInfoMap;
6714 std::vector<std::string> entries = ip->getEntries();
6716 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6718 // entry is a normal entry - it should be "decoded" (setting base address of component)
6719 QString entry (ip->decodeEntry(*entIt).c_str());
6721 // Check that the entry corresponds to a real object in the Study
6722 // as the object may be deleted or modified after the visual state is saved.
6723 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6724 if (!so) continue; //Skip the not existent entry
6726 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6727 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6729 std::vector<std::string>::iterator namesIt = paramNames.begin();
6730 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6732 // actors are stored in a map after displaying of them for
6733 // quicker access in the future: map < viewID to actor >
6734 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6736 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6738 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6739 // '_' is used as separator and should not be used in viewer type or parameter names.
6740 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6741 if (lst.size() != 3)
6744 QString viewerTypStr = lst[0];
6745 QString viewIndexStr = lst[1];
6746 QString paramNameStr = lst[2];
6749 int viewIndex = viewIndexStr.toUInt(&ok);
6750 if (!ok) // bad conversion of view index to integer
6754 if (viewerTypStr == SVTK_Viewer::Type())
6756 SMESH_Actor* aSmeshActor = 0;
6757 if (vtkActors.IsBound(viewIndex))
6758 aSmeshActor = vtkActors.Find(viewIndex);
6760 QList<SUIT_ViewManager*> lst;
6761 getApp()->viewManagers(viewerTypStr, lst);
6763 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6764 SUIT_ViewManager* vman = NULL;
6765 if (viewIndex >= 0 && viewIndex < lst.count())
6766 vman = lst.at(viewIndex);
6768 if (paramNameStr == "Visibility")
6770 if (!aSmeshActor && displayer() && vman)
6772 SUIT_ViewModel* vmodel = vman->getViewModel();
6773 // SVTK view model can be casted to SALOME_View
6774 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6776 // store displayed actor in a temporary map for quicker
6777 // access later when restoring other parameters
6778 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6779 vtkRenderer* Renderer = vtkView->getRenderer();
6780 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6781 vtkActorCollection* theActors = aCopy.GetActors();
6782 theActors->InitTraversal();
6783 bool isFound = false;
6784 vtkActor *ac = theActors->GetNextActor();
6785 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6786 if (ac->IsA("SMESH_Actor")) {
6787 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6788 if (aGeomAc->hasIO()) {
6789 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6790 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6792 vtkActors.Bind(viewIndex, aGeomAc);
6798 } // if (paramNameStr == "Visibility")
6801 // the rest properties "work" with SMESH_Actor
6804 QString val ((*valuesIt).c_str());
6807 if (paramNameStr == "Representation") {
6808 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6811 else if (paramNameStr == "IsShrunk") {
6813 if (!aSmeshActor->IsShrunk())
6814 aSmeshActor->SetShrink();
6817 if (aSmeshActor->IsShrunk())
6818 aSmeshActor->UnShrink();
6821 // Displayed entities
6822 else if (paramNameStr == "Entities") {
6823 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6824 int aEntityMode = SMESH_Actor::eAllEntity;
6825 for ( int i = 0; i < mode.count(); i+=2 ) {
6826 if ( i < mode.count()-1 ) {
6827 QString type = mode[i];
6828 bool val = mode[i+1].toInt();
6829 if ( type == "e" && !val )
6830 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6831 else if ( type == "f" && !val )
6832 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6833 else if ( type == "v" && !val )
6834 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6835 else if ( type == "0d" && !val )
6836 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6837 else if ( type == "b" && !val )
6838 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6841 aSmeshActor->SetEntityMode( aEntityMode );
6844 else if (paramNameStr == "Colors") {
6845 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6852 QColor outlineColor;
6853 QColor orientationColor;
6859 // below lines are required to get default values for delta coefficients
6860 // of backface color for faces and color of reversed volumes
6861 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6862 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6863 for ( int i = 0; i < colors.count(); i++ ) {
6864 QString type = colors[i];
6865 if ( type == "surface" ) {
6866 // face color is set by 3 values r:g:b, where
6867 // - r,g,b - is rgb color components
6868 if ( i+1 >= colors.count() ) break; // format error
6869 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6870 if ( i+2 >= colors.count() ) break; // format error
6871 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6872 if ( i+3 >= colors.count() ) break; // format error
6873 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6874 faceColor.setRgbF( r, g, b );
6877 else if ( type == "backsurface" ) {
6878 // backface color can be defined in several ways
6879 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6880 // - in latest versions, it is set as delta coefficient
6881 bool rgbOk = false, deltaOk;
6882 if ( i+1 >= colors.count() ) break; // format error
6883 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6884 int delta = colors[i+1].toInt( &deltaOk );
6886 if ( i+1 < colors.count() ) // index is shifted to 1
6887 g = colors[i+1].toDouble( &rgbOk );
6888 if ( rgbOk ) i++; // shift index
6889 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6890 b = colors[i+1].toDouble( &rgbOk );
6892 // - as currently there's no way to set directly backsurface color as it was before,
6893 // we ignore old dump where r,g,b triple was set
6894 // - also we check that delta parameter is set properly
6895 if ( !rgbOk && deltaOk )
6898 else if ( type == "volume" ) {
6899 // volume color is set by 4 values r:g:b:delta, where
6900 // - r,g,b - is a normal volume rgb color components
6901 // - delta - is a reversed volume color delta coefficient
6902 if ( i+1 >= colors.count() ) break; // format error
6903 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6904 if ( i+2 >= colors.count() ) break; // format error
6905 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6906 if ( i+3 >= colors.count() ) break; // format error
6907 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6908 if ( i+4 >= colors.count() ) break; // format error
6909 int delta = colors[i+4].toInt( &bOk );
6910 if ( !bOk ) break; // format error
6911 volumeColor.setRgbF( r, g, b );
6915 else if ( type == "edge" ) {
6916 // edge color is set by 3 values r:g:b, where
6917 // - r,g,b - is rgb color components
6918 if ( i+1 >= colors.count() ) break; // format error
6919 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6920 if ( i+2 >= colors.count() ) break; // format error
6921 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6922 if ( i+3 >= colors.count() ) break; // format error
6923 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6924 edgeColor.setRgbF( r, g, b );
6927 else if ( type == "node" ) {
6928 // node color is set by 3 values r:g:b, where
6929 // - r,g,b - is rgb color components
6930 if ( i+1 >= colors.count() ) break; // format error
6931 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6932 if ( i+2 >= colors.count() ) break; // format error
6933 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6934 if ( i+3 >= colors.count() ) break; // format error
6935 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6936 nodeColor.setRgbF( r, g, b );
6939 else if ( type == "elem0d" ) {
6940 // 0d element color is set by 3 values r:g:b, where
6941 // - r,g,b - is rgb color components
6942 if ( i+1 >= colors.count() ) break; // format error
6943 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6944 if ( i+2 >= colors.count() ) break; // format error
6945 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6946 if ( i+3 >= colors.count() ) break; // format error
6947 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6948 elem0dColor.setRgbF( r, g, b );
6951 else if ( type == "ball" ) {
6952 // ball color is set by 3 values r:g:b, where
6953 // - r,g,b - is rgb color components
6954 if ( i+1 >= colors.count() ) break; // format error
6955 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6956 if ( i+2 >= colors.count() ) break; // format error
6957 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6958 if ( i+3 >= colors.count() ) break; // format error
6959 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6960 ballColor.setRgbF( r, g, b );
6963 else if ( type == "outline" ) {
6964 // outline color is set by 3 values r:g:b, where
6965 // - r,g,b - is rgb color components
6966 if ( i+1 >= colors.count() ) break; // format error
6967 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6968 if ( i+2 >= colors.count() ) break; // format error
6969 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6970 if ( i+3 >= colors.count() ) break; // format error
6971 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6972 outlineColor.setRgbF( r, g, b );
6975 else if ( type == "orientation" ) {
6976 // orientation color is set by 3 values r:g:b, where
6977 // - r,g,b - is rgb color components
6978 if ( i+1 >= colors.count() ) break; // format error
6979 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6980 if ( i+2 >= colors.count() ) break; // format error
6981 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6982 if ( i+3 >= colors.count() ) break; // format error
6983 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6984 orientationColor.setRgbF( r, g, b );
6989 if ( nodeColor.isValid() )
6990 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6992 if ( edgeColor.isValid() )
6993 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6995 if ( faceColor.isValid() )
6996 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6998 if ( volumeColor.isValid() )
6999 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
7000 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
7001 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7003 if ( elem0dColor.isValid() )
7004 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
7006 if ( ballColor.isValid() )
7007 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
7009 if ( outlineColor.isValid() )
7010 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
7011 // orientation color
7012 if ( orientationColor.isValid() )
7013 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
7016 else if (paramNameStr == "Sizes") {
7017 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
7020 int outlineWidth = -1;
7021 int elem0dSize = -1;
7022 //int ballSize = -1;
7023 double ballDiameter = -1.0;
7024 double ballScale = -1.0;
7025 double shrinkSize = -1;
7026 double orientationSize = -1;
7027 bool orientation3d = false;
7028 for ( int i = 0; i < sizes.count(); i++ ) {
7029 QString type = sizes[i];
7030 if ( type == "line" ) {
7031 // line (wireframe) width is given as single integer value
7032 if ( i+1 >= sizes.count() ) break; // format error
7033 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7037 if ( type == "outline" ) {
7038 // outline width is given as single integer value
7039 if ( i+1 >= sizes.count() ) break; // format error
7040 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7044 else if ( type == "elem0d" ) {
7045 // 0d element size is given as single integer value
7046 if ( i+1 >= sizes.count() ) break; // format error
7047 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7051 else if ( type == "ball" ) {
7052 // balls are specified by two values: size:scale, where
7053 // - size - is a integer value specifying size
7054 // - scale - is a double value specifying scale factor
7055 if ( i+1 >= sizes.count() ) break; // format error
7056 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7057 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7058 if ( i+2 >= sizes.count() ) break; // format error
7059 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7065 else if ( type == "shrink" ) {
7066 // shrink factor is given as single floating point value
7067 if ( i+1 >= sizes.count() ) break; // format error
7068 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7072 else if ( type == "orientation" ) {
7073 // orientation vectors are specified by two values size:3d, where
7074 // - size - is a floating point value specifying scale factor
7075 // - 3d - is a boolean
7076 if ( i+1 >= sizes.count() ) break; // format error
7077 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7078 if ( i+2 >= sizes.count() ) break; // format error
7079 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
7080 orientationSize = v1;
7081 orientation3d = (bool)v2;
7085 // line (wireframe) width
7086 if ( lineWidth > 0 )
7087 aSmeshActor->SetLineWidth( lineWidth );
7089 if ( outlineWidth > 0 )
7090 aSmeshActor->SetOutlineWidth( outlineWidth );
7091 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
7092 aSmeshActor->SetOutlineWidth( lineWidth );
7094 if ( elem0dSize > 0 )
7095 aSmeshActor->Set0DSize( elem0dSize );
7097 /*if ( ballSize > 0 )
7098 aSmeshActor->SetBallSize( ballSize );*/
7100 if ( ballDiameter > 0 )
7101 aSmeshActor->SetBallSize( ballDiameter );
7103 if ( ballScale > 0.0 )
7104 aSmeshActor->SetBallScale( ballScale );
7106 if ( shrinkSize > 0 )
7107 aSmeshActor->SetShrinkFactor( shrinkSize );
7108 // orientation vectors
7109 if ( orientationSize > 0 ) {
7110 aSmeshActor->SetFacesOrientationScale( orientationSize );
7111 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7115 else if (paramNameStr == "PointMarker") {
7116 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7117 if( data.count() >= 2 ) {
7119 int aParam1 = data[1].toInt( &ok );
7121 if( data[0] == "std" && data.count() == 3 ) {
7122 int aParam2 = data[2].toInt( &ok );
7123 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7125 else if( data[0] == "custom" ) {
7126 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7127 if( markerIt != myMarkerMap.end() ) {
7128 VTK::MarkerData aMarkerData = markerIt->second;
7129 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7136 else if (paramNameStr == "Opacity") {
7137 aSmeshActor->SetOpacity(val.toFloat());
7140 else if (paramNameStr.startsWith("ClippingPlane")) {
7141 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7142 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7143 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7144 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7145 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7146 // new format - val looks like "Off" or "0" (plane id)
7147 // (note: in new format "Off" value is used only for consistency,
7148 // so it is processed together with values in old format)
7149 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7150 if( anIsOldFormat ) {
7151 if (paramNameStr == "ClippingPlane1" || val == "Off")
7152 aSmeshActor->RemoveAllClippingPlanes();
7154 QList<SUIT_ViewManager*> lst;
7155 getApp()->viewManagers(viewerTypStr, lst);
7156 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7157 if (viewIndex >= 0 && viewIndex < lst.count()) {
7158 SUIT_ViewManager* vman = lst.at(viewIndex);
7159 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7161 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7163 SMESH::TActorList anActorList;
7164 anActorList.push_back( aSmeshActor );
7165 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7166 aPlane->myViewWindow = vtkView;
7167 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7168 aPlane->PlaneMode = aMode;
7169 bool isOpenGLClipping = ( bool )vals[1].toInt();
7170 aPlane->IsOpenGLClipping = isOpenGLClipping;
7171 if ( aMode == SMESH::Absolute ) {
7172 aPlane->myAbsoluteOrientation = vals[2].toInt();
7173 aPlane->X = vals[3].toFloat();
7174 aPlane->Y = vals[4].toFloat();
7175 aPlane->Z = vals[5].toFloat();
7176 aPlane->Dx = vals[6].toFloat();
7177 aPlane->Dy = vals[7].toFloat();
7178 aPlane->Dz = vals[8].toFloat();
7180 else if ( aMode == SMESH::Relative ) {
7181 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7182 aPlane->myDistance = vals[3].toFloat();
7183 aPlane->myAngle[0] = vals[4].toFloat();
7184 aPlane->myAngle[1] = vals[5].toFloat();
7188 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7189 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7190 aClippingPlaneInfo.Plane = aPlane;
7191 aClippingPlaneInfo.ActorList = anActorList;
7192 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7200 int aPlaneId = val.toInt( &ok );
7201 if( ok && aPlaneId >= 0 ) {
7202 bool anIsDefinedPlane = false;
7203 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7204 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7205 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7206 TPlaneInfo& aPlaneInfo = *anIter;
7207 if( aPlaneInfo.PlaneId == aPlaneId ) {
7208 aPlaneInfo.ActorList.push_back( aSmeshActor );
7209 anIsDefinedPlane = true;
7213 if( !anIsDefinedPlane ) {
7214 TPlaneInfo aPlaneInfo;
7215 aPlaneInfo.PlaneId = aPlaneId;
7216 aPlaneInfo.ActorList.push_back( aSmeshActor );
7217 aPlaneInfo.ViewManager = vman;
7219 // to make the list sorted by plane id
7220 anIter = aPlaneInfoList.begin();
7221 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7222 const TPlaneInfo& aPlaneInfoRef = *anIter;
7223 if( aPlaneInfoRef.PlaneId > aPlaneId )
7226 aPlaneInfoList.insert( anIter, aPlaneInfo );
7231 } // if (aSmeshActor)
7232 } // other parameters than Visibility
7234 } // for names/parameters iterator
7235 } // for entries iterator
7237 // take into account planes with empty list of actors referred to them
7238 QList<SUIT_ViewManager*> aVMList;
7239 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7241 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7242 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7243 int aViewId = aPlaneDataIter->first;
7244 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7245 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7247 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7249 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7250 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7251 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7252 const TPlaneData& aPlaneData = *anIter2;
7253 int aPlaneId = aPlaneData.Id;
7255 bool anIsFound = false;
7256 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7257 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7258 const TPlaneInfo& aPlaneInfo = *anIter3;
7259 if( aPlaneInfo.PlaneId == aPlaneId ) {
7266 TPlaneInfo aPlaneInfo; // ActorList field is empty
7267 aPlaneInfo.PlaneId = aPlaneId;
7268 aPlaneInfo.ViewManager = aViewManager;
7270 // to make the list sorted by plane id
7271 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7272 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7273 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7274 if( aPlaneInfoRef.PlaneId > aPlaneId )
7277 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7283 // add clipping planes to actors according to the restored parameters
7284 // and update the clipping plane map
7285 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7286 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7287 int aViewId = anIter1->first;
7288 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7290 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7291 if( anIter2 == aPlaneDataMap.end() )
7293 const TPlaneDataList& aPlaneDataList = anIter2->second;
7295 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7296 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7297 const TPlaneInfo& aPlaneInfo = *anIter3;
7298 int aPlaneId = aPlaneInfo.PlaneId;
7299 const TActorList& anActorList = aPlaneInfo.ActorList;
7300 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7304 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7308 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7310 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7311 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7312 const TPlaneData& aPlaneData = *anIter4;
7313 if( aPlaneData.Id == aPlaneId ) {
7314 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7315 aPlane->myViewWindow = aViewWindow;
7316 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7317 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7318 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7319 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7320 aPlane->X = aPlaneData.X;
7321 aPlane->Y = aPlaneData.Y;
7322 aPlane->Z = aPlaneData.Z;
7323 aPlane->Dx = aPlaneData.Dx;
7324 aPlane->Dy = aPlaneData.Dy;
7325 aPlane->Dz = aPlaneData.Dz;
7327 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7328 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7329 aPlane->myDistance = aPlaneData.Distance;
7330 aPlane->myAngle[0] = aPlaneData.Angle[0];
7331 aPlane->myAngle[1] = aPlaneData.Angle[1];
7334 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7335 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7336 aClippingPlaneInfo.Plane = aPlane;
7337 aClippingPlaneInfo.ActorList = anActorList;
7338 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7349 // update all VTK views
7350 QList<SUIT_ViewManager*> lst;
7351 getApp()->viewManagers(lst);
7352 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7353 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7354 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7355 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7356 // set OpenGL clipping planes
7357 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7358 vtkActorCollection* anAllActors = aCopy.GetActors();
7359 anAllActors->InitTraversal();
7360 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7361 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7362 anActor->SetOpenGLClippingPlane();
7364 vtkView->getRenderer()->ResetCameraClippingRange();
7371 \brief Adds preferences for dfont of VTK viewer
7373 \param pIf group identifier
7374 \param param parameter
7375 \return identifier of preferences
7377 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7379 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7381 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7384 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7385 fam.append( tr( "SMESH_FONT_COURIER" ) );
7386 fam.append( tr( "SMESH_FONT_TIMES" ) );
7388 setPreferenceProperty( tfont, "fonts", fam );
7390 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7391 if ( needSize ) f = f | QtxFontEdit::Size;
7392 setPreferenceProperty( tfont, "features", f );
7398 \brief Actions after hypothesis edition
7399 Updates object browser after hypothesis edition
7401 void SMESHGUI::onHypothesisEdit( int result )
7404 SMESHGUI::Modified();
7405 updateObjBrowser( true );
7409 \brief Actions after choosing menu of control modes
7410 Updates control mode actions according to current selection
7412 void SMESHGUI::onUpdateControlActions()
7414 SALOME_ListIO selected;
7415 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7416 aSel->selectedObjects( selected );
7418 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7419 if ( selected.Extent() ) {
7420 if ( selected.First()->hasEntry() ) {
7421 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7422 aControl = anActor->GetControlMode();
7423 SALOME_ListIteratorOfListIO it(selected);
7424 for ( it.Next(); it.More(); it.Next() ) {
7425 Handle(SALOME_InteractiveObject) anIO = it.Value();
7426 if ( anIO->hasEntry() ) {
7427 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7428 if ( aControl != anActor->GetControlMode() ) {
7429 aControl = SMESH_Actor::eNone;
7439 int anAction = ActionToControl( aControl, true );
7441 action( anAction )->setChecked( true );
7443 QMenu* send = (QMenu*)sender();
7444 QList<QAction*> actions = send->actions();
7445 for ( int i = 0; i < actions.size(); i++ )
7446 actions[i]->setChecked( false );
7452 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7453 \param pview view being closed
7455 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7456 #ifndef DISABLE_PLOT2DVIEWER
7457 //Crear all Plot2d Viewers if need.
7458 SMESH::ClearPlot2Viewers(pview);
7460 EmitSignalCloseView();
7463 void SMESHGUI::message( const QString& msg )
7466 QStringList data = msg.split("/");
7467 if ( data.count() > 0 ) {
7468 if ( data.first() == "mesh_loading" ) {
7470 QString entry = data.count() > 1 ? data[1] : QString();
7471 if ( entry.isEmpty() )
7474 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7476 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7479 name = SMESH::fromUtf8(obj->GetName());
7480 if ( name.isEmpty() )
7483 if ( data.last() == "stop" )
7484 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7486 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7487 QApplication::processEvents();
7493 \brief Connects or disconnects signals about activating and cloning view on the module slots
7494 \param pview view which is connected/disconnected
7496 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7500 SUIT_ViewManager* viewMgr = pview->getViewManager();
7502 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7503 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7505 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7506 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7511 \brief Return \c true if object can be renamed
7513 bool SMESHGUI::renameAllowed( const QString& entry) const {
7514 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7518 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7522 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7527 if(appStudy->isComponent(entry) || obj->isReference())
7530 // check type to prevent renaming of inappropriate objects
7531 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7532 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7533 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7534 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7535 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7536 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7543 Rename object by entry.
7544 \param entry entry of the object
7545 \param name new name of the object
7546 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7548 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7550 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7554 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7559 _PTR(Study) aStudy = appStudy->studyDS();
7564 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7566 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7571 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7572 _PTR(GenericAttribute) anAttr;
7573 _PTR(AttributeName) aName;
7575 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7577 // check type to prevent renaming of inappropriate objects
7578 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7579 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7580 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7581 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7582 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7583 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7584 if ( !name.isEmpty() ) {
7585 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7587 // update name of group object and its actor
7588 Handle(SALOME_InteractiveObject) IObject =
7589 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7591 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7592 if( !aGroupObject->_is_nil() ) {
7593 aGroupObject->SetName( qUtf8Printable(name) );
7594 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7595 anActor->setName( qUtf8Printable(name) );
7605 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7607 static QList<QColor> colors;
7609 if ( colors.isEmpty() ) {
7611 for (int s = 0; s < 2 ; s++)
7613 for (int v = 100; v >= 40; v = v - 20)
7615 for (int h = 0; h < 359 ; h = h + 60)
7617 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7622 static int currentColor = randomize( colors.size() );
7624 SALOMEDS::Color color;
7625 color.R = (double)colors[currentColor].red() / 255.0;
7626 color.G = (double)colors[currentColor].green() / 255.0;
7627 color.B = (double)colors[currentColor].blue() / 255.0;
7629 currentColor = (currentColor+1) % colors.count();