1 // Copyright (C) 2007-2024 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_MakeFull2DFrom3DOp.h"
69 #include "SMESHGUI_MakeNodeAtPointDlg.h"
70 #include "SMESHGUI_Measurements.h"
71 #include "SMESHGUI_MergeDlg.h"
72 #include "SMESHGUI_MeshInfo.h"
73 #include "SMESHGUI_MeshOp.h"
74 #include "SMESHGUI_MeshOrderOp.h"
75 #include "SMESHGUI_MeshPatternDlg.h"
76 #include "SMESHGUI_MeshUtils.h"
77 #include "SMESHGUI_MultiEditDlg.h"
78 #include "SMESHGUI_NodesDlg.h"
79 #include "SMESHGUI_OffsetDlg.h"
80 #include "SMESHGUI_Operations.h"
81 #include "SMESHGUI_PatternUtils.h"
82 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
83 #include "SMESHGUI_PropertiesDlg.h"
84 #include "SMESHGUI_RemoveElementsDlg.h"
85 #include "SMESHGUI_RemoveNodeReconnectionDlg.h"
86 #include "SMESHGUI_RemoveNodesDlg.h"
87 #include "SMESHGUI_RenumberingDlg.h"
88 #include "SMESHGUI_ReorientFacesDlg.h"
89 #include "SMESHGUI_RevolutionDlg.h"
90 #include "SMESHGUI_RotationDlg.h"
91 #include "SMESHGUI_ScaleDlg.h"
92 #include "SMESHGUI_Selection.h"
93 #include "SMESHGUI_SewingDlg.h"
94 #include "SMESHGUI_SingleEditDlg.h"
95 #include "SMESHGUI_SmoothingDlg.h"
96 #include "SMESHGUI_SpinBox.h"
97 #include "SMESHGUI_SplitBiQuad.h"
98 #include "SMESHGUI_SymmetryDlg.h"
99 #include "SMESHGUI_TranslationDlg.h"
100 #include "SMESHGUI_TransparencyDlg.h"
101 #include "SMESHGUI_CreateDualMeshDlg.h"
102 #include "SMESHGUI_CreateDualMeshOp.h"
103 #include "SMESHGUI_Utils.h"
104 #include "SMESHGUI_VTKUtils.h"
106 #include "SMESH_version.h"
108 #include "SMESH_Actor.h"
109 #include "SMESH_ActorUtils.h"
110 #include "SMESH_Client.hxx"
111 #include "SMESH_Comment.hxx"
112 #include "SMESH_ControlsDef.hxx"
113 #include "SMESH_ScalarBarActor.h"
114 #include "SMESH_TypeFilter.hxx"
116 // SALOME GUI includes
117 #include <LightApp_DataOwner.h>
118 #include <LightApp_NameDlg.h>
119 #include <LightApp_Preferences.h>
120 #include <LightApp_SelectionMgr.h>
121 #include <LightApp_UpdateFlags.h>
122 #include <QtxFontEdit.h>
123 #include <QtxPopupMgr.h>
124 #include <QtxInfoPanel.h>
125 #include <SALOME_ListIO.hxx>
126 #include <SUIT_Desktop.h>
127 #include <SUIT_FileDlg.h>
128 #include <SUIT_MessageBox.h>
129 #include <SUIT_OverrideCursor.h>
130 #include <SUIT_ResourceMgr.h>
131 #include <SUIT_Session.h>
132 #include <SVTK_Renderer.h>
133 #include <SVTK_ViewManager.h>
134 #include <SVTK_ViewModel.h>
135 #include <SVTK_ViewWindow.h>
136 #include <SalomeApp_Application.h>
137 #include <SalomeApp_CheckFileDlg.h>
138 #include <SalomeApp_DataObject.h>
139 #include <SalomeApp_Study.h>
140 #include <SalomeApp_Tools.h>
141 #include <VTKViewer_Algorithm.h>
143 #ifndef DISABLE_PLOT2DVIEWER
144 #include <SPlot2d_ViewModel.h>
145 #include <SPlot2d_Histogram.h>
149 #include <SALOMEconfig.h>
150 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
151 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
152 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
153 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
154 #include CORBA_CLIENT_HEADER(SMESH_Homard)
157 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
158 #include <QApplication>
160 #include <QDialogButtonBox>
164 #include <QTextStream>
168 #include <boost/shared_ptr.hpp>
171 #include <vtkCallbackCommand.h>
172 #include <vtkCamera.h>
173 #include <vtkLookupTable.h>
174 #include <vtkPlane.h>
175 #include <vtkRenderer.h>
177 // SALOME KERNEL includes
178 #include <Basics_Utils.hxx>
179 #include <SALOMEDSClient_ClientFactory.hxx>
180 #include <SALOMEDSClient_IParameters.hxx>
181 #include <SALOMEDSClient_SComponent.hxx>
182 #include <SALOMEDSClient_StudyBuilder.hxx>
183 #include <SALOMEDS_SObject.hxx>
184 #include <SALOMEDS_Study.hxx>
185 #include <SALOME_GenericObj_wrap.hxx>
186 #include <SALOME_LifeCycleCORBA.hxx>
187 #include <utilities.h>
190 #include <Standard_ErrorHandler.hxx>
191 #include <NCollection_DataMap.hxx>
192 #include <NCollection_DoubleMap.hxx>
194 // Below macro, when uncommented, switches on simplified (more performant) algorithm
195 // of auto-color picking up
196 #define SIMPLE_AUTOCOLOR
201 //=============================================================
202 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
205 void ExportMeshToFile(int theCommandID);
207 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
209 void SetDisplayEntity(int theCommandID);
211 int ActionToControl( int theID, bool theReversed = false );
213 void Control( int theCommandID );
216 //================================================================================
218 * \brief Reads meshes from file
220 //================================================================================
222 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
226 std::string myExtension;
228 if ( theCommandID == SMESHOp::OpImportMED ||
229 theCommandID == SMESHOp::OpPopupImportMED ) {
230 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
231 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
233 else if ( theCommandID == SMESHOp::OpImportUNV ||
234 theCommandID == SMESHOp::OpPopupImportUNV ) {
235 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
237 else if ( theCommandID == SMESHOp::OpImportDAT ||
238 theCommandID == SMESHOp::OpPopupImportDAT ) {
239 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
241 else if ( theCommandID == SMESHOp::OpImportSTL ||
242 theCommandID == SMESHOp::OpPopupImportSTL ) {
243 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
245 else if ( theCommandID == SMESHOp::OpImportCGNS ||
246 theCommandID == SMESHOp::OpPopupImportCGNS ) {
247 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
249 else if ( theCommandID == SMESHOp::OpImportGMF ||
250 theCommandID == SMESHOp::OpPopupImportGMF ) {
251 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
252 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
255 QString anInitialPath = "";
256 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
257 anInitialPath = QDir::currentPath();
259 QStringList filenames;
260 bool toCreateGroups = true;
262 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
263 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
264 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
265 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
266 // fd->setNameFilters( filter );
267 // fd->SetChecked( true );
269 // filenames << fd->selectedFile();
270 // toCreateGroups = fd->IsChecked();
276 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
279 QObject::tr( "SMESH_IMPORT_MESH" ) );
281 if ( filenames.count() > 0 )
283 SUIT_OverrideCursor wc;
284 _PTR(Study) aStudy = SMESH::getStudy();
287 QStringList anEntryList;
288 bool isEmpty = false;
289 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
291 QString filename = *it;
292 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
294 switch ( theCommandID ) {
295 case SMESHOp::OpImportDAT:
296 case SMESHOp::OpPopupImportDAT:
298 // DAT format (currently unsupported)
299 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
300 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
303 case SMESHOp::OpImportUNV:
304 case SMESHOp::OpPopupImportUNV:
307 aMeshes->length( 1 );
308 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
309 if ( aMeshes[0]->_is_nil() )
310 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
311 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
314 case SMESHOp::OpImportMED:
315 case SMESHOp::OpPopupImportMED:
318 SMESH::DriverMED_ReadStatus res;
319 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
320 if ( res != SMESH::DRS_OK ) {
321 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
322 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
326 case SMESHOp::OpImportSTL:
327 case SMESHOp::OpPopupImportSTL:
330 aMeshes->length( 1 );
331 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
332 if ( aMeshes[0]->_is_nil() ) {
333 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
334 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
338 case SMESHOp::OpImportCGNS:
339 case SMESHOp::OpPopupImportCGNS:
342 SMESH::DriverMED_ReadStatus res;
343 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
344 if ( res != SMESH::DRS_OK ) {
345 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
346 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
350 case SMESHOp::OpImportGMF:
351 case SMESHOp::OpPopupImportGMF:
354 SMESH::ComputeError_var res;
355 aMeshes->length( 1 );
356 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
359 if ( res->code != SMESH::DRS_OK ) {
360 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
361 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
362 if ( strlen( res->comment.in() ) > 0 ) {
363 errors.back() += ": ";
364 errors.back() += res->comment.in();
371 catch ( const SALOME::SALOME_Exception& S_ex ) {
372 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
373 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
376 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
378 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
380 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
381 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
382 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
383 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
384 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
386 anEntryList.append( aMeshSO->GetID().c_str() );
394 // update Object browser
395 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
397 // browse to the published meshes
398 if( LightApp_Application* anApp =
399 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
400 anApp->browseObjects( anEntryList );
402 // show Error message box if there were errors
403 if ( errors.count() > 0 ) {
404 SUIT_MessageBox::critical( SMESHGUI::desktop(),
405 QObject::tr( "SMESH_ERROR" ),
406 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
409 // show warning message box, if some imported mesh is empty
411 SUIT_MessageBox::warning( SMESHGUI::desktop(),
412 QObject::tr( "SMESH_WRN_WARNING" ),
413 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
418 //================================================================================
420 * \brief Export selected meshes or groups into a file
422 //================================================================================
424 void ExportMeshToFile( int theCommandID )
426 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
427 SALOME_ListIO selected;
429 aSel->selectedObjects( selected );
431 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
432 theCommandID == SMESHOp::OpPopupExportDAT );
433 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
434 theCommandID == SMESHOp::OpPopupExportMED );
435 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
436 theCommandID == SMESHOp::OpPopupExportUNV );
437 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
438 theCommandID == SMESHOp::OpPopupExportSTL );
439 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
440 theCommandID == SMESHOp::OpPopupExportCGNS );
441 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
442 theCommandID == SMESHOp::OpPopupExportGMF );
444 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
445 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
447 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
448 bool aCheckWarn = true;
450 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
452 // get mesh object from selection and check duplication of their names
453 bool hasDuplicatedMeshNames = false;
454 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
455 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
456 SALOME_ListIteratorOfListIO It( selected );
457 for( ; It.More(); It.Next() )
459 Handle(SALOME_InteractiveObject) anIObject = It.Value();
460 SMESH::SMESH_IDSource_var aMeshItem =
461 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
462 if ( aMeshItem->_is_nil() ) {
463 SUIT_MessageBox::warning( SMESHGUI::desktop(),
464 QObject::tr( "SMESH_WRN_WARNING" ),
465 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
468 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
469 if ( aCheckWarn && !aGroup->_is_nil() )
471 QMessageBox msgBox(SUIT_MessageBox::Warning,
472 QObject::tr("SMESH_WRN_WARNING"),
473 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
474 QMessageBox::StandardButton::NoButton,
475 SMESHGUI::desktop());
476 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
477 msgBox.addButton(QMessageBox::Ok);
478 msgBox.addButton(QMessageBox::Cancel);
479 msgBox.setDefaultButton(QMessageBox::Cancel);
480 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
481 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
482 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
483 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
484 if ( msgBox.exec() != QMessageBox::Ok )
487 if ( dontShowCheckBox.checkState() == Qt::Checked && resMgr )
488 resMgr->setValue( "SMESH", "show_warning", false);
491 QString aMeshName = anIObject->getName();
493 // check for name duplications
494 if ( !hasDuplicatedMeshNames )
495 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
496 if( aMeshName == (*aMeshIter).second ) {
497 hasDuplicatedMeshNames = true;
502 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
505 if( hasDuplicatedMeshNames && isMED ) {
506 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
507 QObject::tr("SMESH_WRN_WARNING"),
508 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
509 QObject::tr("SMESH_BUT_YES"),
510 QObject::tr("SMESH_BUT_NO"), 0, 1);
515 aMeshIter = aMeshList.begin();
516 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
517 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
518 QString aMeshName = (*aMeshIter).second;
520 if ( isMED || isCGNS ) // formats where group names must be unique
522 // check for equal group names within each mesh
523 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
524 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
525 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
526 int aRet = SUIT_MessageBox::warning
527 (SMESHGUI::desktop(),
528 QObject::tr("SMESH_WRN_WARNING"),
529 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
530 QObject::tr("SMESH_BUT_YES"),
531 QObject::tr("SMESH_BUT_NO"), 0, 1);
538 // Warn the user about presence of not supported elements
540 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
544 notSupportedElemTypes.push_back( SMESH::Entity_0D );
545 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
550 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
551 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
552 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
553 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
554 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
555 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
556 notSupportedElemTypes.push_back( SMESH::Entity_0D );
557 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
562 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
563 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
564 notSupportedElemTypes.push_back( SMESH::Entity_0D );
565 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
570 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
575 notSupportedElemTypes.push_back( SMESH::Entity_0D );
576 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
577 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
578 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
579 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
580 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
581 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
582 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
583 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
584 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
586 if ( ! notSupportedElemTypes.empty() )
588 SMESH::smIdType_array_var nbElems = aMeshOrGroup->GetMeshInfo();
589 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
590 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
591 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
593 if ( !presentNotSupported.empty() )
596 const char* typeMsg[] = {
597 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
598 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
599 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
600 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
601 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
602 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
603 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
604 "SMESH_BIQUADRATIC_PENTAHEDRONS",
605 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
607 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
608 static_assert( sizeof(typeMsg) / sizeof(const char*) == SMESH::Entity_Last,
609 "Update names of EntityType's!!!" );
611 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
612 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
613 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
614 if ( iType != presentNotSupported.size() - 1 )
615 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
617 int aRet = SUIT_MessageBox::warning
618 (SMESHGUI::desktop(),
619 QObject::tr("SMESH_WRN_WARNING"),
620 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
621 QObject::tr("SMESH_BUT_YES"),
622 QObject::tr("SMESH_BUT_NO"), 0, 1);
627 // Get parameters of export operation
630 int aFormat =-1; // for MED version used for write
631 bool isOkToWrite = true; // to check MED file version compatibility before adding a mesh in an existing file
633 // Init the parameters with the default values
634 bool aIsASCII_STL = true;
635 bool toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
636 bool toOverwrite = true;
637 bool toFindOutDim = true;
638 bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true );
639 bool toRenumber = true;
640 double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. );
642 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
643 QString anInitialPath = "";
644 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
645 anInitialPath = QDir::currentPath();
647 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
649 // Get a file name to write in and additional options
650 if ( isGMF ) // Export w/o options
652 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
653 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
654 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
656 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
657 anInitialPath + QString("/") + aMeshName,
658 aFilter, aTitle, false);
660 else if ( isCGNS || isUNV || isDAT ) // Export to [ CGNS | UNV | DAT ] - one option
662 const char* theOptionResource = isCGNS ? "cgns_group_elems_by_type" : "export_renumber";
663 bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
665 QStringList checkBoxes;
666 checkBoxes << QObject::tr( isCGNS ? "CGNS_EXPORT_ELEMS_BY_TYPE" : "SMESH_RENUMBER" );
668 SalomeApp_CheckFileDlg* fd =
669 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
670 fd->setWindowTitle( aTitle );
672 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
674 fd->setNameFilter( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
676 fd->setNameFilter( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
677 if ( !anInitialPath.isEmpty() )
678 fd->setDirectory( anInitialPath );
679 fd->selectFile( aMeshName );
680 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
681 fd->setValidator( fv );
682 fd->SetChecked( option, 0 );
685 aFilename = fd->selectedFile();
686 toOverwrite = fv->isOverwrite( aFilename );
687 option = fd->IsChecked( 0 );
688 SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
689 ( isCGNS ? toCreateGroups : toRenumber ) = option;
693 else if ( isSTL ) // Export to STL
695 QMap<QString, int> aFilterMap;
696 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
697 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
700 QMap<QString, int>::const_iterator it = aFilterMap.begin();
701 for ( ; it != aFilterMap.end(); ++it )
702 filters.push_back( it.key() );
704 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
705 fd->setWindowTitle( aTitle );
706 fd->setNameFilters( filters );
707 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
708 if ( !anInitialPath.isEmpty() )
709 fd->setDirectory( anInitialPath );
710 fd->selectFile(aMeshName);
714 aFilename = fd->selectedFile();
715 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
720 else if ( isMED ) // Export to MED
722 int defaultVersion = 0;
723 QMap<QString, int> aFilterMap;
724 //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
725 //QString vmed (aMesh->GetVersionString(-1, 2));
726 SMESH::long_array_var mvok = aMesh->GetMEDVersionsCompatibleForAppend();
727 if ( mvok->length() > 0)
728 defaultVersion = mvok[0]; // the current version to set the default filter on it
729 for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
731 QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
732 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
735 QMap<QString, int>::const_iterator it = aFilterMap.begin();
736 QString aDefaultFilter = it.key();
737 for ( ; it != aFilterMap.end(); ++it ) {
738 filters.push_back( it.key() );
739 if (it.value() == defaultVersion) // explicit default for MED = current MED version
740 aDefaultFilter = it.key();
742 QStringList checkBoxes;
743 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS")
744 << QObject::tr("SMESH_AUTO_DIM")
745 << QObject::tr("SMESH_MED_SAVE_NUMS");
747 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
748 QList< QWidget* > wdgList;
749 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
750 wdgList.append( fieldSelWdg );
752 QWidget* zTolWdg = new QWidget();
753 QCheckBox* zTolCheck = new QCheckBox( QObject::tr( "SMESH_ZTOLERANCE" ), zTolWdg );
754 SMESHGUI_SpinBox* zTolSpin = new SMESHGUI_SpinBox( zTolWdg );
755 QHBoxLayout* zTolLayout = new QHBoxLayout( zTolWdg );
756 zTolLayout->addWidget( zTolCheck );
757 zTolLayout->addWidget( zTolSpin );
758 zTolLayout->setMargin( 0 );
759 zTolSpin->RangeStepAndValidator( 0, 1e+100, 1., "length_precision" );
760 zTolSpin->setValue( zTol );
761 QObject::connect( zTolCheck, SIGNAL( toggled(bool)), zTolSpin, SLOT( setEnabled(bool)));
762 zTolCheck->setChecked( resMgr->booleanValue( "SMESH", "enable_ztolerance", false ));
763 zTolSpin ->setEnabled( zTolCheck->isChecked() );
764 wdgList.append( zTolWdg );
766 SalomeApp_CheckFileDlg* fd =
767 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
768 fd->setWindowTitle( aTitle );
769 fd->setNameFilters( filters );
770 fd->selectNameFilter( aDefaultFilter );
771 fd->SetChecked( toCreateGroups, 0 );
772 fd->SetChecked( toFindOutDim, 1 );
773 fd->SetChecked( saveNumbers, 2 );
774 if ( !anInitialPath.isEmpty() )
775 fd->setDirectory( anInitialPath );
776 fd->selectFile(aMeshName);
779 QListView *lview = fd->findChild<QListView*>("listView");
781 lview->setMinimumHeight(200);
783 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
785 tview->setMinimumHeight(200);
788 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
789 fd->setValidator( fv );
794 //MESSAGE("******* Loop on file dialog ***********");
797 aFilename = fd->selectedFile();
799 aFilename = QString::null;
802 aFormat = aFilterMap[fd->selectedNameFilter()];
803 //MESSAGE("selected version: " << aFormat << " file: " << aFilename.toUtf8().constData());
804 toOverwrite = fv->isOverwrite(aFilename);
805 //MESSAGE("toOverwrite:" << toOverwrite);
807 if ( !aFilename.isEmpty() ) {
809 // append is only possible if the existing file format is compatible
810 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckWriteCompatibility( aFilename.toUtf8().constData() );
811 MESSAGE("Append check, isVersionOk:" << isVersionOk);
812 if ( !isVersionOk ) {
813 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
814 QObject::tr("SMESH_WRN_WARNING"),
815 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
816 QObject::tr("SMESH_BUT_YES"),
817 QObject::tr("SMESH_BUT_NO"), 0, 1);
821 //MESSAGE("incompatible MED file version for add, overwrite accepted");
827 //MESSAGE("incompatible MED file version for add, overwrite refused");
830 QStringList aMeshNamesCollisionList;
831 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
832 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
833 QString anExistingMeshName( aMeshNames[ i ] );
834 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
835 QString anExportMeshName = (*aMeshIter).second;
836 if( anExportMeshName == anExistingMeshName ) {
837 aMeshNamesCollisionList.append( anExportMeshName );
842 if( !aMeshNamesCollisionList.isEmpty() ) {
844 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
845 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
846 QObject::tr("SMESH_WRN_WARNING"),
847 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
848 QObject::tr("SMESH_BUT_YES"),
849 QObject::tr("SMESH_BUT_NO"),
850 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
851 MESSAGE("answer collision name " << aRet);
862 toCreateGroups = fd->IsChecked(0);
863 toFindOutDim = fd->IsChecked(1);
864 saveNumbers = fd->IsChecked(2);
865 zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1;
866 fieldSelWdg->GetSelectedFields();
867 if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() );
869 if ( !fieldSelWdg->parent() )
871 if ( !zTolWdg->parent() )
882 if ( !aFilename.isEmpty() ) {
883 // Check whether the file already exists and delete it if yes
884 QFile aFile( aFilename );
885 if ( aFile.exists() && toOverwrite )
887 SUIT_OverrideCursor wc;
890 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
891 // bool Renumber = false;
892 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
894 // Renumber= resMgr->booleanValue("renumbering");
896 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
897 // aMeshEditor->RenumberNodes();
898 // aMeshEditor->RenumberElements();
899 // if ( SMESHGUI::automaticUpdate() )
900 // SMESH::UpdateView();
902 if ( isMED && isOkToWrite )
904 aMeshIter = aMeshList.begin();
905 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
907 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
908 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
909 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
910 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
912 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
913 toCreateGroups, aFormat,
914 toOverwrite && aMeshIndex == 0, toFindOutDim,
915 fields, geoAssFields.toLatin1().data(), zTol, saveNumbers );
920 if ( aMeshOrGroup->_is_equivalent( aMesh ))
921 aMesh->ExportDAT( aFilename.toUtf8().data(), toRenumber );
923 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
927 if ( aMeshOrGroup->_is_equivalent( aMesh ))
928 aMesh->ExportUNV( aFilename.toUtf8().data(), toRenumber );
930 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
934 if ( aMeshOrGroup->_is_equivalent( aMesh ))
935 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
937 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
941 aMeshIter = aMeshList.begin();
942 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
944 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
945 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
946 aMeshItem->ExportCGNS( aMeshOrGroup,
947 aFilename.toUtf8().data(),
948 toOverwrite && aMeshIndex == 0,
954 toCreateGroups = true;
955 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
958 catch (const SALOME::SALOME_Exception& S_ex)
961 if ( S_ex.details.type == SALOME::COMM && // communicate about too large mesh
962 strncmp( "format=", S_ex.details.sourceFile.in(), 7 ) == 0 )
964 SUIT_MessageBox::critical(SMESHGUI::desktop(),
965 QObject::tr("SMESH_WRN_WARNING"),
966 QObject::tr(S_ex.details.text.in() ));
968 SUIT_MessageBox::warning(SMESHGUI::desktop(),
969 QObject::tr("SMESH_WRN_WARNING"),
970 QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
976 inline void InverseEntityMode(unsigned int& theOutputMode,
977 unsigned int theMode)
979 bool anIsNotPresent = ~theOutputMode & theMode;
981 theOutputMode |= theMode;
983 theOutputMode &= ~theMode;
986 void SetDisplayEntity(int theCommandID)
988 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
989 SALOME_ListIO selected;
991 aSel->selectedObjects( selected );
993 if ( selected.Extent() >= 1 ) {
994 SUIT_OverrideCursor wc;
995 SALOME_ListIteratorOfListIO It( selected );
996 for( ; It.More(); It.Next()){
997 Handle(SALOME_InteractiveObject) IObject = It.Value();
998 if(IObject->hasEntry()){
999 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1000 unsigned int aMode = anActor->GetEntityMode();
1001 switch(theCommandID){
1002 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1003 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1004 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1005 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1006 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1007 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1010 anActor->SetEntityMode(aMode);
1019 SalomeApp_Application* app =
1020 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1024 LightApp_SelectionMgr* aSel = app->selectionMgr();
1025 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1026 if ( !aSel || !appStudy )
1029 SALOME_ListIO selected;
1030 aSel->selectedObjects( selected );
1031 if ( selected.IsEmpty() )
1034 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1036 _PTR(Study) aStudy = appStudy->studyDS();
1037 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1038 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1039 if ( aMainObject->_is_nil() )
1042 SUIT_OverrideCursor wc;
1044 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1046 QList<SALOMEDS::Color> aReservedColors;
1048 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1049 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1051 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1053 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1054 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1055 #else // old algorithm for auto-colors
1056 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1057 aReservedColors.append( aColor );
1058 #endif // SIMPLE_AUTOCOLOR
1059 aGroupObject->SetColor( aColor );
1061 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1062 if ( aGroupSObject ) {
1065 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1066 switch ( aGroupObject->GetType ()) {
1068 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1070 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1072 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1074 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1076 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1077 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1080 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1081 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1087 SMESH::RepaintCurrentView();
1090 void OverallMeshQuality()
1092 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1093 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1094 SALOME_ListIO selected;
1096 aSel->selectedObjects( selected );
1098 if ( selected.IsEmpty() ) return;
1099 SALOME_ListIteratorOfListIO It( selected );
1100 for ( ; It.More(); It.Next() ) {
1101 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1102 ctrlDlg->showInfo( It.Value() );
1107 QString functorToString( SMESH::Controls::FunctorPtr f )
1109 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1110 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1111 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1112 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1113 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1114 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1115 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1116 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1117 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1118 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1119 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1120 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1121 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1122 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1123 type = QObject::tr( "WARP_ELEMENTS" );
1124 else if (dynamic_cast<SMESH::Controls::Warping3D*>(f.get()))
1125 type = QObject::tr("WARP_3D_ELEMENTS");
1126 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1127 type = QObject::tr( "TAPER_ELEMENTS" );
1128 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1129 type = QObject::tr( "SKEW_ELEMENTS" );
1130 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1131 type = QObject::tr( "AREA_ELEMENTS" );
1132 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1133 type = QObject::tr( "LENGTH_EDGES" );
1134 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1135 type = QObject::tr( "LENGTH2D_EDGES" );
1136 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1137 type = QObject::tr( "DEFLECTION2D_FACES" );
1138 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1139 type = QObject::tr( "MULTI_BORDERS" );
1140 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1141 type = QObject::tr( "MULTI2D_BORDERS" );
1142 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1143 type = QObject::tr( "FREE_NODES" );
1144 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1145 type = QObject::tr( "FREE_EDGES" );
1146 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1147 type = QObject::tr( "FREE_BORDERS" );
1148 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1149 type = QObject::tr( "FREE_FACES" );
1150 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1151 type = QObject::tr( "BARE_BORDER_VOLUME" );
1152 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1153 type = QObject::tr( "BARE_BORDER_FACE" );
1154 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1155 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1156 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1157 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1158 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1159 type = QObject::tr( "EQUAL_NODE" );
1160 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1161 type = QObject::tr( "EQUAL_EDGE" );
1162 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1163 type = QObject::tr( "EQUAL_FACE" );
1164 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1165 type = QObject::tr( "EQUAL_VOLUME" );
1166 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1167 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1168 else if ( dynamic_cast< SMESH::Controls::ScaledJacobian* >( f.get() ) )
1169 type = QObject::tr( "SCALED_JACOBIAN" );
1173 void SaveDistribution()
1175 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1176 SALOME_ListIO selected;
1178 aSel->selectedObjects( selected );
1180 if ( selected.Extent() == 1 ) {
1181 Handle(SALOME_InteractiveObject) anIO = selected.First();
1182 if ( anIO->hasEntry() ) {
1183 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1185 anActor->GetScalarBarActor() &&
1186 anActor->GetControlMode() != SMESH_Actor::eNone )
1188 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1189 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1190 if ( aScalarBarActor && aFunctor ) {
1191 SMESH::Controls::NumericalFunctor* aNumFun =
1192 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1194 std::vector<smIdType> elements;
1195 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1196 if ( mesh->_is_nil() ) {
1197 SMESH::SMESH_IDSource_var idSource =
1198 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1199 if ( !idSource->_is_nil() )
1201 SMESH::smIdType_array_var ids = idSource->GetIDs();
1202 elements.resize( ids->length() );
1203 for ( unsigned i = 0; i < elements.size(); ++i )
1204 elements[i] = ids[i];
1207 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1208 vtkLookupTable* lookupTable =
1209 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1210 double * minmax = lookupTable->GetRange();
1211 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1212 std::vector<int> nbEvents;
1213 std::vector<double> funValues;
1214 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1215 elements, minmax, isLogarithmic );
1216 QString anInitialPath = "";
1217 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1218 anInitialPath = QDir::currentPath();
1219 QString aMeshName = anIO->getName();
1221 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1222 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1223 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1224 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1225 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1228 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1230 if ( !aFilename.isEmpty() ) {
1231 QFile f( aFilename );
1232 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1233 QTextStream out( &f );
1234 out << "# Mesh: " << aMeshName << endl;
1235 out << "# Control: " << functorToString( aFunctor ) << endl;
1237 out.setFieldWidth( 10 );
1238 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1239 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1250 void ShowElement( int theCommandID )
1252 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1253 SALOME_ListIO selected;
1255 aSel->selectedObjects( selected );
1257 if ( selected.Extent() == 1 ) {
1258 Handle(SALOME_InteractiveObject) anIO = selected.First();
1259 if ( anIO->hasEntry() ) {
1260 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1262 anActor->GetScalarBarActor() &&
1263 anActor->GetControlMode() != SMESH_Actor::eNone )
1265 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1266 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1267 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1269 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1270 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1277 #ifndef DISABLE_PLOT2DVIEWER
1278 void PlotDistribution()
1280 SalomeApp_Application* app =
1281 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1285 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1286 SALOME_ListIO selected;
1288 aSel->selectedObjects( selected );
1290 if ( selected.Extent() == 1 ) {
1291 Handle(SALOME_InteractiveObject) anIO = selected.First();
1292 if ( anIO->hasEntry() ) {
1293 //Find Actor by entry before getting Plot2d viewer,
1294 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1295 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1297 SUIT_ViewManager* aViewManager =
1298 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1302 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1306 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1310 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1312 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1313 QString functorName = functorToString( anActor->GetFunctor());
1314 QString aHistogramName("%1 : %2");
1315 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1316 aHistogram->setName(aHistogramName);
1317 aHistogram->setHorTitle(functorName);
1318 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1319 aPlot->displayObject(aHistogram, true);
1324 #endif //DISABLE_PLOT2DVIEWER
1326 void DisableAutoColor()
1328 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1329 SALOME_ListIO selected;
1331 aSel->selectedObjects( selected );
1333 if ( selected.Extent() ) {
1334 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1335 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1336 if ( !aMesh->_is_nil() ) {
1337 aMesh->SetAutoColor( false );
1344 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1345 SALOME_ListIO selected;
1347 aSel->selectedObjects( selected );
1348 if ( selected.Extent() )
1350 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1351 _PTR(Study) aStudy = SMESH::getStudy();
1352 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1354 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1355 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1362 // Break link with Shaper model
1363 void breakShaperLink()
1365 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1366 SALOME_ListIO selected;
1368 aSel->selectedObjects(selected);
1369 if (selected.Extent()) {
1370 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1371 _PTR(Study) aStudy = SMESH::getStudy();
1372 std::string aEntry = anIObject->getEntry();
1373 _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
1375 std::string aName = aSObj->GetName();
1376 QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
1377 QObject::tr("SMESH_WRN_WARNING"),
1378 QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
1379 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
1380 if (aRes == SUIT_MessageBox::Yes) {
1381 SUIT_DataOwnerPtrList aList;
1382 aSel->selected(aList, "ObjectBrowser", true);
1383 SUIT_DataOwner* aOwn = aList.first();
1384 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
1385 QString aREntry = sowner->entry();
1387 static GEOM::GEOM_Gen_var geomGen;
1388 if (CORBA::is_nil(geomGen)) {
1389 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1390 (SUIT_Session::session()->activeApplication());
1392 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
1393 Engines::EngineComponent_var comp =
1394 ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
1395 geomGen = GEOM::GEOM_Gen::_narrow(comp);
1398 if (!CORBA::is_nil(geomGen))
1400 geomGen->BreakLink(aREntry.toStdString().c_str());
1401 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1403 // remove actors whose objects are removed by BreakLink()
1404 QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
1405 SUIT_ViewWindow* wnd;
1406 foreach(wnd, wndList)
1407 SMESH::UpdateActorsAfterUpdateStudy(wnd);
1415 //================================================================================
1417 * \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
1418 * which means that the mesh can't be modified. It should be either re-computed
1419 * or breakShaperLink()'ed. Warn the user about it.
1421 //================================================================================
1423 bool warnOnGeomModif()
1425 SALOME_ListIO selected;
1426 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1427 aSel->selectedObjects(selected,"",/*convertReferences=*/false);
1429 SALOME_ListIteratorOfListIO It( selected );
1430 for ( ; It.More(); It.Next() )
1432 Handle(SALOME_InteractiveObject) io = It.Value();
1433 if ( !io->hasEntry() ) continue;
1434 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
1435 SMESH::SMESH_Mesh_var mesh;
1436 while ( mesh->_is_nil() && so && so->GetID() != "0:" )
1438 CORBA::Object_var obj = SMESH::SObjectToObject( so );
1439 SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
1440 if ( isrc->_is_nil() )
1441 so = so->GetFather();
1443 mesh = isrc->GetMesh();
1445 if ( mesh->_is_nil() ) continue;
1446 so = SMESH::FindSObject( mesh );
1447 if ( !so ) continue;
1448 _PTR(GenericAttribute) attr;
1449 so->FindAttribute( attr, "AttributePixMap" );
1450 _PTR(AttributePixMap) pixmap = attr;
1451 if ( !pixmap ) continue;
1453 if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
1455 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1456 QObject::tr("SMESH_WRN_WARNING"),
1457 QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
1464 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1466 SALOME_ListIO selected;
1467 SalomeApp_Application* app =
1468 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1472 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1473 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1474 if ( !aSel || !appStudy )
1477 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1478 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1479 aModule->EmitSignalDeactivateDialog();
1480 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1481 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1486 aSel->selectedObjects( selected );
1488 if ( selected.Extent() >= 1 )
1490 switch ( theCommandID ) {
1491 case SMESHOp::OpTransparency:
1493 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1494 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1497 case SMESHOp::OpProperties:
1500 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1501 QColor orientationColor, outlineColor, volumeColor;
1502 int deltaF = 0, deltaV = 0;
1505 double ballScale = 1.0;
1507 int outlineWidth = 1;
1508 double shrinkCoef = 0.0;
1509 double orientationScale = 0.0;
1510 bool orientation3d = false;
1511 VTK::MarkerType markerType = VTK::MT_NONE;
1512 VTK::MarkerScale markerScale = VTK::MS_NONE;
1514 bool hasNodes = false;
1515 int presentEntities = 0;
1516 bool firstTime = true;
1518 SALOME_ListIteratorOfListIO It( selected );
1519 for ( ; It.More(); It.Next() ) {
1520 Handle(SALOME_InteractiveObject) IObject = It.Value();
1521 if ( !IObject->hasEntry() ) continue;
1522 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1523 if ( !anActor || !anActor->GetObject() ) continue;
1526 // nodes: color, marker
1527 anActor->GetNodeColor( color[0], color[1], color[2] );
1528 nodeColor.setRgbF( color[0], color[1], color[2] );
1529 markerType = anActor->GetMarkerType();
1530 markerScale = anActor->GetMarkerScale();
1531 markerId = anActor->GetMarkerTexture();
1532 // edges: color, width
1533 anActor->GetEdgeColor( color[0], color[1], color[2] );
1534 edgeColor.setRgbF( color[0], color[1], color[2] );
1535 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1536 // faces: front color, back color (delta)
1537 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1538 faceColor.setRgbF( color[0], color[1], color[2] );
1539 // faces: front color, back color (delta)
1540 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1541 volumeColor.setRgbF( color[0], color[1], color[2] );
1542 // 0d elements: color, size
1543 anActor->Get0DColor( color[0], color[1], color[2] );
1544 elem0dColor.setRgbF( color[0], color[1], color[2] );
1545 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1546 // balls: color, size
1547 anActor->GetBallColor( color[0], color[1], color[2] );
1548 ballColor.setRgbF( color[0], color[1], color[2] );
1549 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1550 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1552 anActor->GetOutlineColor( color[0], color[1], color[2] );
1553 outlineColor.setRgbF( color[0], color[1], color[2] );
1554 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1555 // orientation vectors: color, scale, 3d flag
1556 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1557 orientationColor.setRgbF( color[0], color[1], color[2] );
1558 orientationScale = anActor->GetFacesOrientationScale();
1559 orientation3d = anActor->GetFacesOrientation3DVectors();
1561 shrinkCoef = anActor->GetShrinkFactor();
1564 firstTime = false; // we only take properties from first object (for performance reasons)
1567 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1568 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1569 presentEntities = presentEntities | SMESH_Actor::eEdges;
1570 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1571 presentEntities = presentEntities | SMESH_Actor::eFaces;
1572 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1573 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1574 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1575 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1576 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1577 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1579 // as we know that all types of elements are present, we can exit the loop
1580 if ( presentEntities == SMESH_Actor::eAllEntity )
1584 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1585 // nodes: color, marker
1586 dlg.setNodeColor( nodeColor );
1587 if( markerType != VTK::MT_USER )
1588 dlg.setNodeMarker( markerType, markerScale );
1590 dlg.setNodeCustomMarker( markerId );
1591 // edges: color, line width
1592 dlg.setEdgeColor( edgeColor );
1593 dlg.setEdgeWidth( edgeWidth );
1594 // faces: front color, back color
1595 dlg.setFaceColor( faceColor, deltaF );
1596 // volumes: normal color, reversed color
1597 dlg.setVolumeColor( volumeColor, deltaV );
1598 // outlines: color, line width
1599 dlg.setOutlineColor( outlineColor );
1600 dlg.setOutlineWidth( outlineWidth );
1601 // 0d elements: color, size
1602 dlg.setElem0dColor( elem0dColor );
1603 dlg.setElem0dSize( elem0dSize );
1604 // balls: color, size
1605 dlg.setBallColor( ballColor );
1606 //dlg.setBallSize( ballSize );
1607 dlg.setBallScale( ballScale );
1608 // orientation: color, scale, 3d flag
1609 dlg.setOrientationColor( orientationColor );
1610 dlg.setOrientationSize( int( orientationScale * 100. ) );
1611 dlg.setOrientation3d( orientation3d );
1612 // shrink: scale factor
1613 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1614 // hide unused controls
1615 dlg.showControls( presentEntities, hasNodes );
1618 nodeColor = dlg.nodeColor();
1619 markerType = dlg.nodeMarkerType();
1620 markerScale = dlg.nodeMarkerScale();
1621 markerId = dlg.nodeMarkerId();
1622 edgeColor = dlg.edgeColor();
1623 edgeWidth = dlg.edgeWidth();
1624 faceColor = dlg.faceColor();
1625 deltaF = dlg.faceColorDelta();
1626 volumeColor = dlg.volumeColor();
1627 deltaV = dlg.volumeColorDelta();
1628 outlineColor = dlg.outlineColor();
1629 outlineWidth = dlg.outlineWidth();
1630 elem0dColor = dlg.elem0dColor();
1631 elem0dSize = dlg.elem0dSize();
1632 ballColor = dlg.ballColor();
1633 // ballSize = dlg.ballSize();
1634 ballScale = dlg.ballScale();
1635 orientationColor = dlg.orientationColor();
1636 orientationScale = dlg.orientationSize() / 100.;
1637 orientation3d = dlg.orientation3d();
1638 shrinkCoef = dlg.shrinkCoef() / 100.;
1640 // store point markers that might be changed by the user
1641 theMarkerMap = dlg.customMarkers();
1643 // set properties from dialog box to the presentations
1644 SALOME_ListIteratorOfListIO It( selected );
1645 for ( ; It.More(); It.Next() ) {
1646 Handle(SALOME_InteractiveObject) IObject = It.Value();
1647 if ( !IObject->hasEntry() ) continue;
1648 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1649 if ( !anActor ) continue;
1651 // nodes: color, marker
1652 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1653 if ( markerType != VTK::MT_USER ) {
1654 anActor->SetMarkerStd( markerType, markerScale );
1657 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1658 if ( iter != theMarkerMap.end() )
1659 anActor->SetMarkerTexture( markerId, iter->second.second );
1661 // volumes: normal color, reversed color (delta)
1662 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1663 // faces: front color, back color (delta)
1664 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1665 // edges: color, width
1666 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1667 anActor->SetLineWidth( edgeWidth );
1669 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1670 anActor->SetOutlineWidth( outlineWidth );
1671 // 0D elements: color, size
1672 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1673 anActor->Set0DSize( elem0dSize );
1674 // balls: color, size
1675 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1676 // anActor->SetBallSize( ballSize );
1677 anActor->SetBallScale( ballScale );
1678 // orientation: color, scale, 3d flag
1679 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1680 anActor->SetFacesOrientationScale( orientationScale );
1681 anActor->SetFacesOrientation3DVectors( orientation3d );
1683 anActor->SetShrinkFactor( shrinkCoef );
1685 // for groups, set also proper color
1686 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1687 if ( !aGroupObject->_is_nil() ) {
1688 SMESH::ElementType anElementType = aGroupObject->GetType();
1690 switch( anElementType ) {
1692 aColor = nodeColor; break;
1694 aColor = edgeColor; break;
1696 aColor = faceColor; break;
1698 aColor = volumeColor; break;
1700 aColor = elem0dColor; break;
1702 aColor = ballColor; break;
1706 if ( aColor.isValid() ) {
1707 SALOMEDS::Color aGroupColor;
1708 aGroupColor.R = aColor.redF();
1709 aGroupColor.G = aColor.greenF();
1710 aGroupColor.B = aColor.blueF();
1711 aGroupObject->SetColor( aGroupColor );
1713 } // if ( !aGroupObject->_is_nil() )
1714 } // for ( ; It.More(); It.Next() )
1715 SMESH::RepaintCurrentView();
1716 } // if ( dlg.exec() )
1718 } // case SMESHOp::OpProperties:
1719 } // switch(theCommandID)
1720 SUIT_OverrideCursor wc;
1721 SALOME_ListIteratorOfListIO It( selected );
1722 for( ; It.More(); It.Next()){
1723 Handle(SALOME_InteractiveObject) IObject = It.Value();
1724 if(IObject->hasEntry()){
1725 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1726 switch(theCommandID){
1727 case SMESHOp::OpDMWireframe:
1728 anActor->SetRepresentation(SMESH_Actor::eEdge);
1730 case SMESHOp::OpDMShading:
1731 anActor->SetRepresentation(SMESH_Actor::eSurface);
1733 case SMESHOp::OpDMShrink:
1734 if(anActor->IsShrunk())
1735 anActor->UnShrink();
1737 anActor->SetShrink();
1739 case SMESHOp::OpDMNodes:
1740 anActor->SetRepresentation(SMESH_Actor::ePoint);
1742 case SMESHOp::OpRepresentationLines:
1743 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1744 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1746 case SMESHOp::OpRepresentationArcs:
1747 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1748 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1754 SMESH::RepaintCurrentView();
1758 int ActionToControl( int theID, bool theReversed )
1760 NCollection_DoubleMap<int,int> ActionControl;
1761 ActionControl.Bind( 0, SMESH_Actor::eNone );
1762 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1763 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1764 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1765 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1766 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1767 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1768 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1769 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1770 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1771 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1772 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1773 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1774 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1775 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1776 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1777 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1778 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1779 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1780 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1781 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1782 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1783 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1784 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1785 ActionControl.Bind( SMESHOp::OpWarping3D, SMESH_Actor::eWarping3D );
1786 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1787 ActionControl.Bind( SMESHOp::OpScaledJacobian, SMESH_Actor::eScaledJacobian );
1788 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1789 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1790 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1791 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1794 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1795 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1798 void Control( int theCommandID )
1800 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1801 _PTR(Study) aStudy = SMESH::getStudy();
1803 SALOME_ListIO selected;
1804 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1805 aSel->selectedObjects( selected );
1807 if ( !selected.IsEmpty() ) {
1808 SALOME_ListIteratorOfListIO It(selected);
1809 for ( ; It.More(); It.Next())
1811 Handle(SALOME_InteractiveObject) anIO = It.Value();
1812 if ( !anIO.IsNull() ) {
1813 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1815 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1816 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1817 if ( !anIDSrc->_is_nil() ) {
1818 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1819 if (( !anActor && selected.Extent() == 1 ) &&
1820 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1822 anActor->SetControlMode( aControl );
1823 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1824 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1828 if ( anActor->GetControlMode() != aControl )
1829 anActor->SetControlMode( aControl );
1830 QString functorName = functorToString( anActor->GetFunctor() );
1831 smIdType anEntitiesCount = anActor->GetNumberControlEntities();
1832 if (anEntitiesCount >= 0)
1833 functorName = functorName + ": " + QString::number(anEntitiesCount);
1834 anActor->GetScalarBarActor()->SetTitle( functorName.toUtf8().constData() );
1835 SMESH::RepaintCurrentView();
1836 #ifndef DISABLE_PLOT2DVIEWER
1837 if ( anActor->GetPlot2Histogram() ) {
1838 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1839 QString aHistogramName("%1 : %2");
1840 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1841 aHistogram->setName( aHistogramName );
1842 aHistogram->setHorTitle( functorName );
1843 SMESH::ProcessIn2DViewers( anActor );
1855 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1856 SMESH::MeshObjectType theType,
1857 const QString theInTypeName,
1858 QString & theOutTypeName)
1860 SMESH_TypeFilter aTypeFilter( theType );
1862 if ( !theIO.IsNull() )
1864 entry = theIO->getEntry();
1865 LightApp_DataOwner owner( entry );
1866 if ( aTypeFilter.isOk( &owner )) {
1867 theOutTypeName = theInTypeName;
1875 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1877 _PTR(Study) aStudy = SMESH::getStudy();
1878 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1880 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1881 CORBA::String_var anID = aSComp->GetID().c_str();
1882 if ( !strcmp(anID.in(),theIO->getEntry()) )
1888 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1889 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1890 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1891 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1892 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1900 // QString CheckHomogeneousSelection()
1902 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1903 // SALOME_ListIO selected;
1905 // aSel->selectedObjects( selected );
1907 // QString RefType = CheckTypeObject(selected.First());
1908 // SALOME_ListIteratorOfListIO It(selected);
1909 // for ( ; It.More(); It.Next())
1911 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1912 // QString Type = CheckTypeObject(IObject);
1913 // if ( Type.compare(RefType) != 0 )
1914 // return "Heterogeneous Selection";
1920 uint randomize( uint size )
1922 static bool initialized = false;
1923 if ( !initialized ) {
1924 qsrand( QDateTime::currentDateTime().toTime_t() );
1928 v = uint( (double)( v ) / RAND_MAX * size );
1929 v = qMax( uint(0), qMin ( v, size-1 ) );
1935 void SMESHGUI::OnEditDelete()
1937 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1938 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1939 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1941 _PTR(Study) aStudy = SMESH::getStudy();
1942 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1943 _PTR(GenericAttribute) anAttr;
1944 _PTR(AttributeIOR) anIOR;
1946 const int objectCountLimit = 30; // PAL23599
1947 int objectCount = 0;
1949 QString aParentComponent = QString::null;
1951 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1953 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
1954 if ( anIO.IsNull() ) continue;
1956 QString father = "unknown", name;
1958 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
1960 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
1961 // check if object is reference
1962 _PTR(SObject) aRefSObj;
1963 if ( aSO->ReferencedObject( aRefSObj ) ) {
1964 name = QString::fromStdString ( aRefSObj->GetName() );
1965 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1968 name = anIO->getName();
1971 if ( objectCount < objectCountLimit ) { // avoid occupying the whole screen
1972 aNameList.append("\n - ");
1973 aNameList.append( name );
1976 if( aParentComponent.isNull() )
1977 aParentComponent = father;
1978 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
1979 aParentComponent = "";
1981 if ( objectCount >= objectCountLimit )
1982 aNameList.append("\n - ...");
1984 if ( objectCount == 0 )
1985 return; // No Valid Objects Selected
1987 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1988 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1989 QObject::tr("ERR_ERROR"),
1990 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1993 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1994 if (SUIT_MessageBox::warning
1995 (SMESHGUI::desktop(),
1996 QObject::tr("SMESH_WRN_WARNING"),
1997 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1998 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1999 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
2002 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2004 // Put one level of sub-objects of the selected SO's into a list
2005 // in order to get objects inside folders like "Assigned Algorithms"
2006 std::list< _PTR(SObject) > listSO;
2007 SALOME_ListIteratorOfListIO It(selected);
2008 for( ; It.More(); It.Next()) // loop on selected IO's
2010 Handle(SALOME_InteractiveObject) IObject = It.Value();
2011 if(IObject->hasEntry()) {
2012 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
2014 // disable removal of "SMESH" component object
2015 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
2017 if ( engineIOR() == anIOR->Value().c_str() )
2020 //Check the referenced object
2021 _PTR(SObject) aRefSObject;
2022 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
2023 aSO = aRefSObject; // Delete main Object instead of reference
2025 listSO.push_back( aSO );
2027 _PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
2028 for (it->InitEx(false); it->More(); it->Next())
2029 listSO.push_back( it->Value() );
2032 // Check if none of objects to delete is referred from outside
2033 std::list< _PTR(SObject) >::reverse_iterator ritSO;
2034 std::vector< _PTR(SObject) > subSO;
2035 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2037 _PTR(SObject) SO = *ritSO;
2038 if ( !SO ) continue;
2040 int nbChildren = SO->GetLastChildTag();
2042 subSO.reserve( 1 + nbChildren );
2043 subSO.push_back( SO );
2044 if ( nbChildren > 0 )
2046 _PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
2047 for ( it->InitEx( true ); it->More(); it->Next() )
2048 subSO.push_back( it->Value() );
2050 for ( size_t i = 0; i < subSO.size(); ++i )
2052 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
2053 for ( size_t j = 0; j < aReferences.size(); j++ ) {
2054 _PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
2055 std::string type = aComponent->ComponentDataType();
2056 if ( type != "SMESH" )
2058 SUIT_MessageBox::warning( anApp->desktop(),
2059 QObject::tr("WRN_WARNING"),
2060 QObject::tr("DEP_OBJECT") );
2061 return; // outside SMESH, there is an object depending on a SMESH object
2067 // Treat SO's in the list starting from the back
2068 aStudyBuilder->NewCommand(); // There is a transaction
2069 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2071 _PTR(SObject) SO = *ritSO;
2072 if ( !SO ) continue;
2073 std::string anEntry = SO->GetID();
2075 /** Erase graphical object and remove all its data **/
2076 if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
2077 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
2079 /** Remove an object from data structures **/
2080 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
2081 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
2082 if ( !aGroup->_is_nil() ) { // DELETE GROUP
2083 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
2084 aMesh->RemoveGroup( aGroup );
2086 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
2087 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2088 aMesh->RemoveSubMesh( aSubMesh );
2091 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
2092 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
2093 QString objType = CheckTypeObject(IObject);
2094 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
2095 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2096 aStudyBuilder->RemoveObjectWithChildren( SO );
2098 else {// default action: remove SObject from the study
2099 // Find Sub-Meshes and Group and delete corresopning visual objects and actors
2100 _PTR(ChildIterator) it1 = aStudy->NewChildIterator(SO);
2101 for (it1->InitEx(false); it1->More(); it1->Next()) {
2102 _PTR(SObject) SObj = it1->Value();
2103 if (!SObj) continue;
2104 if (SObj->FindAttribute(anAttr, "AttributeIOR")) {
2105 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(SMESH::SObjectToObject(SObj));
2106 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(SMESH::SObjectToObject(SObj));
2107 if (!aGroup->_is_nil() || !aSubMesh->_is_nil()) {
2108 SMESH::RemoveVisualObjectWithActors(SObj->GetID().c_str(), true);
2112 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2113 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2115 aStudyBuilder->RemoveObjectWithChildren( SO );
2119 } /* listSO back loop */
2121 aStudyBuilder->CommitCommand();
2123 /* Clear any previous selection */
2125 aSel->setSelectedObjects( l1 );
2127 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2131 SMESHGUI_EXPORT CAM_Module* createModule()
2133 return new SMESHGUI();
2136 SMESHGUI_EXPORT char* getModuleVersion() {
2137 return (char*)SMESH_VERSION_STR;
2141 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2143 //=============================================================================
2147 //=============================================================================
2148 SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" )
2150 if ( CORBA::is_nil( myComponentSMESH ) )
2152 CORBA::Boolean anIsEmbeddedMode;
2153 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2155 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2157 // 0019923: EDF 765 SMESH : default values of hypothesis
2158 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2159 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2160 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2161 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2162 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2164 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2165 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2166 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2168 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2169 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2173 myActiveDialogBox = 0;
2174 myFilterLibraryDlg = 0;
2178 myEventCallbackCommand = vtkCallbackCommand::New();
2179 myEventCallbackCommand->Delete();
2180 myEventCallbackCommand->SetClientData( this );
2181 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2184 /* load resources for all available meshers */
2185 SMESH::InitAvailableHypotheses();
2188 //=============================================================================
2192 //=============================================================================
2193 SMESHGUI::~SMESHGUI()
2197 //=============================================================================
2201 //=============================================================================
2202 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2204 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2206 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2211 //=============================================================================
2215 //=============================================================================
2216 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2218 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2222 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2223 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2224 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2225 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2226 return autoUpdate && !exceeded;
2229 //=============================================================================
2233 //=============================================================================
2234 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2235 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2237 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2241 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2242 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2243 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2245 SMESH::smIdType_array_var info = theMesh->GetMeshInfo();
2246 long nbOdElems = info[SMDSEntity_0D];
2247 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2248 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2249 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2250 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2251 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2252 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2253 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2254 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2255 info[SMDSEntity_Polyhedra] +
2256 info[SMDSEntity_Hexagonal_Prism];
2257 long nbBalls = info[SMDSEntity_Ball];
2259 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2260 *nbElements = requestedSize;
2262 *entities = SMESH_Actor::eAllEntity;
2265 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2267 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2269 if ( incrementalLimit ) {
2272 if ( nbOdElems > 0 ) {
2273 if ( total + nbOdElems > updateLimit ) {
2274 *entities = *entities & ~SMESH_Actor::e0DElements;
2275 *hidden = *hidden | SMESH_Actor::e0DElements;
2282 if ( nbEdges > 0 ) {
2283 if ( total + nbEdges > updateLimit ) {
2284 *entities = *entities & ~SMESH_Actor::eEdges;
2285 *hidden = *hidden | SMESH_Actor::eEdges;
2292 if ( nbFaces > 0 ) {
2293 if ( total + nbFaces > updateLimit ) {
2294 *entities = *entities & ~SMESH_Actor::eFaces;
2295 *hidden = *hidden | SMESH_Actor::eFaces;
2302 if ( nbVolumes > 0 ) {
2303 if ( total + nbVolumes > updateLimit ) {
2304 *entities = *entities & ~SMESH_Actor::eVolumes;
2305 *hidden = *hidden | SMESH_Actor::eVolumes;
2312 if ( nbBalls > 0 ) {
2313 if ( total + nbBalls > updateLimit ) {
2314 *entities = *entities & ~SMESH_Actor::eBallElem;
2315 *hidden = *hidden | SMESH_Actor::eBallElem;
2323 return autoUpdate && !exceeded;
2326 //=============================================================================
2330 //=============================================================================
2331 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2333 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2336 //=============================================================================
2340 //=============================================================================
2341 SMESHGUI* SMESHGUI::GetSMESHGUI()
2343 SMESHGUI* smeshMod = 0;
2344 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2347 CAM_Module* module = app->module( "Mesh" );
2348 smeshMod = dynamic_cast<SMESHGUI*>( module );
2356 Standard_EXPORT SMESHGUI* GetComponentGUI()
2358 return SMESHGUI::GetSMESHGUI();
2362 //=============================================================================
2366 //=============================================================================
2367 void SMESHGUI::SetState(int aState)
2372 //=============================================================================
2376 //=============================================================================
2377 void SMESHGUI::ResetState()
2382 //=============================================================================
2386 //=============================================================================
2387 void SMESHGUI::EmitSignalDeactivateDialog()
2389 emit SignalDeactivateActiveDialog();
2392 //=============================================================================
2396 //=============================================================================
2397 void SMESHGUI::EmitSignalStudyFrameChanged()
2399 emit SignalStudyFrameChanged();
2402 //=============================================================================
2406 //=============================================================================
2407 void SMESHGUI::EmitSignalCloseAllDialogs()
2409 emit SignalCloseAllDialogs();
2412 //=============================================================================
2416 //=============================================================================
2417 void SMESHGUI::EmitSignalVisibilityChanged()
2419 emit SignalVisibilityChanged();
2422 //=============================================================================
2426 //=============================================================================
2427 void SMESHGUI::EmitSignalCloseView()
2429 emit SignalCloseView();
2432 //=============================================================================
2436 //=============================================================================
2437 void SMESHGUI::EmitSignalActivatedViewManager()
2439 emit SignalActivatedViewManager();
2442 //=============================================================================
2446 //=============================================================================
2447 QDialog *SMESHGUI::GetActiveDialogBox()
2449 return myActiveDialogBox;
2452 //=============================================================================
2456 //=============================================================================
2457 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2459 myActiveDialogBox = (QDialog *) aDlg;
2463 //=============================================================================
2467 //=============================================================================
2468 SUIT_Desktop* SMESHGUI::desktop()
2470 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2472 return app->desktop();
2477 //=============================================================================
2481 //=============================================================================
2482 SalomeApp_Study* SMESHGUI::activeStudy()
2484 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2486 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2491 //=============================================================================
2495 //=============================================================================
2496 void SMESHGUI::Modified( bool theIsUpdateActions )
2498 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2499 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2500 appStudy->Modified();
2501 if( theIsUpdateActions )
2502 app->updateActions();
2507 //=============================================================================
2511 //=============================================================================
2512 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2514 /* Here the position is on the bottom right corner - 10 */
2515 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2517 SUIT_Desktop *PP = desktop();
2518 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2519 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2524 * \brief Verifies whether study of operation is locked
2525 * \param theMess - specifies whether message box must be shown if study is locked
2526 * \return State of study.
2528 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2529 * is locked when corresponding message box appears
2531 bool SMESHGUI::isStudyLocked( bool theMessage )
2533 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2536 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2537 QObject::tr( "WRN_WARNING" ),
2538 QObject::tr( "WRN_STUDY_LOCKED" ) );
2544 //=============================================================================
2548 //=============================================================================
2549 bool SMESHGUI::OnGUIEvent( int theCommandID )
2551 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2555 SUIT_ResourceMgr* mgr = resourceMgr();
2559 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2560 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2562 //QAction* act = action( theCommandID );
2563 bool logAction(false);
2565 switch (theCommandID) {
2566 case SMESHOp::OpDelete:
2567 if(isStudyLocked()) break;
2570 case SMESHOp::OpImportDAT:
2571 case SMESHOp::OpImportUNV:
2572 case SMESHOp::OpImportMED:
2573 case SMESHOp::OpImportSTL:
2574 case SMESHOp::OpImportCGNS:
2575 case SMESHOp::OpImportGMF:
2576 case SMESHOp::OpPopupImportDAT:
2577 case SMESHOp::OpPopupImportUNV:
2578 case SMESHOp::OpPopupImportMED:
2579 case SMESHOp::OpPopupImportSTL:
2580 case SMESHOp::OpPopupImportCGNS:
2581 case SMESHOp::OpPopupImportGMF:
2583 if(isStudyLocked()) break;
2584 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2588 case SMESHOp::OpFileInformation:
2590 SALOME_ListIO selected;
2591 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2593 aSel->selectedObjects( selected );
2594 if( selected.Extent() )
2596 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2597 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2598 if ( !aMesh->_is_nil() )
2600 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2606 case SMESHOp::OpExportDAT:
2607 case SMESHOp::OpExportMED:
2608 case SMESHOp::OpExportUNV:
2609 case SMESHOp::OpExportSTL:
2610 case SMESHOp::OpExportCGNS:
2611 case SMESHOp::OpExportGMF:
2612 case SMESHOp::OpPopupExportDAT:
2613 case SMESHOp::OpPopupExportMED:
2614 case SMESHOp::OpPopupExportUNV:
2615 case SMESHOp::OpPopupExportSTL:
2616 case SMESHOp::OpPopupExportCGNS:
2617 case SMESHOp::OpPopupExportGMF:
2619 ::ExportMeshToFile(theCommandID);
2623 case SMESHOp::OpReset: // SCALAR BAR
2625 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2626 SALOME_ListIO selected;
2628 aSel->selectedObjects( selected );
2630 SALOME_ListIteratorOfListIO it(selected);
2631 for( ; it.More(); it.Next()) {
2632 Handle(SALOME_InteractiveObject) anIO = it.Value();
2633 if( anIO->hasEntry() ) {
2634 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2635 anActor->SetControlMode( SMESH_Actor::eNone );
2636 #ifndef DISABLE_PLOT2DVIEWER
2637 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2639 anActor->UpdateFilter();
2643 SMESH::UpdateView();
2646 case SMESHOp::OpScalarBarProperties:
2648 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2651 case SMESHOp::OpShowScalarBar:
2653 // show/hide scalar bar
2654 ::ShowElement(theCommandID);
2657 case SMESHOp::OpSaveDistribution:
2659 // dump control distribution data to the text file
2660 ::SaveDistribution();
2664 case SMESHOp::OpShowDistribution:
2666 // show/hide distribution
2667 ::ShowElement(theCommandID);
2671 #ifndef DISABLE_PLOT2DVIEWER
2672 case SMESHOp::OpPlotDistribution:
2674 // plot distribution
2675 ::PlotDistribution();
2681 case SMESHOp::OpAutoColor:
2685 case SMESHOp::OpDisableAutoColor:
2686 ::DisableAutoColor();
2689 case SMESHOp::OpClipping:
2690 case SMESHOp::OpTransparency:
2691 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2694 case SMESHOp::OpDMWireframe:
2695 case SMESHOp::OpDMShading:
2696 case SMESHOp::OpDMNodes:
2697 case SMESHOp::OpDMShrink:
2698 ::SetDisplayMode(theCommandID, myMarkerMap);
2701 //2D quadratic representation
2702 case SMESHOp::OpRepresentationLines:
2703 case SMESHOp::OpRepresentationArcs:
2704 ::SetDisplayMode(theCommandID, myMarkerMap);
2708 case SMESHOp::OpDE0DElements:
2709 case SMESHOp::OpDEEdges:
2710 case SMESHOp::OpDEFaces:
2711 case SMESHOp::OpDEVolumes:
2712 case SMESHOp::OpDEBalls:
2713 case SMESHOp::OpDEAllEntity:
2714 ::SetDisplayEntity(theCommandID);
2717 // Choose entities to be displayed
2718 case SMESHOp::OpDEChoose:
2720 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2724 case SMESHOp::OpOrientationOnFaces:
2726 SUIT_OverrideCursor wc;
2727 LightApp_SelectionMgr* mgr = selectionMgr();
2728 SALOME_ListIO selected; mgr->selectedObjects( selected );
2730 SALOME_ListIteratorOfListIO it(selected);
2731 for( ; it.More(); it.Next()) {
2732 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2733 if(anIObject->hasEntry()) {
2734 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2735 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2742 case SMESHOp::OpUpdate:
2744 if(isStudyLocked()) break;
2745 SUIT_OverrideCursor wc;
2748 SMESH::UpdateView();
2750 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2751 SMESH::OnVisuException();
2753 catch (...) { // PAL16774 (Crash after display of many groups)
2754 SMESH::OnVisuException();
2758 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2759 aSel->selectedObjects( l );
2760 aSel->setSelectedObjects( l );
2764 case SMESHOp::OpHide:
2765 case SMESHOp::OpShow:
2766 case SMESHOp::OpShowOnly:
2768 SUIT_OverrideCursor wc;
2769 SMESH::EDisplaing anAction;
2770 switch (theCommandID) {
2771 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2772 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2773 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2776 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2777 SALOME_ListIO sel_objects, to_process;
2779 aSel->selectedObjects( sel_objects );
2781 if ( theCommandID==SMESHOp::OpShowOnly )
2783 //MESSAGE("anAction = SMESH::eDisplayOnly");
2784 startOperation( myEraseAll );
2787 extractContainers( sel_objects, to_process );
2792 SALOME_ListIteratorOfListIO It( to_process );
2793 for ( ; It.More(); It.Next())
2795 Handle(SALOME_InteractiveObject) IOS = It.Value();
2796 if ( IOS->hasEntry() )
2798 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2799 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2800 break; // PAL16774 (Crash after display of many groups)
2802 if (anAction == SMESH::eDisplayOnly)
2803 anAction = SMESH::eDisplay;
2808 // PAL13338 + PAL15161 -->
2809 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2810 SMESH::UpdateView();
2811 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2813 // PAL13338 + PAL15161 <--
2815 catch (...) { // PAL16774 (Crash after display of many groups)
2816 SMESH::OnVisuException();
2819 if (anAction == SMESH::eErase) {
2821 aSel->setSelectedObjects( l1 );
2824 aSel->setSelectedObjects( to_process );
2826 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2827 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2828 vtkwnd->GetRenderer()->AdjustActors();
2833 case SMESHOp::OpNode:
2835 if(isStudyLocked()) break;
2838 EmitSignalDeactivateDialog();
2840 ( new SMESHGUI_NodesDlg( this ) )->show();
2843 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2848 case SMESHOp::OpEditMeshOrSubMesh:
2849 case SMESHOp::OpEditMesh:
2850 case SMESHOp::OpEditSubMesh:
2851 case SMESHOp::OpMeshOrder:
2852 case SMESHOp::OpCreateSubMesh:
2853 if ( warnOnGeomModif() )
2854 break; // action forbidden as geometry modified
2856 case SMESHOp::OpCreateMesh:
2857 case SMESHOp::OpCompute:
2858 case SMESHOp::OpComputeSubMesh:
2859 case SMESHOp::OpPreCompute:
2860 case SMESHOp::OpEvaluate:
2861 case SMESHOp::OpShowErrors:
2862 startOperation( theCommandID );
2864 case SMESHOp::OpRecompute:
2866 if ( isStudyLocked() )
2868 SALOME_ListIO selected;
2869 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2870 sel->selectedObjects( selected );
2871 if ( selected.Extent() == 1 ) {
2872 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2873 if ( !aMesh->_is_nil() )
2875 startOperation( SMESHOp::OpCompute );
2879 case SMESHOp::OpCopyMesh:
2882 if (isStudyLocked()) break;
2883 EmitSignalDeactivateDialog();
2884 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2887 case SMESHOp::OpBuildCompoundMesh:
2889 if (isStudyLocked()) break;
2890 EmitSignalDeactivateDialog();
2891 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2895 case SMESHOp::OpDiagonalInversion:
2896 case SMESHOp::OpUnionOfTwoTriangle:
2900 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2904 if ( isStudyLocked() )
2906 if ( warnOnGeomModif() )
2907 break; // action forbidden as geometry modified
2909 /*Standard_Boolean aRes;
2910 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2911 if ( aMesh->_is_nil() )
2913 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2914 tr( "SMESH_BAD_SELECTION" ) );
2918 EmitSignalDeactivateDialog();
2919 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2920 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2922 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2925 case SMESHOp::OpOrientation:
2926 case SMESHOp::OpUnionOfTriangles:
2927 case SMESHOp::OpCuttingOfQuadrangles:
2928 case SMESHOp::OpSplitVolumes:
2932 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2936 if ( isStudyLocked() )
2938 if ( warnOnGeomModif() )
2939 break; // action forbidden as geometry modified
2941 EmitSignalDeactivateDialog();
2942 SMESHGUI_MultiEditDlg* aDlg = NULL;
2943 if ( theCommandID == SMESHOp::OpOrientation )
2944 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2945 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2946 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2947 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2948 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2950 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2955 case SMESHOp::OpSmoothing:
2957 if(isStudyLocked()) break;
2958 if ( warnOnGeomModif() )
2959 break; // action forbidden as geometry modified
2961 EmitSignalDeactivateDialog();
2962 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2965 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2969 case SMESHOp::OpExtrusion:
2971 if (isStudyLocked()) break;
2972 if ( warnOnGeomModif() )
2973 break; // action forbidden as geometry modified
2975 EmitSignalDeactivateDialog();
2976 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2978 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2982 case SMESHOp::OpExtrusionAlongAPath:
2984 if (isStudyLocked()) break;
2985 if ( warnOnGeomModif() )
2986 break; // action forbidden as geometry modified
2988 EmitSignalDeactivateDialog();
2989 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2991 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2995 case SMESHOp::OpRevolution:
2997 if(isStudyLocked()) break;
2998 if ( warnOnGeomModif() )
2999 break; // action forbidden as geometry modified
3001 EmitSignalDeactivateDialog();
3002 ( new SMESHGUI_RevolutionDlg( this ) )->show();
3005 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3009 case SMESHOp::OpPatternMapping:
3011 if ( isStudyLocked() )
3013 if ( warnOnGeomModif() )
3014 break; // action forbidden as geometry modified
3017 EmitSignalDeactivateDialog();
3018 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3021 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3025 // Adaptation - begin
3026 #ifndef DISABLE_MG_ADAPT
3027 case SMESHOp::OpMGAdapt:
3029 if ( isStudyLocked() )
3031 EmitSignalDeactivateDialog();
3033 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3034 bool isCreation = false;
3035 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3039 #ifndef DISABLE_HOMARD_ADAPT
3040 case SMESHOp::OpHomardAdapt:
3042 if ( isStudyLocked() )
3044 EmitSignalDeactivateDialog();
3046 SALOME::GenericObj_wrap< SMESHHOMARD::HOMARD_Gen > homardGen;
3048 homardGen = GetSMESHGen()->CreateHOMARD_ADAPT();
3050 catch ( const SALOME::SALOME_Exception& S_ex ) {
3051 SUIT_MessageBox::critical(SMESHGUI::desktop(),
3052 QObject::tr("SMESH_ERROR"),
3053 QObject::tr(S_ex.details.text.in()));
3055 if (!homardGen->_is_nil()) {
3056 SMESHGUI_HomardAdaptDlg *aDlg = new SMESHGUI_HomardAdaptDlg(homardGen);
3063 case SMESHOp::OpSplitBiQuadratic:
3064 case SMESHOp::OpConvertMeshToQuadratic:
3065 case SMESHOp::OpCreateDualMesh:
3066 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3067 case SMESHOp::OpCreate2DElements: // create full 2D mesh from 3D
3068 case SMESHOp::OpReorientFaces:
3069 case SMESHOp::OpCreateGeometryGroup:
3071 if ( warnOnGeomModif() )
3072 break; // action forbidden as geometry modified
3073 startOperation( theCommandID );
3076 case SMESHOp::OpCreateGroup:
3080 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3084 if(isStudyLocked()) break;
3085 if ( warnOnGeomModif() )
3086 break; // action forbidden as geometry modified
3087 EmitSignalDeactivateDialog();
3088 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3090 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3091 SALOME_ListIO selected;
3093 aSel->selectedObjects( selected );
3095 int nbSel = selected.Extent();
3097 // check if mesh is selected
3098 aMesh = SMESH::GetMeshByIO( selected.First() );
3100 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3105 case SMESHOp::OpConstructGroup:
3109 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3113 if(isStudyLocked()) break;
3114 if ( warnOnGeomModif() )
3115 break; // action forbidden as geometry modified
3116 EmitSignalDeactivateDialog();
3118 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3119 SALOME_ListIO selected;
3121 aSel->selectedObjects( selected );
3123 int nbSel = selected.Extent();
3125 // check if submesh is selected
3126 Handle(SALOME_InteractiveObject) IObject = selected.First();
3127 if (IObject->hasEntry()) {
3128 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3130 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3131 if (!aSubMesh->_is_nil()) {
3133 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3134 // get submesh elements list by types
3135 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3136 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3137 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3138 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3139 // create group for each type o elements
3140 QString aName = IObject->getName();
3141 QStringList anEntryList;
3142 if (aNodes->length() > 0) {
3143 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3144 aGroup->Add(aNodes.inout());
3145 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3146 anEntryList.append( aSObject->GetID().c_str() );
3148 if (aEdges->length() > 0) {
3149 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3150 aGroup->Add(aEdges.inout());
3151 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3152 anEntryList.append( aSObject->GetID().c_str() );
3154 if (aFaces->length() > 0) {
3155 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3156 aGroup->Add(aFaces.inout());
3157 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3158 anEntryList.append( aSObject->GetID().c_str() );
3160 if (aVolumes->length() > 0) {
3161 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3162 aGroup->Add(aVolumes.inout());
3163 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3164 anEntryList.append( aSObject->GetID().c_str() );
3167 anApp->browseObjects( anEntryList );
3169 catch(const SALOME::SALOME_Exception & S_ex){
3170 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3177 SUIT_MessageBox::warning(desktop(),
3178 tr("SMESH_WRN_WARNING"),
3179 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3184 case SMESHOp::OpEditGroup:
3188 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3192 if(isStudyLocked()) break;
3193 if ( warnOnGeomModif() )
3194 break; // action forbidden as geometry modified
3195 EmitSignalDeactivateDialog();
3197 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3198 SALOME_ListIO selected;
3200 aSel->selectedObjects( selected );
3202 SALOME_ListIteratorOfListIO It (selected);
3203 int nbSelectedGroups = 0;
3204 for ( ; It.More(); It.Next() )
3206 SMESH::SMESH_GroupBase_var aGroup =
3207 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3208 if (!aGroup->_is_nil()) {
3210 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3214 if (nbSelectedGroups == 0)
3216 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3222 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3224 if(isStudyLocked()) break;
3225 if (myState == 800) {
3226 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3227 if (aDlg) aDlg->onAdd();
3232 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3234 if(isStudyLocked()) break;
3235 if (myState == 800) {
3236 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3237 if (aDlg) aDlg->onRemove();
3242 case SMESHOp::OpEditGeomGroupAsGroup:
3246 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3250 if(isStudyLocked()) break;
3251 EmitSignalDeactivateDialog();
3253 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3254 SALOME_ListIO selected;
3256 aSel->selectedObjects( selected );
3258 SALOME_ListIteratorOfListIO It (selected);
3259 for ( ; It.More(); It.Next() )
3261 SMESH::SMESH_GroupOnGeom_var aGroup =
3262 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3263 if (!aGroup->_is_nil()) {
3264 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3269 SMESH::SMESH_GroupOnFilter_var aGroup =
3270 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3271 if (!aGroup->_is_nil()) {
3272 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3280 case SMESHOp::OpUnionGroups:
3281 case SMESHOp::OpIntersectGroups:
3282 case SMESHOp::OpCutGroups:
3286 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3290 if ( isStudyLocked() )
3292 if ( warnOnGeomModif() )
3293 break; // action forbidden as geometry modified
3295 EmitSignalDeactivateDialog();
3297 SMESHGUI_GroupOpDlg* aDlg = 0;
3298 if ( theCommandID == SMESHOp::OpUnionGroups )
3299 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3300 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3301 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3303 aDlg = new SMESHGUI_CutGroupsDlg( this );
3310 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3312 if ( isStudyLocked() )
3314 if ( warnOnGeomModif() )
3315 break; // action forbidden as geometry modified
3317 EmitSignalDeactivateDialog();
3318 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3324 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3326 if ( isStudyLocked() )
3328 if ( warnOnGeomModif() )
3329 break; // action forbidden as geometry modified
3331 EmitSignalDeactivateDialog();
3332 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3338 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3342 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3346 if ( isStudyLocked() )
3349 EmitSignalDeactivateDialog();
3351 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3355 case SMESHOp::OpMeshInformation:
3356 case SMESHOp::OpWhatIs:
3358 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3359 EmitSignalDeactivateDialog();
3360 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3361 SALOME_ListIO selected;
3363 aSel->selectedObjects( selected );
3365 if ( selected.Extent() > 1 ) { // a dlg for each IO
3366 SALOME_ListIteratorOfListIO It( selected );
3367 for ( ; It.More(); It.Next() ) {
3368 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3369 dlg->showInfo( It.Value() );
3374 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3380 case SMESHOp::OpFindElementByPoint:
3382 startOperation( theCommandID );
3386 case SMESHOp::OpEditHypothesis:
3388 if(isStudyLocked()) break;
3389 if ( warnOnGeomModif() )
3390 break; // action forbidden as geometry modified
3392 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3393 SALOME_ListIO selected;
3395 aSel->selectedObjects( selected );
3397 int nbSel = selected.Extent();
3400 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3401 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3403 if ( !aHypothesis->_is_nil() )
3405 SMESHGUI_GenericHypothesisCreator* aCreator =
3406 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3409 // set geometry of mesh and sub-mesh to aCreator
3410 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3411 if ( selected.Extent() == 1 )
3413 QString subGeomID, meshGeomID;
3414 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3415 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3417 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3418 aCreator->setShapeEntry( subGeomID );
3419 aCreator->setMainShapeEntry( meshGeomID );
3423 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3433 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3435 if(isStudyLocked()) break;
3436 if ( warnOnGeomModif() )
3437 break; // action forbidden as geometry modified
3438 SUIT_OverrideCursor wc;
3440 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3441 SALOME_ListIO selected;
3443 aSel->selectedObjects( selected, QString::null, false );
3445 SALOME_ListIteratorOfListIO It(selected);
3446 for (int i = 0; It.More(); It.Next(), i++) {
3447 Handle(SALOME_InteractiveObject) IObject = It.Value();
3448 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3451 aSel->setSelectedObjects( l1 );
3456 case SMESHOp::OpElem0D:
3457 case SMESHOp::OpBall:
3458 case SMESHOp::OpEdge:
3459 case SMESHOp::OpTriangle:
3460 case SMESHOp::OpQuadrangle:
3461 case SMESHOp::OpPolygon:
3462 case SMESHOp::OpTetrahedron:
3463 case SMESHOp::OpHexahedron:
3464 case SMESHOp::OpPentahedron:
3465 case SMESHOp::OpPyramid:
3466 case SMESHOp::OpHexagonalPrism:
3468 if(isStudyLocked()) break;
3469 if ( warnOnGeomModif() )
3470 break; // action forbidden as geometry modified
3472 EmitSignalDeactivateDialog();
3473 SMDSAbs_EntityType type = SMDSEntity_Edge;
3474 switch (theCommandID) {
3475 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3476 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3477 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3478 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3479 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3480 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3481 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3482 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3483 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3484 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3487 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3490 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3494 case SMESHOp::OpPolyhedron:
3496 if(isStudyLocked()) break;
3497 if ( warnOnGeomModif() )
3498 break; // action forbidden as geometry modified
3500 EmitSignalDeactivateDialog();
3501 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3504 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3508 case SMESHOp::OpQuadraticEdge:
3509 case SMESHOp::OpQuadraticTriangle:
3510 case SMESHOp::OpBiQuadraticTriangle:
3511 case SMESHOp::OpQuadraticQuadrangle:
3512 case SMESHOp::OpBiQuadraticQuadrangle:
3513 case SMESHOp::OpQuadraticPolygon:
3514 case SMESHOp::OpQuadraticTetrahedron:
3515 case SMESHOp::OpQuadraticPyramid:
3516 case SMESHOp::OpQuadraticPentahedron:
3517 case SMESHOp::OpBiQuadraticPentahedron:
3518 case SMESHOp::OpQuadraticHexahedron:
3519 case SMESHOp::OpTriQuadraticHexahedron:
3521 if(isStudyLocked()) break;
3522 if ( warnOnGeomModif() )
3523 break; // action forbidden as geometry modified
3525 EmitSignalDeactivateDialog();
3526 SMDSAbs_EntityType type = SMDSEntity_Last;
3528 switch (theCommandID) {
3529 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3530 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3531 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3532 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3533 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3534 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3535 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3536 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3537 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3538 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3539 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3540 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3543 if ( type != SMDSEntity_Last )
3544 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3547 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3548 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3552 case SMESHOp::OpRemoveNodes:
3554 if(isStudyLocked()) break;
3555 if ( warnOnGeomModif() )
3556 break; // action forbidden as geometry modified
3558 EmitSignalDeactivateDialog();
3559 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3562 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3563 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3567 case SMESHOp::OpRemoveNodeWithReconn:
3569 if(isStudyLocked()) break;
3570 if ( warnOnGeomModif() )
3571 break; // action forbidden as geometry modified
3572 startOperation( SMESHOp::OpRemoveNodeWithReconn );
3575 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3577 if(isStudyLocked()) break;
3578 if ( warnOnGeomModif() )
3579 break; // action forbidden as geometry modified
3581 EmitSignalDeactivateDialog();
3582 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3586 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3587 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3591 case SMESHOp::OpClearMesh: {
3593 if(isStudyLocked()) break;
3594 if ( warnOnGeomModif() )
3595 break; // action forbidden as geometry modified
3597 SALOME_ListIO selected;
3598 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3599 aSel->selectedObjects( selected );
3601 SUIT_OverrideCursor wc;
3602 SALOME_ListIteratorOfListIO It (selected);
3603 for ( ; It.More(); It.Next() )
3605 Handle(SALOME_InteractiveObject) IOS = It.Value();
3606 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3607 if ( aMesh->_is_nil()) continue;
3610 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3611 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3612 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3613 // hide groups and submeshes
3614 _PTR(ChildIterator) anIter =
3615 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3616 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3618 _PTR(SObject) so = anIter->Value();
3619 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3622 catch (const SALOME::SALOME_Exception& S_ex){
3624 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3628 SMESH::UpdateView();
3632 case SMESHOp::OpRemoveOrphanNodes:
3634 if(isStudyLocked()) break;
3635 if ( warnOnGeomModif() )
3636 break; // action forbidden as geometry modified
3637 SALOME_ListIO selected;
3638 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3639 aSel->selectedObjects( selected );
3640 if ( selected.Extent() == 1 ) {
3641 Handle(SALOME_InteractiveObject) anIO = selected.First();
3642 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3643 if ( !aMesh->_is_nil() ) {
3644 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3645 tr( "SMESH_WARNING" ),
3646 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3647 SUIT_MessageBox::Yes |
3648 SUIT_MessageBox::No,
3649 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3652 SUIT_OverrideCursor wc;
3653 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3654 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3655 SUIT_MessageBox::information(SMESHGUI::desktop(),
3656 tr("SMESH_INFORMATION"),
3657 tr("NB_NODES_REMOVED").arg(removed));
3658 if ( removed > 0 ) {
3659 SMESH::UpdateView();
3660 SMESHGUI::Modified();
3663 catch (const SALOME::SALOME_Exception& S_ex) {
3664 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3673 case SMESHOp::OpRenumberingNodes:
3675 if(isStudyLocked()) break;
3676 if ( warnOnGeomModif() )
3677 break; // action forbidden as geometry modified
3679 EmitSignalDeactivateDialog();
3680 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3684 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3685 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3689 case SMESHOp::OpRenumberingElements:
3691 if(isStudyLocked()) break;
3692 if ( warnOnGeomModif() )
3693 break; // action forbidden as geometry modified
3695 EmitSignalDeactivateDialog();
3696 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3700 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3701 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3705 case SMESHOp::OpTranslation:
3708 if(isStudyLocked()) break;
3709 if ( warnOnGeomModif() )
3710 break; // action forbidden as geometry modified
3712 EmitSignalDeactivateDialog();
3713 ( new SMESHGUI_TranslationDlg( this ) )->show();
3716 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3717 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3721 case SMESHOp::OpRotation:
3724 if(isStudyLocked()) break;
3725 if ( warnOnGeomModif() )
3726 break; // action forbidden as geometry modified
3728 EmitSignalDeactivateDialog();
3729 ( new SMESHGUI_RotationDlg( this ) )->show();
3732 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3733 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3737 case SMESHOp::OpSymmetry:
3740 if(isStudyLocked()) break;
3741 if ( warnOnGeomModif() )
3742 break; // action forbidden as geometry modified
3744 EmitSignalDeactivateDialog();
3745 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3748 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3749 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3753 case SMESHOp::OpScale:
3756 if(isStudyLocked()) break;
3757 if ( warnOnGeomModif() )
3758 break; // action forbidden as geometry modified
3760 EmitSignalDeactivateDialog();
3761 ( new SMESHGUI_ScaleDlg( this ) )->show();
3764 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3765 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3770 case SMESHOp::OpOffset:
3773 if(isStudyLocked()) break;
3774 if ( warnOnGeomModif() )
3775 break; // action forbidden as geometry modified
3777 EmitSignalDeactivateDialog();
3778 ( new SMESHGUI_OffsetDlg( this ) )->show();
3781 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3782 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3787 case SMESHOp::OpSewing:
3790 if(isStudyLocked()) break;
3791 if ( warnOnGeomModif() )
3792 break; // action forbidden as geometry modified
3794 EmitSignalDeactivateDialog();
3795 ( new SMESHGUI_SewingDlg( this ) )->show();
3798 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3799 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3803 case SMESHOp::OpMergeNodes:
3805 if(isStudyLocked()) break;
3806 if ( warnOnGeomModif() )
3807 break; // action forbidden as geometry modified
3809 EmitSignalDeactivateDialog();
3810 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3813 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3814 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3818 case SMESHOp::OpMergeElements:
3820 if (isStudyLocked()) break;
3821 if ( warnOnGeomModif() )
3822 break; // action forbidden as geometry modified
3824 EmitSignalDeactivateDialog();
3825 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3827 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3828 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3833 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3834 if ( warnOnGeomModif() )
3835 break; // action forbidden as geometry modified
3836 startOperation( SMESHOp::OpMoveNode );
3839 case SMESHOp::OpMoveNodeInteractive:
3840 if ( warnOnGeomModif() )
3841 break; // action forbidden as geometry modified
3842 startOperation( SMESHOp::OpMoveNodeInteractive );
3845 case SMESHOp::OpSplitEdgeInteract:
3846 if ( warnOnGeomModif() )
3847 break; // action forbidden as geometry modified
3848 startOperation( SMESHOp::OpSplitEdgeInteract );
3851 case SMESHOp::OpSplitFaceInteract:
3852 if ( warnOnGeomModif() )
3853 break; // action forbidden as geometry modified
3854 startOperation( SMESHOp::OpSplitFaceInteract );
3857 case SMESHOp::OpDuplicateNodes:
3859 if(isStudyLocked()) break;
3860 if ( warnOnGeomModif() )
3861 break; // action forbidden as geometry modified
3863 EmitSignalDeactivateDialog();
3864 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3867 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3868 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3873 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3874 if ( warnOnGeomModif() )
3875 break; // action forbidden as geometry modified
3876 startOperation( SMESHOp::OpElem0DOnElemNodes );
3879 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3881 static QList<int> aTypes;
3882 if ( aTypes.isEmpty() )
3884 aTypes.append( SMESH::NODE );
3885 aTypes.append( SMESH::EDGE );
3886 aTypes.append( SMESH::FACE );
3887 aTypes.append( SMESH::VOLUME );
3889 if (!myFilterLibraryDlg)
3890 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3891 else if (myFilterLibraryDlg->isHidden())
3892 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3893 myFilterLibraryDlg->raise();
3897 case SMESHOp::OpFreeNode:
3898 case SMESHOp::OpEqualNode:
3899 case SMESHOp::OpNodeConnectivityNb:
3900 case SMESHOp::OpFreeEdge:
3901 case SMESHOp::OpFreeBorder:
3902 case SMESHOp::OpLength:
3903 case SMESHOp::OpConnection:
3904 case SMESHOp::OpEqualEdge:
3905 case SMESHOp::OpFreeFace:
3906 case SMESHOp::OpBareBorderFace:
3907 case SMESHOp::OpOverConstrainedFace:
3908 case SMESHOp::OpLength2D:
3909 case SMESHOp::OpDeflection2D:
3910 case SMESHOp::OpConnection2D:
3911 case SMESHOp::OpArea:
3912 case SMESHOp::OpTaper:
3913 case SMESHOp::OpAspectRatio:
3914 case SMESHOp::OpMinimumAngle:
3915 case SMESHOp::OpWarpingAngle:
3916 case SMESHOp::OpSkew:
3917 case SMESHOp::OpMaxElementLength2D:
3918 case SMESHOp::OpEqualFace:
3919 case SMESHOp::OpAspectRatio3D:
3920 case SMESHOp::OpWarping3D:
3921 case SMESHOp::OpVolume:
3922 case SMESHOp::OpScaledJacobian:
3923 case SMESHOp::OpMaxElementLength3D:
3924 case SMESHOp::OpBareBorderVolume:
3925 case SMESHOp::OpOverConstrainedVolume:
3926 case SMESHOp::OpEqualVolume:
3929 LightApp_SelectionMgr* mgr = selectionMgr();
3930 SALOME_ListIO selected; mgr->selectedObjects( selected );
3932 if( !selected.IsEmpty() ) {
3933 SUIT_OverrideCursor wc;
3934 ::Control( theCommandID );
3937 SUIT_MessageBox::warning(desktop(),
3938 tr( "SMESH_WRN_WARNING" ),
3939 tr( "SMESH_BAD_SELECTION" ) );
3943 SUIT_MessageBox::warning(desktop(),
3944 tr( "SMESH_WRN_WARNING" ),
3945 tr( "NOT_A_VTK_VIEWER" ) );
3948 case SMESHOp::OpOverallMeshQuality:
3949 OverallMeshQuality();
3951 case SMESHOp::OpNumberingNodes:
3953 SUIT_OverrideCursor wc;
3954 LightApp_SelectionMgr* mgr = selectionMgr();
3955 SALOME_ListIO selected; mgr->selectedObjects( selected );
3957 SALOME_ListIteratorOfListIO it(selected);
3958 for( ; it.More(); it.Next()) {
3959 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3960 if(anIObject->hasEntry()) {
3961 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3962 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3968 case SMESHOp::OpNumberingElements:
3970 SUIT_OverrideCursor wc;
3971 LightApp_SelectionMgr* mgr = selectionMgr();
3972 SALOME_ListIO selected; mgr->selectedObjects( selected );
3974 SALOME_ListIteratorOfListIO it(selected);
3975 for( ; it.More(); it.Next()) {
3976 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3977 if(anIObject->hasEntry())
3978 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3979 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3984 case SMESHOp::OpPropertiesLength:
3985 case SMESHOp::OpPropertiesArea:
3986 case SMESHOp::OpPropertiesVolume:
3987 case SMESHOp::OpMinimumDistance:
3988 case SMESHOp::OpBoundingBox:
3989 case SMESHOp::OpAngle:
3991 int page = SMESHGUI_MeasureDlg::MinDistance;
3992 if ( theCommandID == SMESHOp::OpBoundingBox )
3993 page = SMESHGUI_MeasureDlg::BoundingBox;
3994 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3995 page = SMESHGUI_MeasureDlg::Length;
3996 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3997 page = SMESHGUI_MeasureDlg::Area;
3998 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3999 page = SMESHGUI_MeasureDlg::Volume;
4000 else if ( theCommandID == SMESHOp::OpAngle )
4001 page = SMESHGUI_MeasureDlg::Angle;
4003 EmitSignalDeactivateDialog();
4004 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
4008 case SMESHOp::OpSortChild:
4011 case SMESHOp::OpBreakLink:
4012 ::breakShaperLink();
4017 anApp->updateActions(); //SRN: To update a Save button in the toolbar
4018 //updateObjBrowser();
4021 QAction* anAction = action( theCommandID );
4022 CAM_Application::logStructuredUserEvent( "Mesh",
4030 //=============================================================================
4034 //=============================================================================
4035 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4040 //=============================================================================
4044 //=============================================================================
4045 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4050 //=============================================================================
4054 //=============================================================================
4055 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4060 //=============================================================================
4061 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
4062 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
4064 //=============================================================================
4065 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
4066 SUIT_ViewWindow* wnd )
4068 if(theIO->hasEntry()){
4069 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
4070 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
4074 //=======================================================================
4075 // function : createSMESHAction
4077 //=======================================================================
4078 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
4079 const int key, const bool toggle, const QString& shortcutAction )
4082 QWidget* parent = application()->desktop();
4083 SUIT_ResourceMgr* resMgr = resourceMgr();
4085 if ( !icon_id.isEmpty() )
4086 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4088 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4089 if ( !pix.isNull() )
4090 icon = QIcon( pix );
4092 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4093 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4094 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4096 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4097 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4100 //=======================================================================
4101 // function : createPopupItem
4103 //=======================================================================
4104 void SMESHGUI::createPopupItem( const int id,
4105 const QString& clients,
4106 const QString& types,
4107 const QString& theRule,
4110 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4111 popupMgr()->insert( action( id ), pId, 0 );
4113 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4114 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4115 QString rule = "(%1) and (%2) and (%3)";
4116 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4117 if( clients.isEmpty() )
4118 rule = rule.arg( QString( "true" ) );
4120 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4121 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4124 bool cont = myRules.contains( id );
4126 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4128 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4129 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4132 //=======================================================================
4133 // function : initialize
4135 //=======================================================================
4136 void SMESHGUI::initialize( CAM_Application* app )
4138 SalomeApp_Module::initialize( app );
4140 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4142 /* Automatic Update flag */
4143 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4145 // ----- create actions --------------
4147 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4148 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4149 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4150 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4152 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4154 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4155 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4156 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4157 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4159 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4161 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4163 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4164 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4165 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4166 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4168 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4170 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4171 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4172 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4173 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4174 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4176 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4178 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4179 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4180 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4181 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4182 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4183 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4184 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4185 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4186 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4187 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4188 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4189 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4190 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4191 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4192 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4193 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4194 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4195 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4196 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4197 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4198 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4199 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4200 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4201 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4202 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4203 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4204 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4205 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4206 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4207 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4208 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4209 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4210 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4211 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4212 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4214 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4215 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4216 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4217 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4218 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4219 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4220 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4221 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4222 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4223 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4224 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4225 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4226 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4227 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4228 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4229 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4230 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4231 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4232 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4233 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4234 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4235 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4236 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4237 createSMESHAction( SMESHOp::OpWarping3D, "WARP_3D", "ICON_WARP", 0, true);
4238 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4239 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4240 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4241 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4242 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4243 createSMESHAction( SMESHOp::OpScaledJacobian, "SCALED_JACOBIAN", "ICON_SCALED_JACOBIAN", 0, true );
4244 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4246 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4247 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4248 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4249 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4250 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4251 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4252 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4253 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4254 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4255 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4256 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4257 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4258 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4259 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4260 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4261 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4262 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4263 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4264 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4265 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4266 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4267 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4268 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4269 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4270 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4271 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4273 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4274 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4275 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4276 createSMESHAction( SMESHOp::OpRemoveNodeWithReconn, "REMOVE_NODE_RECON", "ICON_REM_NODE_RECON" );
4277 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4279 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4280 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4282 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4283 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4284 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4285 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4286 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4287 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4288 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4289 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4290 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4291 createSMESHAction( SMESHOp::OpMoveNodeInteractive, "MOVE_NODE_INTRCT","ICON_DLG_MOVE_NODE_INTERACTIVE" );
4292 createSMESHAction( SMESHOp::OpSplitEdgeInteract, "SPLIT_DIAG_INTRC","ICON_SPLIT_DIAG_INTERACTIVE" );
4293 createSMESHAction( SMESHOp::OpSplitFaceInteract, "SPLIT_FACE_INTRC","ICON_SPLIT_FACE_INTERACTIVE" );
4294 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4295 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4296 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4297 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4298 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4299 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4300 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4301 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4302 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4303 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4304 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4305 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4306 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4307 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4308 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4309 createSMESHAction( SMESHOp::OpCreateDualMesh, "CREATE_DUAL_MESH","ICON_CREATE_DUAL_MESH" );
4310 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4311 createSMESHAction( SMESHOp::OpCreate2DElements, "2D_FROM_3D_ELEMENTS","ICON_2D_FROM_3D_ELEMENTS" );
4313 createSMESHAction( SMESHOp::OpReset, "RESET" );
4314 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4315 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4316 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4317 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4318 #ifndef DISABLE_PLOT2DVIEWER
4319 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4321 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4322 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4323 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4324 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4325 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4326 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4327 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4328 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4329 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4330 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4331 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4332 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4333 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4335 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4336 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4338 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4339 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4340 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4341 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4342 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4343 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4344 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4345 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4346 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4348 // Adaptation - begin
4349 #ifndef DISABLE_MG_ADAPT
4350 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4352 #ifndef DISABLE_HOMARD_ADAPT
4353 createSMESHAction( SMESHOp::OpHomardAdapt, "HOMARD_ADAPT", "ICON_HOMARD_ADAPT" );
4357 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4358 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4359 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4360 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4361 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4362 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4364 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4365 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4366 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4368 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4370 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4372 QList<int> aCtrlActions;
4373 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4374 << SMESHOp::OpNodeConnectivityNb // node controls
4375 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4376 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4377 << SMESHOp::OpDeflection2D
4378 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4379 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4380 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4381 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4382 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4383 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume << SMESHOp::OpWarping3D
4384 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4385 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume << SMESHOp::OpScaledJacobian; // volume controls
4386 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4387 aCtrlGroup->setExclusive( true );
4388 for( int i = 0; i < aCtrlActions.size(); i++ )
4389 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4391 // ----- create menu --------------
4392 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4393 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4394 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4395 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4396 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4397 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4398 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4399 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4401 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4402 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4404 createMenu( separator(), fileId );
4406 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4407 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4408 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4409 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4410 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4411 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4412 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4413 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4414 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4415 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4416 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4417 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4418 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4420 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4421 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4422 createMenu( SMESHOp::OpImportMED, importId, -1 );
4423 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4425 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4427 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4428 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4429 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4430 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4431 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4433 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4435 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4436 createMenu( separator(), fileId, 10 );
4438 createMenu( SMESHOp::OpDelete, editId, -1 );
4440 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4442 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4443 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4444 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4445 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4446 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4447 createMenu( SMESHOp::OpCreateDualMesh, meshId, -1 );
4448 createMenu( separator(), meshId, -1 );
4449 createMenu( SMESHOp::OpCompute, meshId, -1 );
4450 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4451 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4452 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4453 createMenu( separator(), meshId, -1 );
4454 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4455 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4456 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4457 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4458 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4459 createMenu( separator(), meshId, -1 );
4460 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4461 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4462 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4463 createMenu( separator(), meshId, -1 );
4464 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4465 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4466 createMenu( separator(), meshId, -1 );
4467 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4468 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4469 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4470 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4471 createMenu( separator(), meshId, -1 );
4473 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4474 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4475 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4476 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4477 createMenu( SMESHOp::OpLength, edgeId, -1 );
4478 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4479 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4480 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4481 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4482 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4483 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4484 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4485 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4486 createMenu( SMESHOp::OpArea, faceId, -1 );
4487 createMenu( SMESHOp::OpTaper, faceId, -1 );
4488 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4489 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4490 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4491 createMenu( SMESHOp::OpSkew, faceId, -1 );
4492 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4493 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4494 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4495 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4496 createMenu( SMESHOp::OpWarping3D, volumeId, -1 );
4497 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4498 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4499 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4500 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4501 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4502 createMenu( SMESHOp::OpScaledJacobian, volumeId, -1 );
4503 createMenu( separator(), ctrlId, -1 );
4504 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4505 createMenu( separator(), ctrlId, -1 );
4506 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4508 createMenu( SMESHOp::OpNode, addId, -1 );
4509 createMenu( SMESHOp::OpElem0D, addId, -1 );
4510 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4511 createMenu( SMESHOp::OpBall, addId, -1 );
4512 createMenu( SMESHOp::OpEdge, addId, -1 );
4513 createMenu( SMESHOp::OpTriangle, addId, -1 );
4514 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4515 createMenu( SMESHOp::OpPolygon, addId, -1 );
4516 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4517 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4518 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4519 createMenu( SMESHOp::OpPyramid, addId, -1 );
4520 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4521 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4522 createMenu( separator(), addId, -1 );
4523 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4524 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4525 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4526 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4527 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4528 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4529 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4530 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4531 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4532 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4533 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4534 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4535 createMenu( separator(), addId, -1 );
4536 createMenu( SMESHOp::OpSplitEdgeInteract, addId, -1 );
4537 createMenu( SMESHOp::OpSplitFaceInteract, addId, -1 );
4539 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4540 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4541 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4542 createMenu( SMESHOp::OpRemoveNodeWithReconn, removeId, -1 );
4543 createMenu( separator(), removeId, -1 );
4544 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4545 createMenu( separator(), removeId, -1 );
4546 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4548 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4549 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4551 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4552 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4553 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4554 createMenu( SMESHOp::OpRotation, transfId, -1 );
4555 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4556 createMenu( SMESHOp::OpScale, transfId, -1 );
4557 createMenu( SMESHOp::OpOffset, transfId, -1 );
4558 createMenu( SMESHOp::OpSewing, transfId, -1 );
4559 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4561 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4562 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4563 createMenu( SMESHOp::OpCreate2DElements, modifyId, -1 );
4564 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4565 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4566 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4567 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4568 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4569 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4570 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4571 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4572 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4573 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4574 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4575 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4576 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4577 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4579 // Adaptation - begin
4580 #ifndef DISABLE_MG_ADAPT
4581 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4583 #ifndef DISABLE_HOMARD_ADAPT
4584 createMenu( SMESHOp::OpHomardAdapt, adaptId, -1 );
4588 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4589 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4590 createMenu( SMESHOp::OpAngle, measureId, -1 );
4591 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4592 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4593 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4594 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4596 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4597 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4598 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4599 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4601 // ----- create toolbars --------------
4602 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4603 createTool( SMESHOp::OpCreateMesh, meshTb );
4604 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4605 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4606 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4607 createTool( SMESHOp::OpCopyMesh, meshTb );
4608 createTool( separator(), meshTb );
4609 createTool( SMESHOp::OpCompute, meshTb );
4610 createTool( SMESHOp::OpPreCompute, meshTb );
4611 createTool( SMESHOp::OpEvaluate, meshTb );
4612 createTool( SMESHOp::OpMeshOrder, meshTb );
4614 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4615 createTool( SMESHOp::OpMeshInformation, infoTb );
4616 //createTool( SMESHOp::OpStdInfo, meshTb );
4617 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4618 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4620 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4621 createTool( SMESHOp::OpCreateGroup, groupTb );
4622 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4623 createTool( SMESHOp::OpConstructGroup, groupTb );
4624 createTool( SMESHOp::OpEditGroup, groupTb );
4626 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4627 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4628 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4629 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4631 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4632 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4633 createTool( SMESHOp::OpLength, ctrl1dTb );
4634 createTool( SMESHOp::OpConnection, ctrl1dTb );
4635 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4637 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4638 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4639 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4640 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4641 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4642 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4643 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4644 createTool( SMESHOp::OpArea, ctrl2dTb );
4645 createTool( SMESHOp::OpTaper, ctrl2dTb );
4646 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4647 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4648 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4649 createTool( SMESHOp::OpSkew, ctrl2dTb );
4650 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4651 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4652 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4654 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4655 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4656 createTool( SMESHOp::OpWarping3D, ctrl3dTb );
4657 createTool( SMESHOp::OpVolume, ctrl3dTb );
4658 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4659 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4660 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4661 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4662 createTool( SMESHOp::OpScaledJacobian, ctrl3dTb );
4664 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4665 createTool( SMESHOp::OpNode, addElemTb );
4666 createTool( SMESHOp::OpElem0D, addElemTb );
4667 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4668 createTool( SMESHOp::OpBall, addElemTb );
4669 createTool( SMESHOp::OpEdge, addElemTb );
4670 createTool( SMESHOp::OpTriangle, addElemTb );
4671 createTool( SMESHOp::OpQuadrangle, addElemTb );
4672 createTool( SMESHOp::OpPolygon, addElemTb );
4673 createTool( SMESHOp::OpTetrahedron, addElemTb );
4674 createTool( SMESHOp::OpHexahedron, addElemTb );
4675 createTool( SMESHOp::OpPentahedron, addElemTb );
4676 createTool( SMESHOp::OpPyramid, addElemTb );
4677 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4678 createTool( SMESHOp::OpPolyhedron, addElemTb );
4680 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4681 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4682 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4683 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4684 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4685 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4686 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4687 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4688 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4689 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4690 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4691 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4692 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4694 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4695 createTool( SMESHOp::OpRemoveNodes, remTb );
4696 createTool( SMESHOp::OpRemoveElements, remTb );
4697 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4698 createTool( SMESHOp::OpClearMesh, remTb );
4700 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4701 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4702 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4704 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4705 createTool( SMESHOp::OpMergeNodes, transformTb );
4706 createTool( SMESHOp::OpMergeElements, transformTb );
4707 createTool( SMESHOp::OpTranslation, transformTb );
4708 createTool( SMESHOp::OpRotation, transformTb );
4709 createTool( SMESHOp::OpSymmetry, transformTb );
4710 createTool( SMESHOp::OpScale, transformTb );
4711 createTool( SMESHOp::OpOffset, transformTb );
4712 createTool( SMESHOp::OpSewing, transformTb );
4713 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4715 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4716 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4717 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4718 createTool( SMESHOp::OpCreate2DElements, modifyTb );
4719 createTool( SMESHOp::OpExtrusion, modifyTb );
4720 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4721 createTool( SMESHOp::OpRevolution, modifyTb );
4722 createTool( SMESHOp::OpOrientation, modifyTb );
4723 createTool( SMESHOp::OpReorientFaces, modifyTb );
4724 createTool( SMESHOp::OpMoveNode, modifyTb );
4725 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4726 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4727 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4728 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4729 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4730 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4731 createTool( SMESHOp::OpSmoothing, modifyTb );
4732 createTool( SMESHOp::OpPatternMapping, modifyTb );
4734 int interactTb = createTool( tr( "TB_INTERACT" ), QString( "SMESHInteractiveToolbar" ) ) ;
4735 createTool( SMESHOp::OpMoveNodeInteractive, interactTb );
4736 createTool( SMESHOp::OpRemoveNodeWithReconn, interactTb );
4737 createTool( SMESHOp::OpSplitEdgeInteract, interactTb );
4738 createTool( SMESHOp::OpSplitFaceInteract, interactTb );
4740 // Adaptation - begin
4741 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4742 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4744 #ifndef DISABLE_MG_ADAPT
4745 createTool( SMESHOp::OpMGAdapt, adaptTb );
4747 #ifndef DISABLE_HOMARD_ADAPT
4748 createTool( SMESHOp::OpHomardAdapt, adaptTb );
4752 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4753 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4755 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4756 createTool( SMESHOp::OpUpdate, dispModeTb );
4758 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4759 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4763 OB = "'ObjectBrowser'",
4764 View = "'" + SVTK_Viewer::Type() + "'",
4766 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4767 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4768 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4769 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4770 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4771 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4772 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4773 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4774 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4775 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4776 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4777 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4779 mesh_part = mesh + " " + subMesh + " " + group,
4780 mesh_group = mesh + " " + group,
4781 mesh_submesh = mesh + " " + subMesh,
4782 hyp_alg = hypo + " " + algo;
4784 // popup for object browser
4786 isInvisible("not( isVisible )"),
4787 isEmpty("numberOfNodes = 0"),
4788 isNotEmpty("numberOfNodes <> 0"),
4790 // has nodes, edges, etc in VISIBLE! actor
4791 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4792 hasElems("(count( elemTypes ) > 0)"),
4793 hasDifferentElems("(count( elemTypes ) > 1)"),
4794 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4795 hasBalls("({'BallElem'} in elemTypes)"),
4796 hasElems0d("({'Elem0d'} in elemTypes)"),
4797 hasEdges("({'Edge'} in elemTypes)"),
4798 hasFaces("({'Face'} in elemTypes)"),
4799 hasVolumes("({'Volume'} in elemTypes)"),
4800 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4802 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4803 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4804 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4805 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4806 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4807 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4809 popupMgr()->insert( separator(), -1, 0 );
4810 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4811 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4812 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4813 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4814 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4815 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4816 popupMgr()->insert( separator(), -1, 0 );
4817 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4818 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4819 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4820 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4821 popupMgr()->insert( separator(), -1, 0 );
4822 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4823 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4824 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4825 popupMgr()->insert( separator(), -1, 0 );
4826 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4827 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4828 popupMgr()->insert( separator(), -1, 0 );
4829 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4830 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4832 // Adaptation - begin
4833 popupMgr()->insert( separator(), -1, 0 );
4834 #ifndef DISABLE_MG_ADAPT
4835 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4837 #ifndef DISABLE_HOMARD_ADAPT
4838 createPopupItem( SMESHOp::OpHomardAdapt, OB, mesh );
4840 popupMgr()->insert( separator(), -1, 0 );
4843 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4844 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4845 QString only_one_2D = only_one_non_empty + " && dim>1";
4847 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4848 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4849 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4850 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4851 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4853 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4855 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4856 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4858 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4859 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4860 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4861 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4863 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4865 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4866 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4867 popupMgr()->insert( separator(), -1, 0 );
4869 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4870 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4871 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4874 createPopupItem( SMESHOp::OpEditGroup, View, group );
4875 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4876 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4878 popupMgr()->insert( separator(), -1, 0 );
4879 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4880 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4881 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4882 popupMgr()->insert( separator(), -1, 0 );
4884 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
4885 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4886 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4887 popupMgr()->insert( separator(), -1, 0 );
4889 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4890 QString aType = QString( "%1type in {%2}" ).arg( lc );
4891 aType = aType.arg( mesh_part );
4892 QString aMeshInVTK = aClient + "&&" + aType;
4894 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4895 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4896 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4898 //-------------------------------------------------
4900 //-------------------------------------------------
4901 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4903 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4904 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4905 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4907 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4908 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4909 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4911 popupMgr()->insert( separator(), -1, -1 );
4913 //-------------------------------------------------
4915 //-------------------------------------------------
4916 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4918 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4919 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4920 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4922 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4923 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4924 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4926 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4927 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4928 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4930 popupMgr()->insert( separator(), anId, -1 );
4932 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4933 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4934 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4936 //-------------------------------------------------
4938 //-------------------------------------------------
4939 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4941 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4943 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4944 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4945 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4947 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4948 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4949 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4951 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4952 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4953 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4955 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4956 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4957 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4959 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4960 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4961 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4963 popupMgr()->insert( separator(), anId, -1 );
4965 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4966 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4968 popupMgr()->insert( separator(), anId, -1 );
4970 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4971 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4974 //-------------------------------------------------
4975 // Representation of the 2D Quadratic elements
4976 //-------------------------------------------------
4977 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4978 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4979 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4980 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4982 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4983 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4984 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4986 //-------------------------------------------------
4987 // Orientation of faces
4988 //-------------------------------------------------
4989 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4990 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4991 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4993 //-------------------------------------------------
4995 //-------------------------------------------------
4996 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4997 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4999 //-------------------------------------------------
5001 //-------------------------------------------------
5002 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
5003 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
5005 //-------------------------------------------------
5007 //-------------------------------------------------
5009 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
5010 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
5011 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
5012 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
5014 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
5016 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
5017 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5019 popupMgr()->insert( separator(), anId, -1 );
5021 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
5023 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
5024 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5025 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
5027 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
5028 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5029 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
5031 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
5032 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5033 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
5035 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
5037 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
5038 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
5039 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
5041 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
5042 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5043 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
5045 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
5046 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5047 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
5048 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
5049 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5050 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
5052 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
5054 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
5055 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5056 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
5058 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
5059 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
5060 QtxPopupMgr::VisibleRule );
5061 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
5063 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
5064 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5065 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
5067 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
5068 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5069 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
5071 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
5072 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5073 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
5075 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
5076 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5077 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
5079 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
5080 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5081 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
5083 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
5084 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5085 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
5087 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
5088 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5089 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
5091 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
5092 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5093 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
5095 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
5096 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5097 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
5099 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
5100 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5101 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
5103 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
5104 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5105 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
5107 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
5108 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5109 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
5111 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
5112 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
5113 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
5115 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
5117 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
5118 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5119 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
5121 popupMgr()->insert ( action( SMESHOp::OpWarping3D ), aSubId, -1 );
5122 popupMgr()->setRule( action( SMESHOp::OpWarping3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5123 popupMgr()->setRule( action( SMESHOp::OpWarping3D), "controlMode = 'eWarping3D'", QtxPopupMgr::ToggleRule );
5125 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
5126 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5127 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
5129 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
5130 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5131 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5133 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5134 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5135 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5137 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5138 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5139 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5141 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5142 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5143 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5145 popupMgr()->insert ( action( SMESHOp::OpScaledJacobian ), aSubId, -1 );
5146 popupMgr()->setRule( action( SMESHOp::OpScaledJacobian ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5147 popupMgr()->setRule( action( SMESHOp::OpScaledJacobian ), "controlMode = 'eScaledJacobian'", QtxPopupMgr::ToggleRule );
5149 popupMgr()->insert( separator(), anId, -1 );
5151 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5152 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5153 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5154 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5155 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5157 popupMgr()->insert( separator(), anId, -1 );
5159 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5161 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5162 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5164 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5165 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5166 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5168 #ifndef DISABLE_PLOT2DVIEWER
5169 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5170 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5173 //-------------------------------------------------
5175 //-------------------------------------------------
5176 popupMgr()->insert( separator(), -1, -1 );
5177 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5178 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5179 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5180 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5182 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5183 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5185 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5186 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5188 popupMgr()->insert( separator(), -1, -1 );
5190 //-------------------------------------------------
5192 //-------------------------------------------------
5193 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5194 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5196 popupMgr()->insert( separator(), -1, -1 );
5198 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5199 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5200 popupMgr()->insert( separator(), -1, -1 );
5202 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5203 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5205 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5206 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5208 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5209 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5212 //================================================================================
5214 * \brief Return true if SMESH or GEOM objects are selected.
5215 * Is called form LightApp_Module::activateModule() which clear selection if
5216 * not isSelectionCompatible()
5218 //================================================================================
5220 bool SMESHGUI::isSelectionCompatible()
5222 bool isCompatible = true;
5223 SALOME_ListIO selected;
5224 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5225 Sel->selectedObjects( selected );
5227 SALOME_ListIteratorOfListIO It( selected );
5228 for ( ; isCompatible && It.More(); It.Next())
5230 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5231 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5232 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5234 return isCompatible;
5238 bool SMESHGUI::reusableOperation( const int id )
5240 // compute, evaluate and precompute are not reusable operations
5241 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5246 QString wrap(const QString& text, const QString& tag)
5247 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5250 bool SMESHGUI::activateModule( SUIT_Study* study )
5252 bool res = SalomeApp_Module::activateModule( study );
5254 setMenuShown( true );
5255 setToolShown( true );
5257 // Fill in Help Panel
5258 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5259 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5261 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5264 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5265 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5266 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5267 lab = lab + tr("INFO_REFINE") + ":";
5268 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5269 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5270 lab = lab + wrap(items.join(""), "ul");
5273 app->infoPanel()->addLabel(lab, gb);
5275 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5276 items << wrap("UNV", "li")
5277 << wrap("MED", "li")
5278 << wrap("STL", "li")
5279 << wrap("CGNS", "li")
5280 << wrap("GMF", "li");
5281 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5284 app->infoPanel()->addLabel(lab, gb);
5286 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5287 lab = tr("INFO_DISPLAY") + "<br/>";
5288 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5289 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5290 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5291 << wrap("...", "li");
5292 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5294 lab = lab + tr("INFO_CLIPPING");
5296 app->infoPanel()->addLabel(lab, gb);
5299 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5300 PyGILState_STATE gstate = PyGILState_Ensure();
5301 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5302 if ( !pluginsmanager ) {
5306 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5311 PyGILState_Release(gstate);
5312 // end of SMESH plugins loading
5314 // Reset actions accelerator keys
5315 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5317 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5318 GetSMESHGen()->UpdateStudy();
5320 // get all view currently opened in the study and connect their signals to
5321 // the corresponding slots of the class.
5322 SUIT_Desktop* aDesk = study->application()->desktop();
5324 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5325 SUIT_ViewWindow* wnd;
5326 foreach ( wnd, wndList )
5330 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5331 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5337 Py_XDECREF(pluginsmanager);
5341 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5343 setMenuShown( false );
5344 setToolShown( false );
5346 EmitSignalCloseAllDialogs();
5348 // Unset actions accelerator keys
5349 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5351 return SalomeApp_Module::deactivateModule( study );
5354 void SMESHGUI::studyClosed( SUIT_Study* s )
5358 SMESH::RemoveVisuData();
5359 SalomeApp_Module::studyClosed( s );
5362 void SMESHGUI::OnGUIEvent()
5364 const QObject* obj = sender();
5365 if ( !obj || !obj->inherits( "QAction" ) )
5367 int id = actionId((QAction*)obj);
5372 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5374 if ( CORBA::is_nil( myComponentSMESH ) )
5376 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5377 return aGUI.myComponentSMESH;
5379 return myComponentSMESH;
5382 QString SMESHGUI::engineIOR() const
5384 CORBA::ORB_var anORB = getApp()->orb();
5385 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5386 return QString( anIOR.in() );
5389 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5391 SalomeApp_Module::contextMenuPopup( client, menu, title );
5393 selectionMgr()->selectedObjects( lst );
5394 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5395 Handle(SALOME_InteractiveObject) io = lst.First();
5396 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5397 _PTR(Study) study = appStudy->studyDS();
5398 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5400 QString aName = SMESH::fromUtf8( obj->GetName());
5401 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5402 aName.remove(( aName.length() - 1 ), 1 );
5408 LightApp_Selection* SMESHGUI::createSelection() const
5410 return new SMESHGUI_Selection();
5413 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5415 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5416 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5417 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5418 #ifndef DISABLE_PYCONSOLE
5419 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5423 void SMESHGUI::viewManagers( QStringList& list ) const
5425 list.append( SVTK_Viewer::Type() );
5428 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5430 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5431 SMESH::UpdateSelectionProp( this );
5433 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5434 for(int i = 0; i < aViews.count() ; i++){
5435 SUIT_ViewWindow *sf = aViews[i];
5438 EmitSignalActivatedViewManager();
5442 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5444 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5445 myClippingPlaneInfoMap.erase( theViewManager );
5448 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5450 theActor->AddObserver( SMESH::DeleteActorEvent,
5451 myEventCallbackCommand.GetPointer(),
5455 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5456 unsigned long theEvent,
5457 void* theClientData,
5458 void* /*theCallData*/ )
5460 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5461 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5462 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5463 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5464 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5465 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5466 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5467 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5468 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5469 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5470 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5471 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5472 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5473 if( anActor == *anIter3 ) {
5474 anActorList.erase( anIter3 );
5485 void SMESHGUI::createPreferences()
5487 // General tab ------------------------------------------------------------------------
5488 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5490 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5491 setPreferenceProperty( autoUpdate, "columns", 2 );
5492 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5493 setPreferenceProperty( lim, "min", 0 );
5494 setPreferenceProperty( lim, "max", 100000000 );
5495 setPreferenceProperty( lim, "step", 1000 );
5496 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5497 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5499 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5500 setPreferenceProperty( dispgroup, "columns", 2 );
5502 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5504 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5506 modes.append( tr("MEN_WIRE") );
5507 modes.append( tr("MEN_SHADE") );
5508 modes.append( tr("MEN_NODES") );
5509 modes.append( tr("MEN_SHRINK") );
5510 QList<QVariant> indices;
5511 indices.append( 0 );
5512 indices.append( 1 );
5513 indices.append( 2 );
5514 indices.append( 3 );
5515 setPreferenceProperty( dispmode, "strings", modes );
5516 setPreferenceProperty( dispmode, "indexes", indices );
5518 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5519 setPreferenceProperty( arcgroup, "columns", 2 );
5520 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5521 QStringList quadraticModes;
5522 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5523 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5525 indices.append( 0 );
5526 indices.append( 1 );
5527 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5528 setPreferenceProperty( quadraticmode, "indexes", indices );
5530 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5531 "SMESH", "max_angle" );
5532 setPreferenceProperty( maxAngle, "min", 1 );
5533 setPreferenceProperty( maxAngle, "max", 90 );
5535 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5536 setPreferenceProperty( qaGroup, "columns", 2 );
5537 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5538 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5539 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5540 setPreferenceProperty( prec, "min", 0 );
5541 setPreferenceProperty( prec, "max", 100 );
5542 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5543 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5544 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5545 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5546 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5549 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5550 setPreferenceProperty( cinc, "min", 0 );
5551 setPreferenceProperty( cinc, "max", 5 );
5554 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5555 setPreferenceProperty( exportgroup, "columns", 2 );
5556 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5557 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5558 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5559 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5560 setPreferenceProperty( zTol, "precision", 10 );
5561 setPreferenceProperty( zTol, "min", 0.0000000001 );
5562 setPreferenceProperty( zTol, "max", 1000000.0 );
5563 setPreferenceProperty( zTol, "step", 1. );
5564 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5566 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5567 setPreferenceProperty( computeGroup, "columns", 2 );
5568 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5570 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5571 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5572 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5574 indices.append( 0 );
5575 indices.append( 1 );
5576 indices.append( 2 );
5577 setPreferenceProperty( notifyMode, "strings", modes );
5578 setPreferenceProperty( notifyMode, "indexes", indices );
5580 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5581 setPreferenceProperty( infoGroup, "columns", 2 );
5582 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5584 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5585 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5587 indices.append( 0 );
5588 indices.append( 1 );
5589 setPreferenceProperty( elemInfo, "strings", modes );
5590 setPreferenceProperty( elemInfo, "indexes", indices );
5591 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5592 setPreferenceProperty( nodesLim, "min", 0 );
5593 setPreferenceProperty( nodesLim, "max", 10000000 );
5594 setPreferenceProperty( nodesLim, "step", 10000 );
5595 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5596 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5597 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5598 setPreferenceProperty( ctrlLim, "min", 0 );
5599 setPreferenceProperty( ctrlLim, "max", 10000000 );
5600 setPreferenceProperty( ctrlLim, "step", 1000 );
5601 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5602 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5603 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5604 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5605 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5607 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5608 setPreferenceProperty( segGroup, "columns", 2 );
5609 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5610 "SMESH", "segmentation" );
5611 setPreferenceProperty( segLen, "min", 1 );
5612 setPreferenceProperty( segLen, "max", 10000000 );
5613 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5614 "SMESH", "nb_segments_per_edge" );
5615 setPreferenceProperty( nbSeg, "min", 1 );
5616 setPreferenceProperty( nbSeg, "max", 10000000 );
5617 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5619 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5620 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5621 "SMESH", "forget_mesh_on_hyp_modif" );
5624 // Quantities with individual precision settings
5625 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5626 setPreferenceProperty( precGroup, "columns", 2 );
5628 const int nbQuantities = 6;
5629 int precs[nbQuantities], ii = 0;
5630 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5631 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5632 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5633 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5634 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5635 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5636 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5637 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5638 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5639 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5640 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5641 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5643 // Set property for precision value for spinboxes
5644 for ( ii = 0; ii < nbQuantities; ii++ ){
5645 setPreferenceProperty( precs[ii], "min", -14 );
5646 setPreferenceProperty( precs[ii], "max", 14 );
5647 setPreferenceProperty( precs[ii], "precision", 2 );
5650 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5651 setPreferenceProperty( previewGroup, "columns", 2 );
5652 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5653 setPreferenceProperty( chunkSize, "min", 1 );
5654 setPreferenceProperty( chunkSize, "max", 1000 );
5655 setPreferenceProperty( chunkSize, "step", 50 );
5657 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5658 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5660 // Mesh tab ------------------------------------------------------------------------
5661 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5662 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5663 setPreferenceProperty( nodeGroup, "columns", 3 );
5665 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5667 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5669 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5670 QList<QVariant> aMarkerTypeIndicesList;
5671 QList<QVariant> aMarkerTypeIconsList;
5672 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5673 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5674 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5675 aMarkerTypeIndicesList << i;
5676 aMarkerTypeIconsList << pixmap;
5678 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5679 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5681 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5683 QList<QVariant> aMarkerScaleIndicesList;
5684 QStringList aMarkerScaleValuesList;
5685 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5686 aMarkerScaleIndicesList << i;
5687 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5688 aMarkerScaleValuesList << QString::number( i );
5690 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5691 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5693 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5694 //setPreferenceProperty( elemGroup, "columns", 2 );
5696 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5697 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5698 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5699 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5700 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5701 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5702 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5703 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5704 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5707 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5708 setPreferenceProperty( grpGroup, "columns", 2 );
5710 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5711 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5713 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5714 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5715 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5716 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5717 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5718 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5719 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5720 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5721 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5722 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5723 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5724 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5725 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5726 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5728 setPreferenceProperty( size0d, "min", 1 );
5729 setPreferenceProperty( size0d, "max", 10 );
5731 // setPreferenceProperty( ballSize, "min", 1 );
5732 // setPreferenceProperty( ballSize, "max", 10 );
5734 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5735 setPreferenceProperty( ballDiameter, "max", 1e9 );
5736 setPreferenceProperty( ballDiameter, "step", 0.1 );
5738 setPreferenceProperty( ballScale, "min", 1e-2 );
5739 setPreferenceProperty( ballScale, "max", 1e7 );
5740 setPreferenceProperty( ballScale, "step", 0.5 );
5742 setPreferenceProperty( elemW, "min", 1 );
5743 setPreferenceProperty( elemW, "max", 5 );
5745 setPreferenceProperty( outW, "min", 1 );
5746 setPreferenceProperty( outW, "max", 5 );
5748 setPreferenceProperty( shrink, "min", 0 );
5749 setPreferenceProperty( shrink, "max", 100 );
5751 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5752 setPreferenceProperty( numGroup, "columns", 2 );
5754 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5755 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5757 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5758 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5760 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5761 setPreferenceProperty( orientGroup, "columns", 1 );
5763 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5764 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5766 setPreferenceProperty( orientScale, "min", 0.05 );
5767 setPreferenceProperty( orientScale, "max", 0.5 );
5768 setPreferenceProperty( orientScale, "step", 0.05 );
5770 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5772 // Selection tab ------------------------------------------------------------------------
5773 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5775 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5776 setPreferenceProperty( selGroup, "columns", 2 );
5778 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5779 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5781 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5782 setPreferenceProperty( preGroup, "columns", 2 );
5784 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5786 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5787 setPreferenceProperty( precSelGroup, "columns", 2 );
5789 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5790 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5791 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5793 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5794 setPreferenceProperty( sinc, "min", 0 );
5795 setPreferenceProperty( sinc, "max", 5 );
5797 // Scalar Bar tab ------------------------------------------------------------------------
5798 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5799 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5800 setPreferenceProperty( fontGr, "columns", 2 );
5802 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5803 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5805 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5806 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5808 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5809 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5811 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5812 setPreferenceProperty( numcol, "min", 2 );
5813 setPreferenceProperty( numcol, "max", 256 );
5815 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5816 setPreferenceProperty( numlab, "min", 2 );
5817 setPreferenceProperty( numlab, "max", 65 );
5819 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5820 setPreferenceProperty( orientGr, "columns", 2 );
5821 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5822 QStringList orients;
5823 orients.append( tr( "SMESH_VERTICAL" ) );
5824 orients.append( tr( "SMESH_HORIZONTAL" ) );
5825 indices.clear(); indices.append( 0 ); indices.append( 1 );
5826 setPreferenceProperty( orient, "strings", orients );
5827 setPreferenceProperty( orient, "indexes", indices );
5829 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5830 setPreferenceProperty( posVSizeGr, "columns", 2 );
5831 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5832 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5833 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5834 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5835 setPreferenceProperty( xv, "step", 0.1 );
5836 setPreferenceProperty( xv, "min", 0.0 );
5837 setPreferenceProperty( xv, "max", 1.0 );
5838 setPreferenceProperty( yv, "step", 0.1 );
5839 setPreferenceProperty( yv, "min", 0.0 );
5840 setPreferenceProperty( yv, "max", 1.0 );
5841 setPreferenceProperty( wv, "step", 0.1 );
5842 setPreferenceProperty( wv, "min", 0.0 );
5843 setPreferenceProperty( wv, "max", 1.0 );
5844 setPreferenceProperty( hv, "min", 0.0 );
5845 setPreferenceProperty( hv, "max", 1.0 );
5846 setPreferenceProperty( hv, "step", 0.1 );
5848 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5849 setPreferenceProperty( posHSizeGr, "columns", 2 );
5850 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5851 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5852 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5853 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5854 setPreferenceProperty( xv, "min", 0.0 );
5855 setPreferenceProperty( xv, "max", 1.0 );
5856 setPreferenceProperty( xv, "step", 0.1 );
5857 setPreferenceProperty( xh, "min", 0.0 );
5858 setPreferenceProperty( xh, "max", 1.0 );
5859 setPreferenceProperty( xh, "step", 0.1 );
5860 setPreferenceProperty( yh, "min", 0.0 );
5861 setPreferenceProperty( yh, "max", 1.0 );
5862 setPreferenceProperty( yh, "step", 0.1 );
5863 setPreferenceProperty( wh, "min", 0.0 );
5864 setPreferenceProperty( wh, "max", 1.0 );
5865 setPreferenceProperty( wh, "step", 0.1 );
5866 setPreferenceProperty( hh, "min", 0.0 );
5867 setPreferenceProperty( hh, "max", 1.0 );
5868 setPreferenceProperty( hh, "step", 0.1 );
5870 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5871 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5872 setPreferenceProperty( distributionGr, "columns", 3 );
5874 types.append( tr( "SMESH_MONOCOLOR" ) );
5875 types.append( tr( "SMESH_MULTICOLOR" ) );
5876 indices.clear(); indices.append( 0 ); indices.append( 1 );
5877 setPreferenceProperty( coloringType, "strings", types );
5878 setPreferenceProperty( coloringType, "indexes", indices );
5879 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5881 // Adaptation - begin
5882 #ifndef DISABLE_MG_ADAPT
5883 // Adaptation tab ------------------------------------------------------------------------
5884 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
5887 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
5888 setPreferenceProperty( bloc, "columns", 1 );
5889 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
5890 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
5891 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
5892 QStringList aListOfSizeMap;
5893 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
5894 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
5895 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
5896 setPreferenceProperty( pref, "strings", aListOfSizeMap );
5897 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
5898 QStringList aListOfTimeStep;
5899 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
5900 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
5901 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
5902 setPreferenceProperty( pref, "strings", aListOfTimeStep );
5907 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5909 if ( sect=="SMESH" ) {
5910 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5911 double aTol = 1.00000009999999;
5912 std::string aWarning;
5913 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5915 if ( name == "selection_object_color" ||
5916 name == "selection_element_color" ||
5917 name == "highlight_color" ||
5918 name == "selection_precision_node" ||
5919 name == "selection_precision_element" ||
5920 name == "selection_precision_object" ||
5921 name == "selection_increment")
5923 SMESH::UpdateSelectionProp( this );
5925 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5927 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5928 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5929 if ( sbX1+sbW > aTol ) {
5930 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5933 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5934 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5937 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5939 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5940 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5941 if ( sbY1 + sbH > aTol ) {
5942 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5943 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5944 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5947 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5949 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5950 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5951 if ( sbX1 + sbW > aTol ) {
5952 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5955 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5956 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5959 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5961 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5962 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5963 if ( sbY1 + sbH > aTol ) {
5964 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5967 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5968 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5971 else if ( name == "segmentation" )
5973 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5974 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5976 else if ( name == "nb_segments_per_edge" )
5978 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5979 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5981 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5983 QString val = aResourceMgr->stringValue( "SMESH", name );
5984 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5986 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5988 SMESH::UpdateFontProp( this );
5990 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5992 SMESH::UpdateFontProp( this );
5995 if ( aWarning.size() != 0 ) {
5996 aWarning += "The default values are applied instead.";
5997 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5998 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5999 QObject::tr(aWarning.c_str()));
6004 //================================================================================
6006 * \brief Update something in accordance with update flags
6007 * \param theFlags - update flags
6009 * Update viewer or/and object browser etc. in accordance with update flags ( see
6010 * LightApp_UpdateFlags enumeration ).
6012 //================================================================================
6013 void SMESHGUI::update( const int flags )
6015 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
6016 SMESH::UpdateView();
6018 SalomeApp_Module::update( flags );
6021 //================================================================================
6023 * \brief Set default selection mode
6025 * SLOT called when operation committed. Sets default selection mode
6027 //================================================================================
6028 void SMESHGUI::onOperationCommited( SUIT_Operation* )
6030 SVTK_ViewWindow* vtkWnd =
6031 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6033 vtkWnd->SetSelectionMode( ActorSelection );
6036 //================================================================================
6038 * \brief Set default selection mode
6040 * SLOT called when operation aborted. Sets default selection mode
6042 //================================================================================
6043 void SMESHGUI::onOperationAborted( SUIT_Operation* )
6045 SVTK_ViewWindow* vtkWnd =
6046 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6048 vtkWnd->SetSelectionMode( ActorSelection );
6051 //================================================================================
6053 * \brief Creates operation with given identifier
6054 * \param id - identifier of operation to be started
6055 * \return Pointer on created operation or NULL if operation is not created
6057 * Virtual method redefined from the base class creates operation with given id.
6058 * It is called called automatically from startOperation method of base class.
6060 //================================================================================
6061 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
6063 LightApp_Operation* op = 0;
6064 // to do : create operation here
6067 case SMESHOp::OpSplitBiQuadratic:
6068 op = new SMESHGUI_SplitBiQuadOp();
6070 case SMESHOp::OpConvertMeshToQuadratic:
6071 op = new SMESHGUI_ConvToQuadOp();
6073 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
6074 op = new SMESHGUI_Make2DFrom3DOp();
6076 case SMESHOp::OpCreateDualMesh:
6077 op = new SMESHGUI_CreateDualMeshOp();
6079 case SMESHOp::OpCreate2DElements:
6080 op = new SMESHGUI_MakeFull2DFrom3DOp();
6082 case SMESHOp::OpReorientFaces:
6083 op = new SMESHGUI_ReorientFacesOp();
6085 case SMESHOp::OpCreateMesh:
6086 op = new SMESHGUI_MeshOp( true, true );
6088 case SMESHOp::OpCreateSubMesh:
6089 op = new SMESHGUI_MeshOp( true, false );
6091 case SMESHOp::OpEditMeshOrSubMesh:
6092 case SMESHOp::OpEditMesh:
6093 case SMESHOp::OpEditSubMesh:
6094 op = new SMESHGUI_MeshOp( false );
6096 case SMESHOp::OpCompute:
6097 case SMESHOp::OpComputeSubMesh:
6098 op = new SMESHGUI_ComputeOp();
6100 case SMESHOp::OpShowErrors:
6101 op = new SMESHGUI_ShowErrorsOp();
6103 case SMESHOp::OpPreCompute:
6104 op = new SMESHGUI_PrecomputeOp();
6106 case SMESHOp::OpEvaluate:
6107 op = new SMESHGUI_EvaluateOp();
6109 case SMESHOp::OpMeshOrder:
6110 op = new SMESHGUI_MeshOrderOp();
6112 case SMESHOp::OpCreateGeometryGroup:
6113 op = new SMESHGUI_GroupOnShapeOp();
6115 case SMESHOp::OpFindElementByPoint:
6116 op = new SMESHGUI_FindElemByPointOp();
6118 case SMESHOp::OpMoveNode: // Make mesh pass through point
6119 op = new SMESHGUI_MakeNodeAtPointOp();
6121 case SMESHOp::OpMoveNodeInteractive: // Make mesh pass through point / by mouse
6122 op = new SMESHGUI_MakeNodeAtPointOp( 2 );
6124 case SMESHOp::OpRemoveNodeWithReconn:
6125 op = new SMESHGUI_RemoveNodeReconnectionOp();
6127 case SMESHOp::OpSplitEdgeInteract:
6128 op = new SMESHGUI_AddNodeOnSegmentOp();
6130 case SMESHOp::OpSplitFaceInteract:
6131 op = new SMESHGUI_AddNodeOnFaceOp();
6133 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
6134 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
6141 op = SalomeApp_Module::createOperation( id );
6145 //================================================================================
6147 * \brief Stops current operations and starts a given one
6148 * \param id - The id of the operation to start
6150 //================================================================================
6152 void SMESHGUI::switchToOperation(int id)
6154 activeStudy()->abortAllOperations();
6155 startOperation( id );
6158 LightApp_Displayer* SMESHGUI::displayer()
6161 myDisplayer = new SMESHGUI_Displayer( getApp() );
6165 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6168 int aTolerance = 64;
6169 int anIterations = 0;
6175 if( anIterations % aPeriod == 0 )
6178 if( aTolerance < 1 )
6182 aHue = (int)( 360.0 * rand() / RAND_MAX );
6185 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6186 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6187 for( ; it != itEnd; ++it )
6189 SALOMEDS::Color anAutoColor = *it;
6190 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6193 aQColor.getHsv( &h, &s, &v );
6194 if( abs( h - aHue ) < aTolerance )
6206 aColor.setHsv( aHue, 255, 255 );
6208 SALOMEDS::Color aSColor;
6209 aSColor.R = aColor.redF();
6210 aSColor.G = aColor.greenF();
6211 aSColor.B = aColor.blueF();
6216 const char* gSeparator = "_"; // character used to separate parameter names
6217 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6218 const char* gPathSep = "|"; // character used to separate paths
6221 * \brief Store visual parameters
6223 * This method is called just before the study document is saved.
6224 * Store visual parameters in AttributeParameter attribute(s)
6226 void SMESHGUI::storeVisualParameters (int savePoint)
6229 Kernel_Utils::Localizer loc;
6231 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6232 if (!appStudy || !appStudy->studyDS())
6234 _PTR(Study) studyDS = appStudy->studyDS();
6236 // componentName is used for encoding of entries when storing them in IParameters
6237 std::string componentName = myComponentSMESH->ComponentDataType();
6238 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6239 //if (!aSComponent) return;
6242 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6243 componentName.c_str(),
6245 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6247 // store custom markers
6248 if( !myMarkerMap.empty() )
6250 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6251 for( ; anIter != myMarkerMap.end(); anIter++ )
6253 int anId = anIter->first;
6254 VTK::MarkerData aMarkerData = anIter->second;
6255 std::string aMarkerFileName = aMarkerData.first;
6256 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6257 if( aMarkerTexture.size() < 3 )
6258 continue; // should contain at least width, height and the first value
6260 QString aPropertyName( "texture" );
6261 aPropertyName += gSeparator;
6262 aPropertyName += QString::number( anId );
6264 QString aPropertyValue = aMarkerFileName.c_str();
6265 aPropertyValue += gPathSep;
6267 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6268 ushort aWidth = *aTextureIter++;
6269 ushort aHeight = *aTextureIter++;
6270 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6271 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6272 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6273 aPropertyValue += QString::number( *aTextureIter );
6275 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6279 // viewers counters are used for storing view_numbers in IParameters
6282 // main cycle to store parameters of displayed objects
6283 QList<SUIT_ViewManager*> lst;
6284 QList<SUIT_ViewManager*>::Iterator it;
6285 getApp()->viewManagers(lst);
6286 for (it = lst.begin(); it != lst.end(); it++)
6288 SUIT_ViewManager* vman = *it;
6289 QString vType = vman->getType();
6291 // saving VTK actors properties
6292 if (vType == SVTK_Viewer::Type())
6294 // store the clipping planes attached to the view manager
6295 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6296 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6297 if( anIter != myClippingPlaneInfoMap.end() )
6298 aClippingPlaneInfoList = anIter->second;
6300 if( !aClippingPlaneInfoList.empty() ) {
6301 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6302 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6304 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6305 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6307 QString aPropertyName( "ClippingPlane" );
6308 aPropertyName += gSeparator;
6309 aPropertyName += QString::number( vtkViewers );
6310 aPropertyName += gSeparator;
6311 aPropertyName += QString::number( anId );
6313 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6314 aPropertyValue += gDigitsSep;
6315 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6316 aPropertyValue += gDigitsSep;
6317 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6318 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6319 aPropertyValue += gDigitsSep;
6320 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6321 aPropertyValue += gDigitsSep;
6322 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6323 aPropertyValue += gDigitsSep;
6324 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6325 aPropertyValue += gDigitsSep;
6326 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6327 aPropertyValue += gDigitsSep;
6328 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6329 aPropertyValue += gDigitsSep;
6330 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6332 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6333 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6334 aPropertyValue += gDigitsSep;
6335 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6336 aPropertyValue += gDigitsSep;
6337 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6338 aPropertyValue += gDigitsSep;
6339 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6342 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6346 QVector<SUIT_ViewWindow*> views = vman->getViews();
6347 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6349 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6351 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6352 vtkActorCollection* allActors = aCopy.GetActors();
6353 allActors->InitTraversal();
6354 while (vtkActor* actor = allActors->GetNextActor())
6356 if (actor->GetVisibility()) // store only visible actors
6358 SMESH_Actor* aSmeshActor = 0;
6359 if (actor->IsA("SMESH_Actor"))
6360 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6361 if (aSmeshActor && aSmeshActor->hasIO())
6363 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6366 // entry is "encoded" = it does NOT contain component address,
6367 // since it is a subject to change on next component loading
6368 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6370 std::string param, vtkParam = vType.toLatin1().data();
6371 vtkParam += gSeparator;
6372 vtkParam += QString::number(vtkViewers).toLatin1().data();
6373 vtkParam += gSeparator;
6376 param = vtkParam + "Visibility";
6377 ip->setParameter(entry, param, "On");
6380 param = vtkParam + "Representation";
6381 ip->setParameter(entry, param, QString::number
6382 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6385 param = vtkParam + "IsShrunk";
6386 ip->setParameter(entry, param, QString::number
6387 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6389 // Displayed entities
6390 unsigned int aMode = aSmeshActor->GetEntityMode();
6391 bool isE = aMode & SMESH_Actor::eEdges;
6392 bool isF = aMode & SMESH_Actor::eFaces;
6393 bool isV = aMode & SMESH_Actor::eVolumes;
6394 bool is0d = aMode & SMESH_Actor::e0DElements;
6395 bool isB = aMode & SMESH_Actor::eBallElem;
6397 QString modeStr ("e");
6398 modeStr += gDigitsSep; modeStr += QString::number(isE);
6399 modeStr += gDigitsSep; modeStr += "f";
6400 modeStr += gDigitsSep; modeStr += QString::number(isF);
6401 modeStr += gDigitsSep; modeStr += "v";
6402 modeStr += gDigitsSep; modeStr += QString::number(isV);
6403 modeStr += gDigitsSep; modeStr += "0d";
6404 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6405 modeStr += gDigitsSep; modeStr += "b";
6406 modeStr += gDigitsSep; modeStr += QString::number(isB);
6408 param = vtkParam + "Entities";
6409 ip->setParameter(entry, param, modeStr.toLatin1().data());
6415 aSmeshActor->GetSufaceColor(r, g, b, delta);
6416 QStringList colorStr;
6417 colorStr << "surface";
6418 colorStr << QString::number(r);
6419 colorStr << QString::number(g);
6420 colorStr << QString::number(b);
6422 colorStr << "backsurface";
6423 colorStr << QString::number(delta);
6425 aSmeshActor->GetVolumeColor(r, g, b, delta);
6426 colorStr << "volume";
6427 colorStr << QString::number(r);
6428 colorStr << QString::number(g);
6429 colorStr << QString::number(b);
6430 colorStr << QString::number(delta);
6432 aSmeshActor->GetEdgeColor(r, g, b);
6434 colorStr << QString::number(r);
6435 colorStr << QString::number(g);
6436 colorStr << QString::number(b);
6438 aSmeshActor->GetNodeColor(r, g, b);
6440 colorStr << QString::number(r);
6441 colorStr << QString::number(g);
6442 colorStr << QString::number(b);
6444 aSmeshActor->GetOutlineColor(r, g, b);
6445 colorStr << "outline";
6446 colorStr << QString::number(r);
6447 colorStr << QString::number(g);
6448 colorStr << QString::number(b);
6450 aSmeshActor->Get0DColor(r, g, b);
6451 colorStr << "elem0d";
6452 colorStr << QString::number(r);
6453 colorStr << QString::number(g);
6454 colorStr << QString::number(b);
6456 aSmeshActor->GetBallColor(r, g, b);
6458 colorStr << QString::number(r);
6459 colorStr << QString::number(g);
6460 colorStr << QString::number(b);
6462 aSmeshActor->GetFacesOrientationColor(r, g, b);
6463 colorStr << "orientation";
6464 colorStr << QString::number(r);
6465 colorStr << QString::number(g);
6466 colorStr << QString::number(b);
6468 param = vtkParam + "Colors";
6469 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6472 QStringList sizeStr;
6474 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6475 sizeStr << "outline";
6476 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6477 sizeStr << "elem0d";
6478 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6480 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6481 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6482 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6483 sizeStr << "shrink";
6484 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6485 sizeStr << "orientation";
6486 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6487 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6489 param = vtkParam + "Sizes";
6490 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6495 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6496 if( aMarkerType == VTK::MT_USER ) {
6497 markerStr += "custom";
6498 markerStr += gDigitsSep;
6499 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6503 markerStr += gDigitsSep;
6504 markerStr += QString::number( (int)aMarkerType );
6505 markerStr += gDigitsSep;
6506 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6509 param = vtkParam + "PointMarker";
6510 ip->setParameter(entry, param, markerStr.toLatin1().data());
6513 param = vtkParam + "Opacity";
6514 ip->setParameter(entry, param,
6515 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6518 param = vtkParam + "ClippingPlane";
6520 if( !aClippingPlaneInfoList.empty() ) {
6521 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6522 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6524 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6525 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6526 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6527 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6528 if( aSmeshActor == *anIter2 ) {
6529 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6530 QString::number( anId ).toLatin1().constData() );
6537 ip->setParameter( entry, param, "Off" );
6538 } // if (io->hasEntry())
6539 } // SMESH_Actor && hasIO
6541 } // while.. actors traversal
6545 } // if (SVTK view model)
6546 } // for (viewManagers)
6549 // data structures for clipping planes processing
6553 bool isOpenGLClipping;
6554 vtkIdType RelativeOrientation;
6557 int AbsoluteOrientation;
6558 double X, Y, Z, Dx, Dy, Dz;
6560 typedef std::list<TPlaneData> TPlaneDataList;
6561 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6563 typedef std::list<vtkActor*> TActorList;
6566 TActorList ActorList;
6567 SUIT_ViewManager* ViewManager;
6569 typedef std::list<TPlaneInfo> TPlaneInfoList;
6570 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6573 * \brief Restore visual parameters
6575 * This method is called after the study document is opened.
6576 * Restore visual parameters from AttributeParameter attribute(s)
6578 void SMESHGUI::restoreVisualParameters (int savePoint)
6581 Kernel_Utils::Localizer loc;
6583 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6584 if (!appStudy || !appStudy->studyDS())
6586 _PTR(Study) studyDS = appStudy->studyDS();
6588 // componentName is used for encoding of entries when storing them in IParameters
6589 std::string componentName = myComponentSMESH->ComponentDataType();
6592 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6593 componentName.c_str(),
6595 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6597 // restore custom markers and map of clipping planes
6598 TPlaneDataMap aPlaneDataMap;
6600 std::vector<std::string> properties = ip->getProperties();
6601 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6603 std::string property = *propIt;
6604 QString aPropertyName( property.c_str() );
6605 QString aPropertyValue( ip->getProperty( property ).c_str() );
6607 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6608 if( aPropertyNameList.isEmpty() )
6611 QString aPropertyType = aPropertyNameList[0];
6612 if( aPropertyType == "texture" )
6614 if( aPropertyNameList.size() != 2 )
6618 int anId = aPropertyNameList[1].toInt( &ok );
6619 if( !ok || anId < 1 )
6622 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6623 if( aPropertyValueList.size() != 2 )
6626 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6627 QString aMarkerTextureString = aPropertyValueList[1];
6628 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6629 if( aMarkerTextureStringList.size() != 3 )
6633 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6638 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6642 VTK::MarkerTexture aMarkerTexture;
6643 aMarkerTexture.push_back( aWidth );
6644 aMarkerTexture.push_back( aHeight );
6646 QString aMarkerTextureData = aMarkerTextureStringList[2];
6647 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6649 QChar aChar = aMarkerTextureData.at( i );
6650 if( aChar.isDigit() )
6651 aMarkerTexture.push_back( aChar.digitValue() );
6654 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6656 else if( aPropertyType == "ClippingPlane" )
6658 if( aPropertyNameList.size() != 3 )
6662 int aViewId = aPropertyNameList[1].toInt( &ok );
6663 if( !ok || aViewId < 0 )
6667 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6668 if( !ok || aClippingPlaneId < 0 )
6671 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6672 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6675 TPlaneData aPlaneData;
6676 aPlaneData.AbsoluteOrientation = false;
6677 aPlaneData.RelativeOrientation = 0;
6678 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6679 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6680 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6682 aPlaneData.Id = aClippingPlaneId;
6685 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6690 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6694 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6697 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6702 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6707 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6712 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6717 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6722 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6727 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6731 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6733 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6738 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6743 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6748 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6753 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6754 aPlaneDataList.push_back( aPlaneData );
6758 TPlaneInfoMap aPlaneInfoMap;
6760 std::vector<std::string> entries = ip->getEntries();
6762 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6764 // entry is a normal entry - it should be "decoded" (setting base address of component)
6765 QString entry (ip->decodeEntry(*entIt).c_str());
6767 // Check that the entry corresponds to a real object in the Study
6768 // as the object may be deleted or modified after the visual state is saved.
6769 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6770 if (!so) continue; //Skip the not existent entry
6772 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6773 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6775 std::vector<std::string>::iterator namesIt = paramNames.begin();
6776 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6778 // actors are stored in a map after displaying of them for
6779 // quicker access in the future: map < viewID to actor >
6780 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6782 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6784 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6785 // '_' is used as separator and should not be used in viewer type or parameter names.
6786 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6787 if (lst.size() != 3)
6790 QString viewerTypStr = lst[0];
6791 QString viewIndexStr = lst[1];
6792 QString paramNameStr = lst[2];
6795 int viewIndex = viewIndexStr.toUInt(&ok);
6796 if (!ok) // bad conversion of view index to integer
6800 if (viewerTypStr == SVTK_Viewer::Type())
6802 SMESH_Actor* aSmeshActor = 0;
6803 if (vtkActors.IsBound(viewIndex))
6804 aSmeshActor = vtkActors.Find(viewIndex);
6806 QList<SUIT_ViewManager*> lst;
6807 getApp()->viewManagers(viewerTypStr, lst);
6809 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6810 SUIT_ViewManager* vman = NULL;
6811 if (viewIndex >= 0 && viewIndex < lst.count())
6812 vman = lst.at(viewIndex);
6814 if (paramNameStr == "Visibility")
6816 if (!aSmeshActor && displayer() && vman)
6818 SUIT_ViewModel* vmodel = vman->getViewModel();
6819 // SVTK view model can be casted to SALOME_View
6820 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6822 // store displayed actor in a temporary map for quicker
6823 // access later when restoring other parameters
6824 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6825 vtkRenderer* Renderer = vtkView->getRenderer();
6826 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6827 vtkActorCollection* theActors = aCopy.GetActors();
6828 theActors->InitTraversal();
6829 bool isFound = false;
6830 vtkActor *ac = theActors->GetNextActor();
6831 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6832 if (ac->IsA("SMESH_Actor")) {
6833 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6834 if (aGeomAc->hasIO()) {
6835 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6836 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6838 vtkActors.Bind(viewIndex, aGeomAc);
6844 } // if (paramNameStr == "Visibility")
6847 // the rest properties "work" with SMESH_Actor
6850 QString val ((*valuesIt).c_str());
6853 if (paramNameStr == "Representation") {
6854 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6857 else if (paramNameStr == "IsShrunk") {
6859 if (!aSmeshActor->IsShrunk())
6860 aSmeshActor->SetShrink();
6863 if (aSmeshActor->IsShrunk())
6864 aSmeshActor->UnShrink();
6867 // Displayed entities
6868 else if (paramNameStr == "Entities") {
6869 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6870 int aEntityMode = SMESH_Actor::eAllEntity;
6871 for ( int i = 0; i < mode.count(); i+=2 ) {
6872 if ( i < mode.count()-1 ) {
6873 QString type = mode[i];
6874 bool val = mode[i+1].toInt();
6875 if ( type == "e" && !val )
6876 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6877 else if ( type == "f" && !val )
6878 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6879 else if ( type == "v" && !val )
6880 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6881 else if ( type == "0d" && !val )
6882 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6883 else if ( type == "b" && !val )
6884 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6887 aSmeshActor->SetEntityMode( aEntityMode );
6890 else if (paramNameStr == "Colors") {
6891 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6898 QColor outlineColor;
6899 QColor orientationColor;
6905 // below lines are required to get default values for delta coefficients
6906 // of backface color for faces and color of reversed volumes
6907 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6908 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6909 for ( int i = 0; i < colors.count(); i++ ) {
6910 QString type = colors[i];
6911 if ( type == "surface" ) {
6912 // face color is set by 3 values r:g:b, where
6913 // - r,g,b - is rgb color components
6914 if ( i+1 >= colors.count() ) break; // format error
6915 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6916 if ( i+2 >= colors.count() ) break; // format error
6917 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6918 if ( i+3 >= colors.count() ) break; // format error
6919 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6920 faceColor.setRgbF( r, g, b );
6923 else if ( type == "backsurface" ) {
6924 // backface color can be defined in several ways
6925 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6926 // - in latest versions, it is set as delta coefficient
6927 bool rgbOk = false, deltaOk;
6928 if ( i+1 >= colors.count() ) break; // format error
6929 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6930 int delta = colors[i+1].toInt( &deltaOk );
6932 if ( i+1 < colors.count() ) // index is shifted to 1
6933 g = colors[i+1].toDouble( &rgbOk );
6934 if ( rgbOk ) i++; // shift index
6935 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6936 b = colors[i+1].toDouble( &rgbOk );
6938 // - as currently there's no way to set directly backsurface color as it was before,
6939 // we ignore old dump where r,g,b triple was set
6940 // - also we check that delta parameter is set properly
6941 if ( !rgbOk && deltaOk )
6944 else if ( type == "volume" ) {
6945 // volume color is set by 4 values r:g:b:delta, where
6946 // - r,g,b - is a normal volume rgb color components
6947 // - delta - is a reversed volume color delta coefficient
6948 if ( i+1 >= colors.count() ) break; // format error
6949 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6950 if ( i+2 >= colors.count() ) break; // format error
6951 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6952 if ( i+3 >= colors.count() ) break; // format error
6953 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6954 if ( i+4 >= colors.count() ) break; // format error
6955 int delta = colors[i+4].toInt( &bOk );
6956 if ( !bOk ) break; // format error
6957 volumeColor.setRgbF( r, g, b );
6961 else if ( type == "edge" ) {
6962 // edge color is set by 3 values r:g:b, where
6963 // - r,g,b - is rgb color components
6964 if ( i+1 >= colors.count() ) break; // format error
6965 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6966 if ( i+2 >= colors.count() ) break; // format error
6967 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6968 if ( i+3 >= colors.count() ) break; // format error
6969 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6970 edgeColor.setRgbF( r, g, b );
6973 else if ( type == "node" ) {
6974 // node color is set by 3 values r:g:b, where
6975 // - r,g,b - is rgb color components
6976 if ( i+1 >= colors.count() ) break; // format error
6977 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6978 if ( i+2 >= colors.count() ) break; // format error
6979 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6980 if ( i+3 >= colors.count() ) break; // format error
6981 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6982 nodeColor.setRgbF( r, g, b );
6985 else if ( type == "elem0d" ) {
6986 // 0d element color is set by 3 values r:g:b, where
6987 // - r,g,b - is rgb color components
6988 if ( i+1 >= colors.count() ) break; // format error
6989 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6990 if ( i+2 >= colors.count() ) break; // format error
6991 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6992 if ( i+3 >= colors.count() ) break; // format error
6993 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6994 elem0dColor.setRgbF( r, g, b );
6997 else if ( type == "ball" ) {
6998 // ball color is set by 3 values r:g:b, where
6999 // - r,g,b - is rgb color components
7000 if ( i+1 >= colors.count() ) break; // format error
7001 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7002 if ( i+2 >= colors.count() ) break; // format error
7003 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7004 if ( i+3 >= colors.count() ) break; // format error
7005 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7006 ballColor.setRgbF( r, g, b );
7009 else if ( type == "outline" ) {
7010 // outline color is set by 3 values r:g:b, where
7011 // - r,g,b - is rgb color components
7012 if ( i+1 >= colors.count() ) break; // format error
7013 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7014 if ( i+2 >= colors.count() ) break; // format error
7015 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7016 if ( i+3 >= colors.count() ) break; // format error
7017 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7018 outlineColor.setRgbF( r, g, b );
7021 else if ( type == "orientation" ) {
7022 // orientation color is set by 3 values r:g:b, where
7023 // - r,g,b - is rgb color components
7024 if ( i+1 >= colors.count() ) break; // format error
7025 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7026 if ( i+2 >= colors.count() ) break; // format error
7027 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7028 if ( i+3 >= colors.count() ) break; // format error
7029 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7030 orientationColor.setRgbF( r, g, b );
7035 if ( nodeColor.isValid() )
7036 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
7038 if ( edgeColor.isValid() )
7039 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
7041 if ( faceColor.isValid() )
7042 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7044 if ( volumeColor.isValid() )
7045 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
7046 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
7047 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7049 if ( elem0dColor.isValid() )
7050 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
7052 if ( ballColor.isValid() )
7053 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
7055 if ( outlineColor.isValid() )
7056 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
7057 // orientation color
7058 if ( orientationColor.isValid() )
7059 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
7062 else if (paramNameStr == "Sizes") {
7063 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
7066 int outlineWidth = -1;
7067 int elem0dSize = -1;
7068 //int ballSize = -1;
7069 double ballDiameter = -1.0;
7070 double ballScale = -1.0;
7071 double shrinkSize = -1;
7072 double orientationSize = -1;
7073 bool orientation3d = false;
7074 for ( int i = 0; i < sizes.count(); i++ ) {
7075 QString type = sizes[i];
7076 if ( type == "line" ) {
7077 // line (wireframe) width is given as single integer value
7078 if ( i+1 >= sizes.count() ) break; // format error
7079 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7083 if ( type == "outline" ) {
7084 // outline width is given as single integer value
7085 if ( i+1 >= sizes.count() ) break; // format error
7086 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7090 else if ( type == "elem0d" ) {
7091 // 0d element size is given as single integer value
7092 if ( i+1 >= sizes.count() ) break; // format error
7093 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7097 else if ( type == "ball" ) {
7098 // balls are specified by two values: size:scale, where
7099 // - size - is a integer value specifying size
7100 // - scale - is a double value specifying scale factor
7101 if ( i+1 >= sizes.count() ) break; // format error
7102 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7103 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7104 if ( i+2 >= sizes.count() ) break; // format error
7105 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7111 else if ( type == "shrink" ) {
7112 // shrink factor is given as single floating point value
7113 if ( i+1 >= sizes.count() ) break; // format error
7114 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7118 else if ( type == "orientation" ) {
7119 // orientation vectors are specified by two values size:3d, where
7120 // - size - is a floating point value specifying scale factor
7121 // - 3d - is a boolean
7122 if ( i+1 >= sizes.count() ) break; // format error
7123 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7124 if ( i+2 >= sizes.count() ) break; // format error
7125 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
7126 orientationSize = v1;
7127 orientation3d = (bool)v2;
7131 // line (wireframe) width
7132 if ( lineWidth > 0 )
7133 aSmeshActor->SetLineWidth( lineWidth );
7135 if ( outlineWidth > 0 )
7136 aSmeshActor->SetOutlineWidth( outlineWidth );
7137 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
7138 aSmeshActor->SetOutlineWidth( lineWidth );
7140 if ( elem0dSize > 0 )
7141 aSmeshActor->Set0DSize( elem0dSize );
7143 /*if ( ballSize > 0 )
7144 aSmeshActor->SetBallSize( ballSize );*/
7146 if ( ballDiameter > 0 )
7147 aSmeshActor->SetBallSize( ballDiameter );
7149 if ( ballScale > 0.0 )
7150 aSmeshActor->SetBallScale( ballScale );
7152 if ( shrinkSize > 0 )
7153 aSmeshActor->SetShrinkFactor( shrinkSize );
7154 // orientation vectors
7155 if ( orientationSize > 0 ) {
7156 aSmeshActor->SetFacesOrientationScale( orientationSize );
7157 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7161 else if (paramNameStr == "PointMarker") {
7162 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7163 if( data.count() >= 2 ) {
7165 int aParam1 = data[1].toInt( &ok );
7167 if( data[0] == "std" && data.count() == 3 ) {
7168 int aParam2 = data[2].toInt( &ok );
7169 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7171 else if( data[0] == "custom" ) {
7172 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7173 if( markerIt != myMarkerMap.end() ) {
7174 VTK::MarkerData aMarkerData = markerIt->second;
7175 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7182 else if (paramNameStr == "Opacity") {
7183 aSmeshActor->SetOpacity(val.toFloat());
7186 else if (paramNameStr.startsWith("ClippingPlane")) {
7187 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7188 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7189 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7190 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7191 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7192 // new format - val looks like "Off" or "0" (plane id)
7193 // (note: in new format "Off" value is used only for consistency,
7194 // so it is processed together with values in old format)
7195 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7196 if( anIsOldFormat ) {
7197 if (paramNameStr == "ClippingPlane1" || val == "Off")
7198 aSmeshActor->RemoveAllClippingPlanes();
7200 QList<SUIT_ViewManager*> lst;
7201 getApp()->viewManagers(viewerTypStr, lst);
7202 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7203 if (viewIndex >= 0 && viewIndex < lst.count()) {
7204 SUIT_ViewManager* vman = lst.at(viewIndex);
7205 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7207 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7209 SMESH::TActorList anActorList;
7210 anActorList.push_back( aSmeshActor );
7211 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7212 aPlane->myViewWindow = vtkView;
7213 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7214 aPlane->PlaneMode = aMode;
7215 bool isOpenGLClipping = ( bool )vals[1].toInt();
7216 aPlane->IsOpenGLClipping = isOpenGLClipping;
7217 if ( aMode == SMESH::Absolute ) {
7218 aPlane->myAbsoluteOrientation = vals[2].toInt();
7219 aPlane->X = vals[3].toFloat();
7220 aPlane->Y = vals[4].toFloat();
7221 aPlane->Z = vals[5].toFloat();
7222 aPlane->Dx = vals[6].toFloat();
7223 aPlane->Dy = vals[7].toFloat();
7224 aPlane->Dz = vals[8].toFloat();
7226 else if ( aMode == SMESH::Relative ) {
7227 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7228 aPlane->myDistance = vals[3].toFloat();
7229 aPlane->myAngle[0] = vals[4].toFloat();
7230 aPlane->myAngle[1] = vals[5].toFloat();
7234 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7235 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7236 aClippingPlaneInfo.Plane = aPlane;
7237 aClippingPlaneInfo.ActorList = anActorList;
7238 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7246 int aPlaneId = val.toInt( &ok );
7247 if( ok && aPlaneId >= 0 ) {
7248 bool anIsDefinedPlane = false;
7249 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7250 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7251 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7252 TPlaneInfo& aPlaneInfo = *anIter;
7253 if( aPlaneInfo.PlaneId == aPlaneId ) {
7254 aPlaneInfo.ActorList.push_back( aSmeshActor );
7255 anIsDefinedPlane = true;
7259 if( !anIsDefinedPlane ) {
7260 TPlaneInfo aPlaneInfo;
7261 aPlaneInfo.PlaneId = aPlaneId;
7262 aPlaneInfo.ActorList.push_back( aSmeshActor );
7263 aPlaneInfo.ViewManager = vman;
7265 // to make the list sorted by plane id
7266 anIter = aPlaneInfoList.begin();
7267 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7268 const TPlaneInfo& aPlaneInfoRef = *anIter;
7269 if( aPlaneInfoRef.PlaneId > aPlaneId )
7272 aPlaneInfoList.insert( anIter, aPlaneInfo );
7277 } // if (aSmeshActor)
7278 } // other parameters than Visibility
7280 } // for names/parameters iterator
7281 } // for entries iterator
7283 // take into account planes with empty list of actors referred to them
7284 QList<SUIT_ViewManager*> aVMList;
7285 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7287 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7288 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7289 int aViewId = aPlaneDataIter->first;
7290 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7291 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7293 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7295 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7296 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7297 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7298 const TPlaneData& aPlaneData = *anIter2;
7299 int aPlaneId = aPlaneData.Id;
7301 bool anIsFound = false;
7302 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7303 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7304 const TPlaneInfo& aPlaneInfo = *anIter3;
7305 if( aPlaneInfo.PlaneId == aPlaneId ) {
7312 TPlaneInfo aPlaneInfo; // ActorList field is empty
7313 aPlaneInfo.PlaneId = aPlaneId;
7314 aPlaneInfo.ViewManager = aViewManager;
7316 // to make the list sorted by plane id
7317 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7318 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7319 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7320 if( aPlaneInfoRef.PlaneId > aPlaneId )
7323 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7329 // add clipping planes to actors according to the restored parameters
7330 // and update the clipping plane map
7331 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7332 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7333 int aViewId = anIter1->first;
7334 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7336 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7337 if( anIter2 == aPlaneDataMap.end() )
7339 const TPlaneDataList& aPlaneDataList = anIter2->second;
7341 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7342 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7343 const TPlaneInfo& aPlaneInfo = *anIter3;
7344 int aPlaneId = aPlaneInfo.PlaneId;
7345 const TActorList& anActorList = aPlaneInfo.ActorList;
7346 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7350 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7354 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7356 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7357 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7358 const TPlaneData& aPlaneData = *anIter4;
7359 if( aPlaneData.Id == aPlaneId ) {
7360 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7361 aPlane->myViewWindow = aViewWindow;
7362 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7363 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7364 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7365 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7366 aPlane->X = aPlaneData.X;
7367 aPlane->Y = aPlaneData.Y;
7368 aPlane->Z = aPlaneData.Z;
7369 aPlane->Dx = aPlaneData.Dx;
7370 aPlane->Dy = aPlaneData.Dy;
7371 aPlane->Dz = aPlaneData.Dz;
7373 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7374 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7375 aPlane->myDistance = aPlaneData.Distance;
7376 aPlane->myAngle[0] = aPlaneData.Angle[0];
7377 aPlane->myAngle[1] = aPlaneData.Angle[1];
7380 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7381 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7382 aClippingPlaneInfo.Plane = aPlane;
7383 aClippingPlaneInfo.ActorList = anActorList;
7384 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7395 // update all VTK views
7396 QList<SUIT_ViewManager*> lst;
7397 getApp()->viewManagers(lst);
7398 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7399 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7400 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7401 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7402 // set OpenGL clipping planes
7403 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7404 vtkActorCollection* anAllActors = aCopy.GetActors();
7405 anAllActors->InitTraversal();
7406 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7407 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7408 anActor->SetOpenGLClippingPlane();
7410 vtkView->getRenderer()->ResetCameraClippingRange();
7417 \brief Adds preferences for dfont of VTK viewer
7419 \param pIf group identifier
7420 \param param parameter
7421 \return identifier of preferences
7423 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7425 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7427 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7430 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7431 fam.append( tr( "SMESH_FONT_COURIER" ) );
7432 fam.append( tr( "SMESH_FONT_TIMES" ) );
7434 setPreferenceProperty( tfont, "fonts", fam );
7436 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7437 if ( needSize ) f = f | QtxFontEdit::Size;
7438 setPreferenceProperty( tfont, "features", f );
7444 \brief Actions after hypothesis edition
7445 Updates object browser after hypothesis edition
7447 void SMESHGUI::onHypothesisEdit( int result )
7450 SMESHGUI::Modified();
7451 updateObjBrowser( true );
7455 \brief Actions after choosing menu of control modes
7456 Updates control mode actions according to current selection
7458 void SMESHGUI::onUpdateControlActions()
7460 SALOME_ListIO selected;
7461 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7462 aSel->selectedObjects( selected );
7464 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7465 if ( selected.Extent() ) {
7466 if ( selected.First()->hasEntry() ) {
7467 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7468 aControl = anActor->GetControlMode();
7469 SALOME_ListIteratorOfListIO it(selected);
7470 for ( it.Next(); it.More(); it.Next() ) {
7471 Handle(SALOME_InteractiveObject) anIO = it.Value();
7472 if ( anIO->hasEntry() ) {
7473 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7474 if ( aControl != anActor->GetControlMode() ) {
7475 aControl = SMESH_Actor::eNone;
7485 int anAction = ActionToControl( aControl, true );
7487 action( anAction )->setChecked( true );
7489 QMenu* send = (QMenu*)sender();
7490 QList<QAction*> actions = send->actions();
7491 for ( int i = 0; i < actions.size(); i++ )
7492 actions[i]->setChecked( false );
7498 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7499 \param pview view being closed
7501 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7502 #ifndef DISABLE_PLOT2DVIEWER
7503 //Crear all Plot2d Viewers if need.
7504 SMESH::ClearPlot2Viewers(pview);
7506 EmitSignalCloseView();
7509 void SMESHGUI::message( const QString& msg )
7512 QStringList data = msg.split("/");
7513 if ( data.count() > 0 ) {
7514 if ( data.first() == "mesh_loading" ) {
7516 QString entry = data.count() > 1 ? data[1] : QString();
7517 if ( entry.isEmpty() )
7520 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7522 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7525 name = SMESH::fromUtf8(obj->GetName());
7526 if ( name.isEmpty() )
7529 if ( data.last() == "stop" )
7530 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7532 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7533 QApplication::processEvents();
7539 \brief Connects or disconnects signals about activating and cloning view on the module slots
7540 \param pview view which is connected/disconnected
7542 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7546 SUIT_ViewManager* viewMgr = pview->getViewManager();
7548 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7549 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7551 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7552 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7557 \brief Return \c true if object can be renamed
7559 bool SMESHGUI::renameAllowed( const QString& entry) const {
7560 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7564 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7568 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7573 if(appStudy->isComponent(entry) || obj->isReference())
7576 // check type to prevent renaming of inappropriate objects
7577 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7578 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7579 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7580 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7581 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7582 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7589 Rename object by entry.
7590 \param entry entry of the object
7591 \param name new name of the object
7592 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7594 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7596 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7600 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7605 _PTR(Study) aStudy = appStudy->studyDS();
7610 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7612 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7617 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7618 _PTR(GenericAttribute) anAttr;
7619 _PTR(AttributeName) aName;
7621 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7623 // check type to prevent renaming of inappropriate objects
7624 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7625 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7626 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7627 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7628 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7629 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7630 if ( !name.isEmpty() ) {
7631 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7633 // update name of group object and its actor
7634 Handle(SALOME_InteractiveObject) IObject =
7635 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7637 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7638 if( !aGroupObject->_is_nil() ) {
7639 aGroupObject->SetName( qUtf8Printable(name) );
7640 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7641 anActor->setName( qUtf8Printable(name) );
7651 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7653 static QList<QColor> colors;
7655 if ( colors.isEmpty() ) {
7657 for (int s = 0; s < 2 ; s++)
7659 for (int v = 100; v >= 40; v = v - 20)
7661 for (int h = 0; h < 359 ; h = h + 60)
7663 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7668 static int currentColor = randomize( colors.size() );
7670 SALOMEDS::Color color;
7671 color.R = (double)colors[currentColor].red() / 255.0;
7672 color.G = (double)colors[currentColor].green() / 255.0;
7673 color.B = (double)colors[currentColor].blue() / 255.0;
7675 currentColor = (currentColor+1) % colors.count();