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 );
2564 switch (theCommandID) {
2565 case SMESHOp::OpDelete:
2566 if(isStudyLocked()) break;
2569 case SMESHOp::OpImportDAT:
2570 case SMESHOp::OpImportUNV:
2571 case SMESHOp::OpImportMED:
2572 case SMESHOp::OpImportSTL:
2573 case SMESHOp::OpImportCGNS:
2574 case SMESHOp::OpImportGMF:
2575 case SMESHOp::OpPopupImportDAT:
2576 case SMESHOp::OpPopupImportUNV:
2577 case SMESHOp::OpPopupImportMED:
2578 case SMESHOp::OpPopupImportSTL:
2579 case SMESHOp::OpPopupImportCGNS:
2580 case SMESHOp::OpPopupImportGMF:
2582 if(isStudyLocked()) break;
2583 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2587 case SMESHOp::OpFileInformation:
2589 SALOME_ListIO selected;
2590 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2592 aSel->selectedObjects( selected );
2593 if( selected.Extent() )
2595 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2596 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2597 if ( !aMesh->_is_nil() )
2599 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2605 case SMESHOp::OpExportDAT:
2606 case SMESHOp::OpExportMED:
2607 case SMESHOp::OpExportUNV:
2608 case SMESHOp::OpExportSTL:
2609 case SMESHOp::OpExportCGNS:
2610 case SMESHOp::OpExportGMF:
2611 case SMESHOp::OpPopupExportDAT:
2612 case SMESHOp::OpPopupExportMED:
2613 case SMESHOp::OpPopupExportUNV:
2614 case SMESHOp::OpPopupExportSTL:
2615 case SMESHOp::OpPopupExportCGNS:
2616 case SMESHOp::OpPopupExportGMF:
2618 ::ExportMeshToFile(theCommandID);
2622 case SMESHOp::OpReset: // SCALAR BAR
2624 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2625 SALOME_ListIO selected;
2627 aSel->selectedObjects( selected );
2629 SALOME_ListIteratorOfListIO it(selected);
2630 for( ; it.More(); it.Next()) {
2631 Handle(SALOME_InteractiveObject) anIO = it.Value();
2632 if( anIO->hasEntry() ) {
2633 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2634 anActor->SetControlMode( SMESH_Actor::eNone );
2635 #ifndef DISABLE_PLOT2DVIEWER
2636 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2638 anActor->UpdateFilter();
2642 SMESH::UpdateView();
2645 case SMESHOp::OpScalarBarProperties:
2647 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2650 case SMESHOp::OpShowScalarBar:
2652 // show/hide scalar bar
2653 ::ShowElement(theCommandID);
2656 case SMESHOp::OpSaveDistribution:
2658 // dump control distribution data to the text file
2659 ::SaveDistribution();
2663 case SMESHOp::OpShowDistribution:
2665 // show/hide distribution
2666 ::ShowElement(theCommandID);
2670 #ifndef DISABLE_PLOT2DVIEWER
2671 case SMESHOp::OpPlotDistribution:
2673 // plot distribution
2674 ::PlotDistribution();
2680 case SMESHOp::OpAutoColor:
2684 case SMESHOp::OpDisableAutoColor:
2685 ::DisableAutoColor();
2688 case SMESHOp::OpClipping:
2689 case SMESHOp::OpTransparency:
2690 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2693 case SMESHOp::OpDMWireframe:
2694 case SMESHOp::OpDMShading:
2695 case SMESHOp::OpDMNodes:
2696 case SMESHOp::OpDMShrink:
2697 ::SetDisplayMode(theCommandID, myMarkerMap);
2700 //2D quadratic representation
2701 case SMESHOp::OpRepresentationLines:
2702 case SMESHOp::OpRepresentationArcs:
2703 ::SetDisplayMode(theCommandID, myMarkerMap);
2707 case SMESHOp::OpDE0DElements:
2708 case SMESHOp::OpDEEdges:
2709 case SMESHOp::OpDEFaces:
2710 case SMESHOp::OpDEVolumes:
2711 case SMESHOp::OpDEBalls:
2712 case SMESHOp::OpDEAllEntity:
2713 ::SetDisplayEntity(theCommandID);
2716 // Choose entities to be displayed
2717 case SMESHOp::OpDEChoose:
2719 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2723 case SMESHOp::OpOrientationOnFaces:
2725 SUIT_OverrideCursor wc;
2726 LightApp_SelectionMgr* mgr = selectionMgr();
2727 SALOME_ListIO selected; mgr->selectedObjects( selected );
2729 SALOME_ListIteratorOfListIO it(selected);
2730 for( ; it.More(); it.Next()) {
2731 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2732 if(anIObject->hasEntry()) {
2733 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2734 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2741 case SMESHOp::OpUpdate:
2743 if(isStudyLocked()) break;
2744 SUIT_OverrideCursor wc;
2747 SMESH::UpdateView();
2749 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2750 SMESH::OnVisuException();
2752 catch (...) { // PAL16774 (Crash after display of many groups)
2753 SMESH::OnVisuException();
2757 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2758 aSel->selectedObjects( l );
2759 aSel->setSelectedObjects( l );
2763 case SMESHOp::OpHide:
2764 case SMESHOp::OpShow:
2765 case SMESHOp::OpShowOnly:
2767 SUIT_OverrideCursor wc;
2768 SMESH::EDisplaing anAction;
2769 switch (theCommandID) {
2770 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2771 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2772 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2775 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2776 SALOME_ListIO sel_objects, to_process;
2778 aSel->selectedObjects( sel_objects );
2780 if ( theCommandID==SMESHOp::OpShowOnly )
2782 //MESSAGE("anAction = SMESH::eDisplayOnly");
2783 startOperation( myEraseAll );
2786 extractContainers( sel_objects, to_process );
2791 SALOME_ListIteratorOfListIO It( to_process );
2792 for ( ; It.More(); It.Next())
2794 Handle(SALOME_InteractiveObject) IOS = It.Value();
2795 if ( IOS->hasEntry() )
2797 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2798 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2799 break; // PAL16774 (Crash after display of many groups)
2801 if (anAction == SMESH::eDisplayOnly)
2802 anAction = SMESH::eDisplay;
2807 // PAL13338 + PAL15161 -->
2808 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2809 SMESH::UpdateView();
2810 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2812 // PAL13338 + PAL15161 <--
2814 catch (...) { // PAL16774 (Crash after display of many groups)
2815 SMESH::OnVisuException();
2818 if (anAction == SMESH::eErase) {
2820 aSel->setSelectedObjects( l1 );
2823 aSel->setSelectedObjects( to_process );
2825 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2826 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2827 vtkwnd->GetRenderer()->AdjustActors();
2832 case SMESHOp::OpNode:
2834 if(isStudyLocked()) break;
2837 EmitSignalDeactivateDialog();
2839 ( new SMESHGUI_NodesDlg( this ) )->show();
2842 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2847 case SMESHOp::OpEditMeshOrSubMesh:
2848 case SMESHOp::OpEditMesh:
2849 case SMESHOp::OpEditSubMesh:
2850 case SMESHOp::OpMeshOrder:
2851 case SMESHOp::OpCreateSubMesh:
2852 if ( warnOnGeomModif() )
2853 break; // action forbidden as geometry modified
2855 case SMESHOp::OpCreateMesh:
2856 case SMESHOp::OpCompute:
2857 case SMESHOp::OpComputeSubMesh:
2858 case SMESHOp::OpPreCompute:
2859 case SMESHOp::OpEvaluate:
2860 case SMESHOp::OpShowErrors:
2861 startOperation( theCommandID );
2863 case SMESHOp::OpRecompute:
2865 if ( isStudyLocked() )
2867 SALOME_ListIO selected;
2868 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2869 sel->selectedObjects( selected );
2870 if ( selected.Extent() == 1 ) {
2871 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2872 if ( !aMesh->_is_nil() )
2874 startOperation( SMESHOp::OpCompute );
2878 case SMESHOp::OpCopyMesh:
2880 if (isStudyLocked()) break;
2881 EmitSignalDeactivateDialog();
2882 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2885 case SMESHOp::OpBuildCompoundMesh:
2887 if (isStudyLocked()) break;
2888 EmitSignalDeactivateDialog();
2889 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2893 case SMESHOp::OpDiagonalInversion:
2894 case SMESHOp::OpUnionOfTwoTriangle:
2898 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2902 if ( isStudyLocked() )
2904 if ( warnOnGeomModif() )
2905 break; // action forbidden as geometry modified
2907 /*Standard_Boolean aRes;
2908 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2909 if ( aMesh->_is_nil() )
2911 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2912 tr( "SMESH_BAD_SELECTION" ) );
2916 EmitSignalDeactivateDialog();
2917 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2918 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2920 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2923 case SMESHOp::OpOrientation:
2924 case SMESHOp::OpUnionOfTriangles:
2925 case SMESHOp::OpCuttingOfQuadrangles:
2926 case SMESHOp::OpSplitVolumes:
2930 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2934 if ( isStudyLocked() )
2936 if ( warnOnGeomModif() )
2937 break; // action forbidden as geometry modified
2939 EmitSignalDeactivateDialog();
2940 SMESHGUI_MultiEditDlg* aDlg = NULL;
2941 if ( theCommandID == SMESHOp::OpOrientation )
2942 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2943 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2944 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2945 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2946 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2948 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2953 case SMESHOp::OpSmoothing:
2955 if(isStudyLocked()) break;
2956 if ( warnOnGeomModif() )
2957 break; // action forbidden as geometry modified
2959 EmitSignalDeactivateDialog();
2960 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2963 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2967 case SMESHOp::OpExtrusion:
2969 if (isStudyLocked()) break;
2970 if ( warnOnGeomModif() )
2971 break; // action forbidden as geometry modified
2973 EmitSignalDeactivateDialog();
2974 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2976 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2980 case SMESHOp::OpExtrusionAlongAPath:
2982 if (isStudyLocked()) break;
2983 if ( warnOnGeomModif() )
2984 break; // action forbidden as geometry modified
2986 EmitSignalDeactivateDialog();
2987 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2989 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2993 case SMESHOp::OpRevolution:
2995 if(isStudyLocked()) break;
2996 if ( warnOnGeomModif() )
2997 break; // action forbidden as geometry modified
2999 EmitSignalDeactivateDialog();
3000 ( new SMESHGUI_RevolutionDlg( this ) )->show();
3003 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3007 case SMESHOp::OpPatternMapping:
3009 if ( isStudyLocked() )
3011 if ( warnOnGeomModif() )
3012 break; // action forbidden as geometry modified
3015 EmitSignalDeactivateDialog();
3016 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3019 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3023 // Adaptation - begin
3024 #ifndef DISABLE_MG_ADAPT
3025 case SMESHOp::OpMGAdapt:
3027 if ( isStudyLocked() )
3029 EmitSignalDeactivateDialog();
3031 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3032 bool isCreation = false;
3033 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3037 #ifndef DISABLE_HOMARD_ADAPT
3038 case SMESHOp::OpHomardAdapt:
3040 if ( isStudyLocked() )
3042 EmitSignalDeactivateDialog();
3044 SALOME::GenericObj_wrap< SMESHHOMARD::HOMARD_Gen > homardGen;
3046 homardGen = GetSMESHGen()->CreateHOMARD_ADAPT();
3048 catch ( const SALOME::SALOME_Exception& S_ex ) {
3049 SUIT_MessageBox::critical(SMESHGUI::desktop(),
3050 QObject::tr("SMESH_ERROR"),
3051 QObject::tr(S_ex.details.text.in()));
3053 if (!homardGen->_is_nil()) {
3054 SMESHGUI_HomardAdaptDlg *aDlg = new SMESHGUI_HomardAdaptDlg(homardGen);
3061 case SMESHOp::OpSplitBiQuadratic:
3062 case SMESHOp::OpConvertMeshToQuadratic:
3063 case SMESHOp::OpCreateDualMesh:
3064 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3065 case SMESHOp::OpCreate2DElements: // create full 2D mesh from 3D
3066 case SMESHOp::OpReorientFaces:
3067 case SMESHOp::OpCreateGeometryGroup:
3069 if ( warnOnGeomModif() )
3070 break; // action forbidden as geometry modified
3071 startOperation( theCommandID );
3074 case SMESHOp::OpCreateGroup:
3078 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3082 if(isStudyLocked()) break;
3083 if ( warnOnGeomModif() )
3084 break; // action forbidden as geometry modified
3085 EmitSignalDeactivateDialog();
3086 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3088 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3089 SALOME_ListIO selected;
3091 aSel->selectedObjects( selected );
3093 int nbSel = selected.Extent();
3095 // check if mesh is selected
3096 aMesh = SMESH::GetMeshByIO( selected.First() );
3098 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3103 case SMESHOp::OpConstructGroup:
3107 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3111 if(isStudyLocked()) break;
3112 if ( warnOnGeomModif() )
3113 break; // action forbidden as geometry modified
3114 EmitSignalDeactivateDialog();
3116 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3117 SALOME_ListIO selected;
3119 aSel->selectedObjects( selected );
3121 int nbSel = selected.Extent();
3123 // check if submesh is selected
3124 Handle(SALOME_InteractiveObject) IObject = selected.First();
3125 if (IObject->hasEntry()) {
3126 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3128 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3129 if (!aSubMesh->_is_nil()) {
3131 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3132 // get submesh elements list by types
3133 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3134 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3135 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3136 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3137 // create group for each type o elements
3138 QString aName = IObject->getName();
3139 QStringList anEntryList;
3140 if (aNodes->length() > 0) {
3141 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3142 aGroup->Add(aNodes.inout());
3143 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3144 anEntryList.append( aSObject->GetID().c_str() );
3146 if (aEdges->length() > 0) {
3147 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3148 aGroup->Add(aEdges.inout());
3149 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3150 anEntryList.append( aSObject->GetID().c_str() );
3152 if (aFaces->length() > 0) {
3153 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3154 aGroup->Add(aFaces.inout());
3155 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3156 anEntryList.append( aSObject->GetID().c_str() );
3158 if (aVolumes->length() > 0) {
3159 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3160 aGroup->Add(aVolumes.inout());
3161 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3162 anEntryList.append( aSObject->GetID().c_str() );
3165 anApp->browseObjects( anEntryList );
3167 catch(const SALOME::SALOME_Exception & S_ex){
3168 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3175 SUIT_MessageBox::warning(desktop(),
3176 tr("SMESH_WRN_WARNING"),
3177 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3182 case SMESHOp::OpEditGroup:
3186 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3190 if(isStudyLocked()) break;
3191 if ( warnOnGeomModif() )
3192 break; // action forbidden as geometry modified
3193 EmitSignalDeactivateDialog();
3195 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3196 SALOME_ListIO selected;
3198 aSel->selectedObjects( selected );
3200 SALOME_ListIteratorOfListIO It (selected);
3201 int nbSelectedGroups = 0;
3202 for ( ; It.More(); It.Next() )
3204 SMESH::SMESH_GroupBase_var aGroup =
3205 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3206 if (!aGroup->_is_nil()) {
3208 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3212 if (nbSelectedGroups == 0)
3214 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3220 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3222 if(isStudyLocked()) break;
3223 if (myState == 800) {
3224 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3225 if (aDlg) aDlg->onAdd();
3230 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3232 if(isStudyLocked()) break;
3233 if (myState == 800) {
3234 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3235 if (aDlg) aDlg->onRemove();
3240 case SMESHOp::OpEditGeomGroupAsGroup:
3244 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3248 if(isStudyLocked()) break;
3249 EmitSignalDeactivateDialog();
3251 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3252 SALOME_ListIO selected;
3254 aSel->selectedObjects( selected );
3256 SALOME_ListIteratorOfListIO It (selected);
3257 for ( ; It.More(); It.Next() )
3259 SMESH::SMESH_GroupOnGeom_var aGroup =
3260 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3261 if (!aGroup->_is_nil()) {
3262 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3267 SMESH::SMESH_GroupOnFilter_var aGroup =
3268 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3269 if (!aGroup->_is_nil()) {
3270 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3278 case SMESHOp::OpUnionGroups:
3279 case SMESHOp::OpIntersectGroups:
3280 case SMESHOp::OpCutGroups:
3284 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3288 if ( isStudyLocked() )
3290 if ( warnOnGeomModif() )
3291 break; // action forbidden as geometry modified
3293 EmitSignalDeactivateDialog();
3295 SMESHGUI_GroupOpDlg* aDlg = 0;
3296 if ( theCommandID == SMESHOp::OpUnionGroups )
3297 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3298 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3299 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3301 aDlg = new SMESHGUI_CutGroupsDlg( this );
3308 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3310 if ( isStudyLocked() )
3312 if ( warnOnGeomModif() )
3313 break; // action forbidden as geometry modified
3315 EmitSignalDeactivateDialog();
3316 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3322 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3324 if ( isStudyLocked() )
3326 if ( warnOnGeomModif() )
3327 break; // action forbidden as geometry modified
3329 EmitSignalDeactivateDialog();
3330 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3336 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3340 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3344 if ( isStudyLocked() )
3347 EmitSignalDeactivateDialog();
3349 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3353 case SMESHOp::OpMeshInformation:
3354 case SMESHOp::OpWhatIs:
3356 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3357 EmitSignalDeactivateDialog();
3358 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3359 SALOME_ListIO selected;
3361 aSel->selectedObjects( selected );
3363 if ( selected.Extent() > 1 ) { // a dlg for each IO
3364 SALOME_ListIteratorOfListIO It( selected );
3365 for ( ; It.More(); It.Next() ) {
3366 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3367 dlg->showInfo( It.Value() );
3372 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3378 case SMESHOp::OpFindElementByPoint:
3380 startOperation( theCommandID );
3384 case SMESHOp::OpEditHypothesis:
3386 if(isStudyLocked()) break;
3387 if ( warnOnGeomModif() )
3388 break; // action forbidden as geometry modified
3390 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3391 SALOME_ListIO selected;
3393 aSel->selectedObjects( selected );
3395 int nbSel = selected.Extent();
3398 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3399 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3401 if ( !aHypothesis->_is_nil() )
3403 SMESHGUI_GenericHypothesisCreator* aCreator =
3404 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3407 // set geometry of mesh and sub-mesh to aCreator
3408 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3409 if ( selected.Extent() == 1 )
3411 QString subGeomID, meshGeomID;
3412 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3413 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3415 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3416 aCreator->setShapeEntry( subGeomID );
3417 aCreator->setMainShapeEntry( meshGeomID );
3421 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3431 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3433 if(isStudyLocked()) break;
3434 if ( warnOnGeomModif() )
3435 break; // action forbidden as geometry modified
3436 SUIT_OverrideCursor wc;
3438 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3439 SALOME_ListIO selected;
3441 aSel->selectedObjects( selected, QString::null, false );
3443 SALOME_ListIteratorOfListIO It(selected);
3444 for (int i = 0; It.More(); It.Next(), i++) {
3445 Handle(SALOME_InteractiveObject) IObject = It.Value();
3446 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3449 aSel->setSelectedObjects( l1 );
3454 case SMESHOp::OpElem0D:
3455 case SMESHOp::OpBall:
3456 case SMESHOp::OpEdge:
3457 case SMESHOp::OpTriangle:
3458 case SMESHOp::OpQuadrangle:
3459 case SMESHOp::OpPolygon:
3460 case SMESHOp::OpTetrahedron:
3461 case SMESHOp::OpHexahedron:
3462 case SMESHOp::OpPentahedron:
3463 case SMESHOp::OpPyramid:
3464 case SMESHOp::OpHexagonalPrism:
3466 if(isStudyLocked()) break;
3467 if ( warnOnGeomModif() )
3468 break; // action forbidden as geometry modified
3470 EmitSignalDeactivateDialog();
3471 SMDSAbs_EntityType type = SMDSEntity_Edge;
3472 switch (theCommandID) {
3473 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3474 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3475 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3476 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3477 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3478 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3479 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3480 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3481 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3482 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3485 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3488 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3492 case SMESHOp::OpPolyhedron:
3494 if(isStudyLocked()) break;
3495 if ( warnOnGeomModif() )
3496 break; // action forbidden as geometry modified
3498 EmitSignalDeactivateDialog();
3499 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3502 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3506 case SMESHOp::OpQuadraticEdge:
3507 case SMESHOp::OpQuadraticTriangle:
3508 case SMESHOp::OpBiQuadraticTriangle:
3509 case SMESHOp::OpQuadraticQuadrangle:
3510 case SMESHOp::OpBiQuadraticQuadrangle:
3511 case SMESHOp::OpQuadraticPolygon:
3512 case SMESHOp::OpQuadraticTetrahedron:
3513 case SMESHOp::OpQuadraticPyramid:
3514 case SMESHOp::OpQuadraticPentahedron:
3515 case SMESHOp::OpBiQuadraticPentahedron:
3516 case SMESHOp::OpQuadraticHexahedron:
3517 case SMESHOp::OpTriQuadraticHexahedron:
3519 if(isStudyLocked()) break;
3520 if ( warnOnGeomModif() )
3521 break; // action forbidden as geometry modified
3523 EmitSignalDeactivateDialog();
3524 SMDSAbs_EntityType type = SMDSEntity_Last;
3526 switch (theCommandID) {
3527 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3528 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3529 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3530 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3531 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3532 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3533 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3534 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3535 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3536 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3537 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3538 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3541 if ( type != SMDSEntity_Last )
3542 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3545 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3546 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3550 case SMESHOp::OpRemoveNodes:
3552 if(isStudyLocked()) break;
3553 if ( warnOnGeomModif() )
3554 break; // action forbidden as geometry modified
3556 EmitSignalDeactivateDialog();
3557 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3560 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3561 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3565 case SMESHOp::OpRemoveNodeWithReconn:
3567 if(isStudyLocked()) break;
3568 if ( warnOnGeomModif() )
3569 break; // action forbidden as geometry modified
3570 startOperation( SMESHOp::OpRemoveNodeWithReconn );
3573 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3575 if(isStudyLocked()) break;
3576 if ( warnOnGeomModif() )
3577 break; // action forbidden as geometry modified
3579 EmitSignalDeactivateDialog();
3580 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3584 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3585 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3589 case SMESHOp::OpClearMesh: {
3591 if(isStudyLocked()) break;
3592 if ( warnOnGeomModif() )
3593 break; // action forbidden as geometry modified
3595 SALOME_ListIO selected;
3596 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3597 aSel->selectedObjects( selected );
3599 SUIT_OverrideCursor wc;
3600 SALOME_ListIteratorOfListIO It (selected);
3601 for ( ; It.More(); It.Next() )
3603 Handle(SALOME_InteractiveObject) IOS = It.Value();
3604 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3605 if ( aMesh->_is_nil()) continue;
3608 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3609 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3610 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3611 // hide groups and submeshes
3612 _PTR(ChildIterator) anIter =
3613 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3614 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3616 _PTR(SObject) so = anIter->Value();
3617 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3620 catch (const SALOME::SALOME_Exception& S_ex){
3622 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3626 SMESH::UpdateView();
3630 case SMESHOp::OpRemoveOrphanNodes:
3632 if(isStudyLocked()) break;
3633 if ( warnOnGeomModif() )
3634 break; // action forbidden as geometry modified
3635 SALOME_ListIO selected;
3636 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3637 aSel->selectedObjects( selected );
3638 if ( selected.Extent() == 1 ) {
3639 Handle(SALOME_InteractiveObject) anIO = selected.First();
3640 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3641 if ( !aMesh->_is_nil() ) {
3642 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3643 tr( "SMESH_WARNING" ),
3644 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3645 SUIT_MessageBox::Yes |
3646 SUIT_MessageBox::No,
3647 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3650 SUIT_OverrideCursor wc;
3651 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3652 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3653 SUIT_MessageBox::information(SMESHGUI::desktop(),
3654 tr("SMESH_INFORMATION"),
3655 tr("NB_NODES_REMOVED").arg(removed));
3656 if ( removed > 0 ) {
3657 SMESH::UpdateView();
3658 SMESHGUI::Modified();
3661 catch (const SALOME::SALOME_Exception& S_ex) {
3662 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3671 case SMESHOp::OpRenumberingNodes:
3673 if(isStudyLocked()) break;
3674 if ( warnOnGeomModif() )
3675 break; // action forbidden as geometry modified
3677 EmitSignalDeactivateDialog();
3678 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3682 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3683 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3687 case SMESHOp::OpRenumberingElements:
3689 if(isStudyLocked()) break;
3690 if ( warnOnGeomModif() )
3691 break; // action forbidden as geometry modified
3693 EmitSignalDeactivateDialog();
3694 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3698 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3699 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3703 case SMESHOp::OpTranslation:
3705 if(isStudyLocked()) break;
3706 if ( warnOnGeomModif() )
3707 break; // action forbidden as geometry modified
3709 EmitSignalDeactivateDialog();
3710 ( new SMESHGUI_TranslationDlg( this ) )->show();
3713 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3714 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3718 case SMESHOp::OpRotation:
3720 if(isStudyLocked()) break;
3721 if ( warnOnGeomModif() )
3722 break; // action forbidden as geometry modified
3724 EmitSignalDeactivateDialog();
3725 ( new SMESHGUI_RotationDlg( this ) )->show();
3728 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3729 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3733 case SMESHOp::OpSymmetry:
3735 if(isStudyLocked()) break;
3736 if ( warnOnGeomModif() )
3737 break; // action forbidden as geometry modified
3739 EmitSignalDeactivateDialog();
3740 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3743 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3744 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3748 case SMESHOp::OpScale:
3750 if(isStudyLocked()) break;
3751 if ( warnOnGeomModif() )
3752 break; // action forbidden as geometry modified
3754 EmitSignalDeactivateDialog();
3755 ( new SMESHGUI_ScaleDlg( this ) )->show();
3758 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3759 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3764 case SMESHOp::OpOffset:
3766 if(isStudyLocked()) break;
3767 if ( warnOnGeomModif() )
3768 break; // action forbidden as geometry modified
3770 EmitSignalDeactivateDialog();
3771 ( new SMESHGUI_OffsetDlg( this ) )->show();
3774 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3775 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3780 case SMESHOp::OpSewing:
3782 if(isStudyLocked()) break;
3783 if ( warnOnGeomModif() )
3784 break; // action forbidden as geometry modified
3786 EmitSignalDeactivateDialog();
3787 ( new SMESHGUI_SewingDlg( this ) )->show();
3790 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3791 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3795 case SMESHOp::OpMergeNodes:
3797 if(isStudyLocked()) break;
3798 if ( warnOnGeomModif() )
3799 break; // action forbidden as geometry modified
3801 EmitSignalDeactivateDialog();
3802 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3805 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3806 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3810 case SMESHOp::OpMergeElements:
3812 if (isStudyLocked()) break;
3813 if ( warnOnGeomModif() )
3814 break; // action forbidden as geometry modified
3816 EmitSignalDeactivateDialog();
3817 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3819 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3820 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3825 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3826 if ( warnOnGeomModif() )
3827 break; // action forbidden as geometry modified
3828 startOperation( SMESHOp::OpMoveNode );
3831 case SMESHOp::OpMoveNodeInteractive:
3832 if ( warnOnGeomModif() )
3833 break; // action forbidden as geometry modified
3834 startOperation( SMESHOp::OpMoveNodeInteractive );
3837 case SMESHOp::OpSplitEdgeInteract:
3838 if ( warnOnGeomModif() )
3839 break; // action forbidden as geometry modified
3840 startOperation( SMESHOp::OpSplitEdgeInteract );
3843 case SMESHOp::OpSplitFaceInteract:
3844 if ( warnOnGeomModif() )
3845 break; // action forbidden as geometry modified
3846 startOperation( SMESHOp::OpSplitFaceInteract );
3849 case SMESHOp::OpDuplicateNodes:
3851 if(isStudyLocked()) break;
3852 if ( warnOnGeomModif() )
3853 break; // action forbidden as geometry modified
3855 EmitSignalDeactivateDialog();
3856 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3859 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3860 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3865 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3866 if ( warnOnGeomModif() )
3867 break; // action forbidden as geometry modified
3868 startOperation( SMESHOp::OpElem0DOnElemNodes );
3871 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3873 static QList<int> aTypes;
3874 if ( aTypes.isEmpty() )
3876 aTypes.append( SMESH::NODE );
3877 aTypes.append( SMESH::EDGE );
3878 aTypes.append( SMESH::FACE );
3879 aTypes.append( SMESH::VOLUME );
3881 if (!myFilterLibraryDlg)
3882 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3883 else if (myFilterLibraryDlg->isHidden())
3884 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3885 myFilterLibraryDlg->raise();
3889 case SMESHOp::OpFreeNode:
3890 case SMESHOp::OpEqualNode:
3891 case SMESHOp::OpNodeConnectivityNb:
3892 case SMESHOp::OpFreeEdge:
3893 case SMESHOp::OpFreeBorder:
3894 case SMESHOp::OpLength:
3895 case SMESHOp::OpConnection:
3896 case SMESHOp::OpEqualEdge:
3897 case SMESHOp::OpFreeFace:
3898 case SMESHOp::OpBareBorderFace:
3899 case SMESHOp::OpOverConstrainedFace:
3900 case SMESHOp::OpLength2D:
3901 case SMESHOp::OpDeflection2D:
3902 case SMESHOp::OpConnection2D:
3903 case SMESHOp::OpArea:
3904 case SMESHOp::OpTaper:
3905 case SMESHOp::OpAspectRatio:
3906 case SMESHOp::OpMinimumAngle:
3907 case SMESHOp::OpWarpingAngle:
3908 case SMESHOp::OpSkew:
3909 case SMESHOp::OpMaxElementLength2D:
3910 case SMESHOp::OpEqualFace:
3911 case SMESHOp::OpAspectRatio3D:
3912 case SMESHOp::OpWarping3D:
3913 case SMESHOp::OpVolume:
3914 case SMESHOp::OpScaledJacobian:
3915 case SMESHOp::OpMaxElementLength3D:
3916 case SMESHOp::OpBareBorderVolume:
3917 case SMESHOp::OpOverConstrainedVolume:
3918 case SMESHOp::OpEqualVolume:
3921 LightApp_SelectionMgr* mgr = selectionMgr();
3922 SALOME_ListIO selected; mgr->selectedObjects( selected );
3924 if( !selected.IsEmpty() ) {
3925 SUIT_OverrideCursor wc;
3926 ::Control( theCommandID );
3929 SUIT_MessageBox::warning(desktop(),
3930 tr( "SMESH_WRN_WARNING" ),
3931 tr( "SMESH_BAD_SELECTION" ) );
3935 SUIT_MessageBox::warning(desktop(),
3936 tr( "SMESH_WRN_WARNING" ),
3937 tr( "NOT_A_VTK_VIEWER" ) );
3940 case SMESHOp::OpOverallMeshQuality:
3941 OverallMeshQuality();
3943 case SMESHOp::OpNumberingNodes:
3945 SUIT_OverrideCursor wc;
3946 LightApp_SelectionMgr* mgr = selectionMgr();
3947 SALOME_ListIO selected; mgr->selectedObjects( selected );
3949 SALOME_ListIteratorOfListIO it(selected);
3950 for( ; it.More(); it.Next()) {
3951 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3952 if(anIObject->hasEntry()) {
3953 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3954 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3960 case SMESHOp::OpNumberingElements:
3962 SUIT_OverrideCursor wc;
3963 LightApp_SelectionMgr* mgr = selectionMgr();
3964 SALOME_ListIO selected; mgr->selectedObjects( selected );
3966 SALOME_ListIteratorOfListIO it(selected);
3967 for( ; it.More(); it.Next()) {
3968 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3969 if(anIObject->hasEntry())
3970 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3971 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3976 case SMESHOp::OpPropertiesLength:
3977 case SMESHOp::OpPropertiesArea:
3978 case SMESHOp::OpPropertiesVolume:
3979 case SMESHOp::OpMinimumDistance:
3980 case SMESHOp::OpBoundingBox:
3981 case SMESHOp::OpAngle:
3983 int page = SMESHGUI_MeasureDlg::MinDistance;
3984 if ( theCommandID == SMESHOp::OpBoundingBox )
3985 page = SMESHGUI_MeasureDlg::BoundingBox;
3986 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3987 page = SMESHGUI_MeasureDlg::Length;
3988 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3989 page = SMESHGUI_MeasureDlg::Area;
3990 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3991 page = SMESHGUI_MeasureDlg::Volume;
3992 else if ( theCommandID == SMESHOp::OpAngle )
3993 page = SMESHGUI_MeasureDlg::Angle;
3995 EmitSignalDeactivateDialog();
3996 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
4000 case SMESHOp::OpSortChild:
4003 case SMESHOp::OpBreakLink:
4004 ::breakShaperLink();
4009 anApp->updateActions(); //SRN: To update a Save button in the toolbar
4010 //updateObjBrowser();
4014 //=============================================================================
4018 //=============================================================================
4019 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4024 //=============================================================================
4028 //=============================================================================
4029 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4034 //=============================================================================
4038 //=============================================================================
4039 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4044 //=============================================================================
4045 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
4046 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
4048 //=============================================================================
4049 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
4050 SUIT_ViewWindow* wnd )
4052 if(theIO->hasEntry()){
4053 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
4054 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
4058 //=======================================================================
4059 // function : createSMESHAction
4061 //=======================================================================
4062 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
4063 const int key, const bool toggle, const QString& shortcutAction )
4066 QWidget* parent = application()->desktop();
4067 SUIT_ResourceMgr* resMgr = resourceMgr();
4069 if ( !icon_id.isEmpty() )
4070 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4072 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4073 if ( !pix.isNull() )
4074 icon = QIcon( pix );
4076 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4077 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4078 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4080 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4081 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4084 //=======================================================================
4085 // function : createPopupItem
4087 //=======================================================================
4088 void SMESHGUI::createPopupItem( const int id,
4089 const QString& clients,
4090 const QString& types,
4091 const QString& theRule,
4094 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4095 popupMgr()->insert( action( id ), pId, 0 );
4097 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4098 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4099 QString rule = "(%1) and (%2) and (%3)";
4100 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4101 if( clients.isEmpty() )
4102 rule = rule.arg( QString( "true" ) );
4104 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4105 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4108 bool cont = myRules.contains( id );
4110 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4112 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4113 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4116 //=======================================================================
4117 // function : initialize
4119 //=======================================================================
4120 void SMESHGUI::initialize( CAM_Application* app )
4122 SalomeApp_Module::initialize( app );
4124 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4126 /* Automatic Update flag */
4127 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4129 // ----- create actions --------------
4131 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4132 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4133 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4134 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4136 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4138 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4139 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4140 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4141 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4143 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4145 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4147 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4148 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4149 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4150 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4152 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4154 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4155 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4156 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4157 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4158 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4160 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4162 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4163 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4164 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4165 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4166 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4167 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4168 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4169 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4170 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4171 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4172 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4173 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4174 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4175 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4176 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4177 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4178 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4179 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4180 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4181 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4182 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4183 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4184 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4185 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4186 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4187 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4188 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4189 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4190 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4191 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4192 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4193 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4194 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4195 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4196 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4198 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4199 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4200 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4201 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4202 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4203 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4204 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4205 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4206 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4207 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4208 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4209 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4210 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4211 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4212 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4213 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4214 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4215 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4216 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4217 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4218 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4219 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4220 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4221 createSMESHAction( SMESHOp::OpWarping3D, "WARP_3D", "ICON_WARP", 0, true);
4222 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4223 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4224 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4225 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4226 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4227 createSMESHAction( SMESHOp::OpScaledJacobian, "SCALED_JACOBIAN", "ICON_SCALED_JACOBIAN", 0, true );
4228 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4230 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4231 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4232 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4233 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4234 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4235 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4236 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4237 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4238 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4239 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4240 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4241 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4242 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4243 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4244 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4245 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4246 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4247 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4248 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4249 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4250 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4251 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4252 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4253 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4254 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4255 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4257 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4258 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4259 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4260 createSMESHAction( SMESHOp::OpRemoveNodeWithReconn, "REMOVE_NODE_RECON", "ICON_REM_NODE_RECON" );
4261 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4263 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4264 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4266 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4267 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4268 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4269 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4270 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4271 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4272 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4273 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4274 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4275 createSMESHAction( SMESHOp::OpMoveNodeInteractive, "MOVE_NODE_INTRCT","ICON_DLG_MOVE_NODE_INTERACTIVE" );
4276 createSMESHAction( SMESHOp::OpSplitEdgeInteract, "SPLIT_DIAG_INTRC","ICON_SPLIT_DIAG_INTERACTIVE" );
4277 createSMESHAction( SMESHOp::OpSplitFaceInteract, "SPLIT_FACE_INTRC","ICON_SPLIT_FACE_INTERACTIVE" );
4278 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4279 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4280 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4281 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4282 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4283 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4284 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4285 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4286 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4287 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4288 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4289 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4290 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4291 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4292 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4293 createSMESHAction( SMESHOp::OpCreateDualMesh, "CREATE_DUAL_MESH","ICON_CREATE_DUAL_MESH" );
4294 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4295 createSMESHAction( SMESHOp::OpCreate2DElements, "2D_FROM_3D_ELEMENTS","ICON_2D_FROM_3D_ELEMENTS" );
4297 createSMESHAction( SMESHOp::OpReset, "RESET" );
4298 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4299 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4300 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4301 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4302 #ifndef DISABLE_PLOT2DVIEWER
4303 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4305 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4306 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4307 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4308 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4309 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4310 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4311 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4312 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4313 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4314 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4315 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4316 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4317 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4319 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4320 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4322 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4323 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4324 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4325 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4326 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4327 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4328 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4329 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4330 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4332 // Adaptation - begin
4333 #ifndef DISABLE_MG_ADAPT
4334 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4336 #ifndef DISABLE_HOMARD_ADAPT
4337 createSMESHAction( SMESHOp::OpHomardAdapt, "HOMARD_ADAPT", "ICON_HOMARD_ADAPT" );
4341 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4342 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4343 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4344 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4345 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4346 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4348 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4349 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4350 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4352 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4354 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4356 QList<int> aCtrlActions;
4357 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4358 << SMESHOp::OpNodeConnectivityNb // node controls
4359 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4360 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4361 << SMESHOp::OpDeflection2D
4362 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4363 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4364 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4365 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4366 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4367 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume << SMESHOp::OpWarping3D
4368 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4369 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume << SMESHOp::OpScaledJacobian; // volume controls
4370 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4371 aCtrlGroup->setExclusive( true );
4372 for( int i = 0; i < aCtrlActions.size(); i++ )
4373 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4375 // ----- create menu --------------
4376 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4377 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4378 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4379 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4380 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4381 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4382 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4383 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4385 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4386 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4388 createMenu( separator(), fileId );
4390 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4391 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4392 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4393 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4394 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4395 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4396 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4397 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4398 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4399 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4400 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4401 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4402 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4404 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4405 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4406 createMenu( SMESHOp::OpImportMED, importId, -1 );
4407 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4409 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4411 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4412 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4413 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4414 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4415 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4417 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4419 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4420 createMenu( separator(), fileId, 10 );
4422 createMenu( SMESHOp::OpDelete, editId, -1 );
4424 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4426 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4427 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4428 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4429 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4430 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4431 createMenu( SMESHOp::OpCreateDualMesh, meshId, -1 );
4432 createMenu( separator(), meshId, -1 );
4433 createMenu( SMESHOp::OpCompute, meshId, -1 );
4434 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4435 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4436 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4437 createMenu( separator(), meshId, -1 );
4438 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4439 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4440 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4441 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4442 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4443 createMenu( separator(), meshId, -1 );
4444 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4445 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4446 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4447 createMenu( separator(), meshId, -1 );
4448 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4449 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4450 createMenu( separator(), meshId, -1 );
4451 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4452 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4453 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4454 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4455 createMenu( separator(), meshId, -1 );
4457 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4458 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4459 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4460 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4461 createMenu( SMESHOp::OpLength, edgeId, -1 );
4462 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4463 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4464 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4465 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4466 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4467 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4468 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4469 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4470 createMenu( SMESHOp::OpArea, faceId, -1 );
4471 createMenu( SMESHOp::OpTaper, faceId, -1 );
4472 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4473 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4474 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4475 createMenu( SMESHOp::OpSkew, faceId, -1 );
4476 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4477 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4478 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4479 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4480 createMenu( SMESHOp::OpWarping3D, volumeId, -1 );
4481 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4482 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4483 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4484 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4485 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4486 createMenu( SMESHOp::OpScaledJacobian, volumeId, -1 );
4487 createMenu( separator(), ctrlId, -1 );
4488 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4489 createMenu( separator(), ctrlId, -1 );
4490 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4492 createMenu( SMESHOp::OpNode, addId, -1 );
4493 createMenu( SMESHOp::OpElem0D, addId, -1 );
4494 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4495 createMenu( SMESHOp::OpBall, addId, -1 );
4496 createMenu( SMESHOp::OpEdge, addId, -1 );
4497 createMenu( SMESHOp::OpTriangle, addId, -1 );
4498 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4499 createMenu( SMESHOp::OpPolygon, addId, -1 );
4500 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4501 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4502 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4503 createMenu( SMESHOp::OpPyramid, addId, -1 );
4504 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4505 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4506 createMenu( separator(), addId, -1 );
4507 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4508 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4509 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4510 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4511 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4512 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4513 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4514 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4515 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4516 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4517 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4518 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4519 createMenu( separator(), addId, -1 );
4520 createMenu( SMESHOp::OpSplitEdgeInteract, addId, -1 );
4521 createMenu( SMESHOp::OpSplitFaceInteract, addId, -1 );
4523 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4524 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4525 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4526 createMenu( SMESHOp::OpRemoveNodeWithReconn, removeId, -1 );
4527 createMenu( separator(), removeId, -1 );
4528 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4529 createMenu( separator(), removeId, -1 );
4530 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4532 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4533 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4535 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4536 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4537 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4538 createMenu( SMESHOp::OpRotation, transfId, -1 );
4539 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4540 createMenu( SMESHOp::OpScale, transfId, -1 );
4541 createMenu( SMESHOp::OpOffset, transfId, -1 );
4542 createMenu( SMESHOp::OpSewing, transfId, -1 );
4543 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4545 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4546 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4547 createMenu( SMESHOp::OpCreate2DElements, modifyId, -1 );
4548 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4549 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4550 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4551 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4552 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4553 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4554 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4555 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4556 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4557 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4558 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4559 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4560 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4561 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4563 // Adaptation - begin
4564 #ifndef DISABLE_MG_ADAPT
4565 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4567 #ifndef DISABLE_HOMARD_ADAPT
4568 createMenu( SMESHOp::OpHomardAdapt, adaptId, -1 );
4572 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4573 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4574 createMenu( SMESHOp::OpAngle, measureId, -1 );
4575 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4576 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4577 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4578 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4580 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4581 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4582 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4583 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4585 // ----- create toolbars --------------
4586 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4587 createTool( SMESHOp::OpCreateMesh, meshTb );
4588 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4589 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4590 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4591 createTool( SMESHOp::OpCopyMesh, meshTb );
4592 createTool( separator(), meshTb );
4593 createTool( SMESHOp::OpCompute, meshTb );
4594 createTool( SMESHOp::OpPreCompute, meshTb );
4595 createTool( SMESHOp::OpEvaluate, meshTb );
4596 createTool( SMESHOp::OpMeshOrder, meshTb );
4598 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4599 createTool( SMESHOp::OpMeshInformation, infoTb );
4600 //createTool( SMESHOp::OpStdInfo, meshTb );
4601 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4602 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4604 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4605 createTool( SMESHOp::OpCreateGroup, groupTb );
4606 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4607 createTool( SMESHOp::OpConstructGroup, groupTb );
4608 createTool( SMESHOp::OpEditGroup, groupTb );
4610 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4611 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4612 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4613 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4615 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4616 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4617 createTool( SMESHOp::OpLength, ctrl1dTb );
4618 createTool( SMESHOp::OpConnection, ctrl1dTb );
4619 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4621 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4622 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4623 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4624 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4625 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4626 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4627 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4628 createTool( SMESHOp::OpArea, ctrl2dTb );
4629 createTool( SMESHOp::OpTaper, ctrl2dTb );
4630 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4631 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4632 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4633 createTool( SMESHOp::OpSkew, ctrl2dTb );
4634 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4635 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4636 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4638 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4639 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4640 createTool( SMESHOp::OpWarping3D, ctrl3dTb );
4641 createTool( SMESHOp::OpVolume, ctrl3dTb );
4642 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4643 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4644 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4645 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4646 createTool( SMESHOp::OpScaledJacobian, ctrl3dTb );
4648 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4649 createTool( SMESHOp::OpNode, addElemTb );
4650 createTool( SMESHOp::OpElem0D, addElemTb );
4651 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4652 createTool( SMESHOp::OpBall, addElemTb );
4653 createTool( SMESHOp::OpEdge, addElemTb );
4654 createTool( SMESHOp::OpTriangle, addElemTb );
4655 createTool( SMESHOp::OpQuadrangle, addElemTb );
4656 createTool( SMESHOp::OpPolygon, addElemTb );
4657 createTool( SMESHOp::OpTetrahedron, addElemTb );
4658 createTool( SMESHOp::OpHexahedron, addElemTb );
4659 createTool( SMESHOp::OpPentahedron, addElemTb );
4660 createTool( SMESHOp::OpPyramid, addElemTb );
4661 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4662 createTool( SMESHOp::OpPolyhedron, addElemTb );
4664 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4665 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4666 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4667 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4668 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4669 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4670 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4671 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4672 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4673 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4674 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4675 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4676 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4678 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4679 createTool( SMESHOp::OpRemoveNodes, remTb );
4680 createTool( SMESHOp::OpRemoveElements, remTb );
4681 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4682 createTool( SMESHOp::OpClearMesh, remTb );
4684 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4685 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4686 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4688 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4689 createTool( SMESHOp::OpMergeNodes, transformTb );
4690 createTool( SMESHOp::OpMergeElements, transformTb );
4691 createTool( SMESHOp::OpTranslation, transformTb );
4692 createTool( SMESHOp::OpRotation, transformTb );
4693 createTool( SMESHOp::OpSymmetry, transformTb );
4694 createTool( SMESHOp::OpScale, transformTb );
4695 createTool( SMESHOp::OpOffset, transformTb );
4696 createTool( SMESHOp::OpSewing, transformTb );
4697 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4699 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4700 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4701 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4702 createTool( SMESHOp::OpCreate2DElements, modifyTb );
4703 createTool( SMESHOp::OpExtrusion, modifyTb );
4704 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4705 createTool( SMESHOp::OpRevolution, modifyTb );
4706 createTool( SMESHOp::OpOrientation, modifyTb );
4707 createTool( SMESHOp::OpReorientFaces, modifyTb );
4708 createTool( SMESHOp::OpMoveNode, modifyTb );
4709 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4710 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4711 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4712 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4713 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4714 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4715 createTool( SMESHOp::OpSmoothing, modifyTb );
4716 createTool( SMESHOp::OpPatternMapping, modifyTb );
4718 int interactTb = createTool( tr( "TB_INTERACT" ), QString( "SMESHInteractiveToolbar" ) ) ;
4719 createTool( SMESHOp::OpMoveNodeInteractive, interactTb );
4720 createTool( SMESHOp::OpRemoveNodeWithReconn, interactTb );
4721 createTool( SMESHOp::OpSplitEdgeInteract, interactTb );
4722 createTool( SMESHOp::OpSplitFaceInteract, interactTb );
4724 // Adaptation - begin
4725 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4726 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4728 #ifndef DISABLE_MG_ADAPT
4729 createTool( SMESHOp::OpMGAdapt, adaptTb );
4731 #ifndef DISABLE_HOMARD_ADAPT
4732 createTool( SMESHOp::OpHomardAdapt, adaptTb );
4736 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4737 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4739 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4740 createTool( SMESHOp::OpUpdate, dispModeTb );
4742 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4743 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4747 OB = "'ObjectBrowser'",
4748 View = "'" + SVTK_Viewer::Type() + "'",
4750 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4751 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4752 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4753 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4754 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4755 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4756 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4757 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4758 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4759 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4760 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4761 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4763 mesh_part = mesh + " " + subMesh + " " + group,
4764 mesh_group = mesh + " " + group,
4765 mesh_submesh = mesh + " " + subMesh,
4766 hyp_alg = hypo + " " + algo;
4768 // popup for object browser
4770 isInvisible("not( isVisible )"),
4771 isEmpty("numberOfNodes = 0"),
4772 isNotEmpty("numberOfNodes <> 0"),
4774 // has nodes, edges, etc in VISIBLE! actor
4775 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4776 hasElems("(count( elemTypes ) > 0)"),
4777 hasDifferentElems("(count( elemTypes ) > 1)"),
4778 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4779 hasBalls("({'BallElem'} in elemTypes)"),
4780 hasElems0d("({'Elem0d'} in elemTypes)"),
4781 hasEdges("({'Edge'} in elemTypes)"),
4782 hasFaces("({'Face'} in elemTypes)"),
4783 hasVolumes("({'Volume'} in elemTypes)"),
4784 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4786 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4787 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4788 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4789 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4790 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4791 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4793 popupMgr()->insert( separator(), -1, 0 );
4794 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4795 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4796 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4797 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4798 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4799 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4800 popupMgr()->insert( separator(), -1, 0 );
4801 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4802 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4803 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4804 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4805 popupMgr()->insert( separator(), -1, 0 );
4806 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4807 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4808 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4809 popupMgr()->insert( separator(), -1, 0 );
4810 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4811 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4812 popupMgr()->insert( separator(), -1, 0 );
4813 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4814 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4816 // Adaptation - begin
4817 popupMgr()->insert( separator(), -1, 0 );
4818 #ifndef DISABLE_MG_ADAPT
4819 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4821 #ifndef DISABLE_HOMARD_ADAPT
4822 createPopupItem( SMESHOp::OpHomardAdapt, OB, mesh );
4824 popupMgr()->insert( separator(), -1, 0 );
4827 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4828 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4829 QString only_one_2D = only_one_non_empty + " && dim>1";
4831 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4832 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4833 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4834 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4835 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4837 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4839 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4840 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4842 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4843 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4844 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4845 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4847 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4849 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4850 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4851 popupMgr()->insert( separator(), -1, 0 );
4853 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4854 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4855 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4858 createPopupItem( SMESHOp::OpEditGroup, View, group );
4859 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4860 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4862 popupMgr()->insert( separator(), -1, 0 );
4863 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4864 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4865 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4866 popupMgr()->insert( separator(), -1, 0 );
4868 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
4869 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4870 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4871 popupMgr()->insert( separator(), -1, 0 );
4873 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4874 QString aType = QString( "%1type in {%2}" ).arg( lc );
4875 aType = aType.arg( mesh_part );
4876 QString aMeshInVTK = aClient + "&&" + aType;
4878 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4879 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4880 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4882 //-------------------------------------------------
4884 //-------------------------------------------------
4885 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4887 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4888 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4889 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4891 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4892 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4893 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4895 popupMgr()->insert( separator(), -1, -1 );
4897 //-------------------------------------------------
4899 //-------------------------------------------------
4900 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4902 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4903 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4904 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4906 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4907 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4908 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4910 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4911 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4912 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4914 popupMgr()->insert( separator(), anId, -1 );
4916 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4917 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4918 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4920 //-------------------------------------------------
4922 //-------------------------------------------------
4923 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4925 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4927 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4928 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4929 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4931 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4932 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4933 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4935 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4936 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4937 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4939 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4940 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4941 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4943 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4944 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4945 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4947 popupMgr()->insert( separator(), anId, -1 );
4949 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4950 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4952 popupMgr()->insert( separator(), anId, -1 );
4954 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4955 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4958 //-------------------------------------------------
4959 // Representation of the 2D Quadratic elements
4960 //-------------------------------------------------
4961 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4962 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4963 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4964 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4966 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4967 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4968 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4970 //-------------------------------------------------
4971 // Orientation of faces
4972 //-------------------------------------------------
4973 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4974 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4975 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4977 //-------------------------------------------------
4979 //-------------------------------------------------
4980 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4981 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4983 //-------------------------------------------------
4985 //-------------------------------------------------
4986 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4987 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4989 //-------------------------------------------------
4991 //-------------------------------------------------
4993 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4994 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4995 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4996 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4998 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
5000 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
5001 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5003 popupMgr()->insert( separator(), anId, -1 );
5005 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
5007 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
5008 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5009 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
5011 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
5012 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5013 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
5015 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
5016 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5017 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
5019 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
5021 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
5022 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
5023 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
5025 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
5026 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5027 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
5029 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
5030 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5031 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
5032 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
5033 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5034 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
5036 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
5038 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
5039 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5040 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
5042 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
5043 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
5044 QtxPopupMgr::VisibleRule );
5045 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
5047 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
5048 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5049 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
5051 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
5052 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5053 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
5055 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
5056 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5057 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
5059 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
5060 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5061 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
5063 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
5064 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5065 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
5067 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
5068 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5069 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
5071 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
5072 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5073 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
5075 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
5076 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5077 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
5079 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
5080 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5081 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
5083 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
5084 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5085 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
5087 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
5088 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5089 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
5091 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
5092 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5093 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
5095 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
5096 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
5097 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
5099 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
5101 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
5102 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5103 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
5105 popupMgr()->insert ( action( SMESHOp::OpWarping3D ), aSubId, -1 );
5106 popupMgr()->setRule( action( SMESHOp::OpWarping3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5107 popupMgr()->setRule( action( SMESHOp::OpWarping3D), "controlMode = 'eWarping3D'", QtxPopupMgr::ToggleRule );
5109 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
5110 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5111 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
5113 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
5114 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5115 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5117 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5118 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5119 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5121 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5122 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5123 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5125 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5126 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5127 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5129 popupMgr()->insert ( action( SMESHOp::OpScaledJacobian ), aSubId, -1 );
5130 popupMgr()->setRule( action( SMESHOp::OpScaledJacobian ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5131 popupMgr()->setRule( action( SMESHOp::OpScaledJacobian ), "controlMode = 'eScaledJacobian'", QtxPopupMgr::ToggleRule );
5133 popupMgr()->insert( separator(), anId, -1 );
5135 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5136 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5137 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5138 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5139 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5141 popupMgr()->insert( separator(), anId, -1 );
5143 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5145 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5146 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5148 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5149 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5150 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5152 #ifndef DISABLE_PLOT2DVIEWER
5153 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5154 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5157 //-------------------------------------------------
5159 //-------------------------------------------------
5160 popupMgr()->insert( separator(), -1, -1 );
5161 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5162 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5163 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5164 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5166 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5167 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5169 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5170 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5172 popupMgr()->insert( separator(), -1, -1 );
5174 //-------------------------------------------------
5176 //-------------------------------------------------
5177 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5178 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5180 popupMgr()->insert( separator(), -1, -1 );
5182 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5183 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5184 popupMgr()->insert( separator(), -1, -1 );
5186 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5187 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5189 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5190 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5192 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5193 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5196 //================================================================================
5198 * \brief Return true if SMESH or GEOM objects are selected.
5199 * Is called form LightApp_Module::activateModule() which clear selection if
5200 * not isSelectionCompatible()
5202 //================================================================================
5204 bool SMESHGUI::isSelectionCompatible()
5206 bool isCompatible = true;
5207 SALOME_ListIO selected;
5208 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5209 Sel->selectedObjects( selected );
5211 SALOME_ListIteratorOfListIO It( selected );
5212 for ( ; isCompatible && It.More(); It.Next())
5214 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5215 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5216 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5218 return isCompatible;
5222 bool SMESHGUI::reusableOperation( const int id )
5224 // compute, evaluate and precompute are not reusable operations
5225 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5230 QString wrap(const QString& text, const QString& tag)
5231 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5234 bool SMESHGUI::activateModule( SUIT_Study* study )
5236 bool res = SalomeApp_Module::activateModule( study );
5238 setMenuShown( true );
5239 setToolShown( true );
5241 // Fill in Help Panel
5242 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5243 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5245 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5248 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5249 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5250 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5251 lab = lab + tr("INFO_REFINE") + ":";
5252 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5253 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5254 lab = lab + wrap(items.join(""), "ul");
5257 app->infoPanel()->addLabel(lab, gb);
5259 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5260 items << wrap("UNV", "li")
5261 << wrap("MED", "li")
5262 << wrap("STL", "li")
5263 << wrap("CGNS", "li")
5264 << wrap("GMF", "li");
5265 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5268 app->infoPanel()->addLabel(lab, gb);
5270 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5271 lab = tr("INFO_DISPLAY") + "<br/>";
5272 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5273 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5274 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5275 << wrap("...", "li");
5276 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5278 lab = lab + tr("INFO_CLIPPING");
5280 app->infoPanel()->addLabel(lab, gb);
5283 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5284 PyGILState_STATE gstate = PyGILState_Ensure();
5285 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5286 if ( !pluginsmanager ) {
5290 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5295 PyGILState_Release(gstate);
5296 // end of SMESH plugins loading
5298 // Reset actions accelerator keys
5299 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5301 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5302 GetSMESHGen()->UpdateStudy();
5304 // get all view currently opened in the study and connect their signals to
5305 // the corresponding slots of the class.
5306 SUIT_Desktop* aDesk = study->application()->desktop();
5308 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5309 SUIT_ViewWindow* wnd;
5310 foreach ( wnd, wndList )
5314 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5315 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5321 Py_XDECREF(pluginsmanager);
5325 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5327 setMenuShown( false );
5328 setToolShown( false );
5330 EmitSignalCloseAllDialogs();
5332 // Unset actions accelerator keys
5333 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5335 return SalomeApp_Module::deactivateModule( study );
5338 void SMESHGUI::studyClosed( SUIT_Study* s )
5342 SMESH::RemoveVisuData();
5343 SalomeApp_Module::studyClosed( s );
5346 void SMESHGUI::OnGUIEvent()
5348 const QObject* obj = sender();
5349 if ( !obj || !obj->inherits( "QAction" ) )
5351 int id = actionId((QAction*)obj);
5356 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5358 if ( CORBA::is_nil( myComponentSMESH ) )
5360 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5361 return aGUI.myComponentSMESH;
5363 return myComponentSMESH;
5366 QString SMESHGUI::engineIOR() const
5368 CORBA::ORB_var anORB = getApp()->orb();
5369 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5370 return QString( anIOR.in() );
5373 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5375 SalomeApp_Module::contextMenuPopup( client, menu, title );
5377 selectionMgr()->selectedObjects( lst );
5378 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5379 Handle(SALOME_InteractiveObject) io = lst.First();
5380 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5381 _PTR(Study) study = appStudy->studyDS();
5382 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5384 QString aName = SMESH::fromUtf8( obj->GetName());
5385 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5386 aName.remove(( aName.length() - 1 ), 1 );
5392 LightApp_Selection* SMESHGUI::createSelection() const
5394 return new SMESHGUI_Selection();
5397 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5399 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5400 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5401 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5402 #ifndef DISABLE_PYCONSOLE
5403 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5407 void SMESHGUI::viewManagers( QStringList& list ) const
5409 list.append( SVTK_Viewer::Type() );
5412 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5414 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5415 SMESH::UpdateSelectionProp( this );
5417 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5418 for(int i = 0; i < aViews.count() ; i++){
5419 SUIT_ViewWindow *sf = aViews[i];
5422 EmitSignalActivatedViewManager();
5426 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5428 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5429 myClippingPlaneInfoMap.erase( theViewManager );
5432 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5434 theActor->AddObserver( SMESH::DeleteActorEvent,
5435 myEventCallbackCommand.GetPointer(),
5439 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5440 unsigned long theEvent,
5441 void* theClientData,
5442 void* /*theCallData*/ )
5444 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5445 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5446 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5447 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5448 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5449 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5450 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5451 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5452 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5453 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5454 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5455 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5456 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5457 if( anActor == *anIter3 ) {
5458 anActorList.erase( anIter3 );
5469 void SMESHGUI::createPreferences()
5471 // General tab ------------------------------------------------------------------------
5472 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5474 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5475 setPreferenceProperty( autoUpdate, "columns", 2 );
5476 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5477 setPreferenceProperty( lim, "min", 0 );
5478 setPreferenceProperty( lim, "max", 100000000 );
5479 setPreferenceProperty( lim, "step", 1000 );
5480 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5481 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5483 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5484 setPreferenceProperty( dispgroup, "columns", 2 );
5486 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5488 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5490 modes.append( tr("MEN_WIRE") );
5491 modes.append( tr("MEN_SHADE") );
5492 modes.append( tr("MEN_NODES") );
5493 modes.append( tr("MEN_SHRINK") );
5494 QList<QVariant> indices;
5495 indices.append( 0 );
5496 indices.append( 1 );
5497 indices.append( 2 );
5498 indices.append( 3 );
5499 setPreferenceProperty( dispmode, "strings", modes );
5500 setPreferenceProperty( dispmode, "indexes", indices );
5502 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5503 setPreferenceProperty( arcgroup, "columns", 2 );
5504 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5505 QStringList quadraticModes;
5506 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5507 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5509 indices.append( 0 );
5510 indices.append( 1 );
5511 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5512 setPreferenceProperty( quadraticmode, "indexes", indices );
5514 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5515 "SMESH", "max_angle" );
5516 setPreferenceProperty( maxAngle, "min", 1 );
5517 setPreferenceProperty( maxAngle, "max", 90 );
5519 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5520 setPreferenceProperty( qaGroup, "columns", 2 );
5521 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5522 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5523 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5524 setPreferenceProperty( prec, "min", 0 );
5525 setPreferenceProperty( prec, "max", 100 );
5526 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5527 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5528 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5529 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5530 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5533 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5534 setPreferenceProperty( cinc, "min", 0 );
5535 setPreferenceProperty( cinc, "max", 5 );
5538 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5539 setPreferenceProperty( exportgroup, "columns", 2 );
5540 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5541 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5542 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5543 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5544 setPreferenceProperty( zTol, "precision", 10 );
5545 setPreferenceProperty( zTol, "min", 0.0000000001 );
5546 setPreferenceProperty( zTol, "max", 1000000.0 );
5547 setPreferenceProperty( zTol, "step", 1. );
5548 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5550 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5551 setPreferenceProperty( computeGroup, "columns", 2 );
5552 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5554 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5555 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5556 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5558 indices.append( 0 );
5559 indices.append( 1 );
5560 indices.append( 2 );
5561 setPreferenceProperty( notifyMode, "strings", modes );
5562 setPreferenceProperty( notifyMode, "indexes", indices );
5564 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5565 setPreferenceProperty( infoGroup, "columns", 2 );
5566 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5568 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5569 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5571 indices.append( 0 );
5572 indices.append( 1 );
5573 setPreferenceProperty( elemInfo, "strings", modes );
5574 setPreferenceProperty( elemInfo, "indexes", indices );
5575 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5576 setPreferenceProperty( nodesLim, "min", 0 );
5577 setPreferenceProperty( nodesLim, "max", 10000000 );
5578 setPreferenceProperty( nodesLim, "step", 10000 );
5579 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5580 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5581 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5582 setPreferenceProperty( ctrlLim, "min", 0 );
5583 setPreferenceProperty( ctrlLim, "max", 10000000 );
5584 setPreferenceProperty( ctrlLim, "step", 1000 );
5585 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5586 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5587 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5588 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5589 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5591 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5592 setPreferenceProperty( segGroup, "columns", 2 );
5593 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5594 "SMESH", "segmentation" );
5595 setPreferenceProperty( segLen, "min", 1 );
5596 setPreferenceProperty( segLen, "max", 10000000 );
5597 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5598 "SMESH", "nb_segments_per_edge" );
5599 setPreferenceProperty( nbSeg, "min", 1 );
5600 setPreferenceProperty( nbSeg, "max", 10000000 );
5601 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5603 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5604 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5605 "SMESH", "forget_mesh_on_hyp_modif" );
5608 // Quantities with individual precision settings
5609 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5610 setPreferenceProperty( precGroup, "columns", 2 );
5612 const int nbQuantities = 6;
5613 int precs[nbQuantities], ii = 0;
5614 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5615 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5616 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5617 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5618 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5619 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5620 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5621 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5622 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5623 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5624 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5625 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5627 // Set property for precision value for spinboxes
5628 for ( ii = 0; ii < nbQuantities; ii++ ){
5629 setPreferenceProperty( precs[ii], "min", -14 );
5630 setPreferenceProperty( precs[ii], "max", 14 );
5631 setPreferenceProperty( precs[ii], "precision", 2 );
5634 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5635 setPreferenceProperty( previewGroup, "columns", 2 );
5636 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5637 setPreferenceProperty( chunkSize, "min", 1 );
5638 setPreferenceProperty( chunkSize, "max", 1000 );
5639 setPreferenceProperty( chunkSize, "step", 50 );
5641 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5642 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5644 // Mesh tab ------------------------------------------------------------------------
5645 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5646 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5647 setPreferenceProperty( nodeGroup, "columns", 3 );
5649 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5651 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5653 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5654 QList<QVariant> aMarkerTypeIndicesList;
5655 QList<QVariant> aMarkerTypeIconsList;
5656 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5657 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5658 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5659 aMarkerTypeIndicesList << i;
5660 aMarkerTypeIconsList << pixmap;
5662 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5663 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5665 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5667 QList<QVariant> aMarkerScaleIndicesList;
5668 QStringList aMarkerScaleValuesList;
5669 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5670 aMarkerScaleIndicesList << i;
5671 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5672 aMarkerScaleValuesList << QString::number( i );
5674 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5675 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5677 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5678 //setPreferenceProperty( elemGroup, "columns", 2 );
5680 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5681 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5682 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5683 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5684 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5685 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5686 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5687 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5688 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5691 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5692 setPreferenceProperty( grpGroup, "columns", 2 );
5694 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5695 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5697 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5698 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5699 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5700 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5701 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5702 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5703 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5704 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5705 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5706 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5707 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5708 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5709 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5710 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5712 setPreferenceProperty( size0d, "min", 1 );
5713 setPreferenceProperty( size0d, "max", 10 );
5715 // setPreferenceProperty( ballSize, "min", 1 );
5716 // setPreferenceProperty( ballSize, "max", 10 );
5718 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5719 setPreferenceProperty( ballDiameter, "max", 1e9 );
5720 setPreferenceProperty( ballDiameter, "step", 0.1 );
5722 setPreferenceProperty( ballScale, "min", 1e-2 );
5723 setPreferenceProperty( ballScale, "max", 1e7 );
5724 setPreferenceProperty( ballScale, "step", 0.5 );
5726 setPreferenceProperty( elemW, "min", 1 );
5727 setPreferenceProperty( elemW, "max", 5 );
5729 setPreferenceProperty( outW, "min", 1 );
5730 setPreferenceProperty( outW, "max", 5 );
5732 setPreferenceProperty( shrink, "min", 0 );
5733 setPreferenceProperty( shrink, "max", 100 );
5735 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5736 setPreferenceProperty( numGroup, "columns", 2 );
5738 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5739 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5741 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5742 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5744 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5745 setPreferenceProperty( orientGroup, "columns", 1 );
5747 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5748 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5750 setPreferenceProperty( orientScale, "min", 0.05 );
5751 setPreferenceProperty( orientScale, "max", 0.5 );
5752 setPreferenceProperty( orientScale, "step", 0.05 );
5754 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5756 // Selection tab ------------------------------------------------------------------------
5757 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5759 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5760 setPreferenceProperty( selGroup, "columns", 2 );
5762 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5763 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5765 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5766 setPreferenceProperty( preGroup, "columns", 2 );
5768 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5770 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5771 setPreferenceProperty( precSelGroup, "columns", 2 );
5773 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5774 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5775 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5777 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5778 setPreferenceProperty( sinc, "min", 0 );
5779 setPreferenceProperty( sinc, "max", 5 );
5781 // Scalar Bar tab ------------------------------------------------------------------------
5782 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5783 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5784 setPreferenceProperty( fontGr, "columns", 2 );
5786 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5787 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5789 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5790 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5792 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5793 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5795 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5796 setPreferenceProperty( numcol, "min", 2 );
5797 setPreferenceProperty( numcol, "max", 256 );
5799 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5800 setPreferenceProperty( numlab, "min", 2 );
5801 setPreferenceProperty( numlab, "max", 65 );
5803 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5804 setPreferenceProperty( orientGr, "columns", 2 );
5805 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5806 QStringList orients;
5807 orients.append( tr( "SMESH_VERTICAL" ) );
5808 orients.append( tr( "SMESH_HORIZONTAL" ) );
5809 indices.clear(); indices.append( 0 ); indices.append( 1 );
5810 setPreferenceProperty( orient, "strings", orients );
5811 setPreferenceProperty( orient, "indexes", indices );
5813 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5814 setPreferenceProperty( posVSizeGr, "columns", 2 );
5815 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5816 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5817 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5818 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5819 setPreferenceProperty( xv, "step", 0.1 );
5820 setPreferenceProperty( xv, "min", 0.0 );
5821 setPreferenceProperty( xv, "max", 1.0 );
5822 setPreferenceProperty( yv, "step", 0.1 );
5823 setPreferenceProperty( yv, "min", 0.0 );
5824 setPreferenceProperty( yv, "max", 1.0 );
5825 setPreferenceProperty( wv, "step", 0.1 );
5826 setPreferenceProperty( wv, "min", 0.0 );
5827 setPreferenceProperty( wv, "max", 1.0 );
5828 setPreferenceProperty( hv, "min", 0.0 );
5829 setPreferenceProperty( hv, "max", 1.0 );
5830 setPreferenceProperty( hv, "step", 0.1 );
5832 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5833 setPreferenceProperty( posHSizeGr, "columns", 2 );
5834 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5835 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5836 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5837 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5838 setPreferenceProperty( xv, "min", 0.0 );
5839 setPreferenceProperty( xv, "max", 1.0 );
5840 setPreferenceProperty( xv, "step", 0.1 );
5841 setPreferenceProperty( xh, "min", 0.0 );
5842 setPreferenceProperty( xh, "max", 1.0 );
5843 setPreferenceProperty( xh, "step", 0.1 );
5844 setPreferenceProperty( yh, "min", 0.0 );
5845 setPreferenceProperty( yh, "max", 1.0 );
5846 setPreferenceProperty( yh, "step", 0.1 );
5847 setPreferenceProperty( wh, "min", 0.0 );
5848 setPreferenceProperty( wh, "max", 1.0 );
5849 setPreferenceProperty( wh, "step", 0.1 );
5850 setPreferenceProperty( hh, "min", 0.0 );
5851 setPreferenceProperty( hh, "max", 1.0 );
5852 setPreferenceProperty( hh, "step", 0.1 );
5854 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5855 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5856 setPreferenceProperty( distributionGr, "columns", 3 );
5858 types.append( tr( "SMESH_MONOCOLOR" ) );
5859 types.append( tr( "SMESH_MULTICOLOR" ) );
5860 indices.clear(); indices.append( 0 ); indices.append( 1 );
5861 setPreferenceProperty( coloringType, "strings", types );
5862 setPreferenceProperty( coloringType, "indexes", indices );
5863 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5865 // Adaptation - begin
5866 #ifndef DISABLE_MG_ADAPT
5867 // Adaptation tab ------------------------------------------------------------------------
5868 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
5871 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
5872 setPreferenceProperty( bloc, "columns", 1 );
5873 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
5874 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
5875 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
5876 QStringList aListOfSizeMap;
5877 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
5878 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
5879 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
5880 setPreferenceProperty( pref, "strings", aListOfSizeMap );
5881 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
5882 QStringList aListOfTimeStep;
5883 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
5884 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
5885 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
5886 setPreferenceProperty( pref, "strings", aListOfTimeStep );
5891 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5893 if ( sect=="SMESH" ) {
5894 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5895 double aTol = 1.00000009999999;
5896 std::string aWarning;
5897 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5899 if ( name == "selection_object_color" ||
5900 name == "selection_element_color" ||
5901 name == "highlight_color" ||
5902 name == "selection_precision_node" ||
5903 name == "selection_precision_element" ||
5904 name == "selection_precision_object" ||
5905 name == "selection_increment")
5907 SMESH::UpdateSelectionProp( this );
5909 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5911 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5912 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5913 if ( sbX1+sbW > aTol ) {
5914 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5917 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5918 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5921 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5923 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5924 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5925 if ( sbY1 + sbH > aTol ) {
5926 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5927 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5928 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5931 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5933 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5934 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5935 if ( sbX1 + sbW > aTol ) {
5936 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5939 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5940 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5943 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5945 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5946 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5947 if ( sbY1 + sbH > aTol ) {
5948 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5951 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5952 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5955 else if ( name == "segmentation" )
5957 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5958 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5960 else if ( name == "nb_segments_per_edge" )
5962 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5963 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5965 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5967 QString val = aResourceMgr->stringValue( "SMESH", name );
5968 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5970 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5972 SMESH::UpdateFontProp( this );
5974 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5976 SMESH::UpdateFontProp( this );
5979 if ( aWarning.size() != 0 ) {
5980 aWarning += "The default values are applied instead.";
5981 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5982 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5983 QObject::tr(aWarning.c_str()));
5988 //================================================================================
5990 * \brief Update something in accordance with update flags
5991 * \param theFlags - update flags
5993 * Update viewer or/and object browser etc. in accordance with update flags ( see
5994 * LightApp_UpdateFlags enumeration ).
5996 //================================================================================
5997 void SMESHGUI::update( const int flags )
5999 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
6000 SMESH::UpdateView();
6002 SalomeApp_Module::update( flags );
6005 //================================================================================
6007 * \brief Set default selection mode
6009 * SLOT called when operation committed. Sets default selection mode
6011 //================================================================================
6012 void SMESHGUI::onOperationCommited( SUIT_Operation* )
6014 SVTK_ViewWindow* vtkWnd =
6015 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6017 vtkWnd->SetSelectionMode( ActorSelection );
6020 //================================================================================
6022 * \brief Set default selection mode
6024 * SLOT called when operation aborted. Sets default selection mode
6026 //================================================================================
6027 void SMESHGUI::onOperationAborted( SUIT_Operation* )
6029 SVTK_ViewWindow* vtkWnd =
6030 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6032 vtkWnd->SetSelectionMode( ActorSelection );
6035 //================================================================================
6037 * \brief Creates operation with given identifier
6038 * \param id - identifier of operation to be started
6039 * \return Pointer on created operation or NULL if operation is not created
6041 * Virtual method redefined from the base class creates operation with given id.
6042 * It is called called automatically from startOperation method of base class.
6044 //================================================================================
6045 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
6047 LightApp_Operation* op = 0;
6048 // to do : create operation here
6051 case SMESHOp::OpSplitBiQuadratic:
6052 op = new SMESHGUI_SplitBiQuadOp();
6054 case SMESHOp::OpConvertMeshToQuadratic:
6055 op = new SMESHGUI_ConvToQuadOp();
6057 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
6058 op = new SMESHGUI_Make2DFrom3DOp();
6060 case SMESHOp::OpCreateDualMesh:
6061 op = new SMESHGUI_CreateDualMeshOp();
6063 case SMESHOp::OpCreate2DElements:
6064 op = new SMESHGUI_MakeFull2DFrom3DOp();
6066 case SMESHOp::OpReorientFaces:
6067 op = new SMESHGUI_ReorientFacesOp();
6069 case SMESHOp::OpCreateMesh:
6070 op = new SMESHGUI_MeshOp( true, true );
6072 case SMESHOp::OpCreateSubMesh:
6073 op = new SMESHGUI_MeshOp( true, false );
6075 case SMESHOp::OpEditMeshOrSubMesh:
6076 case SMESHOp::OpEditMesh:
6077 case SMESHOp::OpEditSubMesh:
6078 op = new SMESHGUI_MeshOp( false );
6080 case SMESHOp::OpCompute:
6081 case SMESHOp::OpComputeSubMesh:
6082 op = new SMESHGUI_ComputeOp();
6084 case SMESHOp::OpShowErrors:
6085 op = new SMESHGUI_ShowErrorsOp();
6087 case SMESHOp::OpPreCompute:
6088 op = new SMESHGUI_PrecomputeOp();
6090 case SMESHOp::OpEvaluate:
6091 op = new SMESHGUI_EvaluateOp();
6093 case SMESHOp::OpMeshOrder:
6094 op = new SMESHGUI_MeshOrderOp();
6096 case SMESHOp::OpCreateGeometryGroup:
6097 op = new SMESHGUI_GroupOnShapeOp();
6099 case SMESHOp::OpFindElementByPoint:
6100 op = new SMESHGUI_FindElemByPointOp();
6102 case SMESHOp::OpMoveNode: // Make mesh pass through point
6103 op = new SMESHGUI_MakeNodeAtPointOp();
6105 case SMESHOp::OpMoveNodeInteractive: // Make mesh pass through point / by mouse
6106 op = new SMESHGUI_MakeNodeAtPointOp( 2 );
6108 case SMESHOp::OpRemoveNodeWithReconn:
6109 op = new SMESHGUI_RemoveNodeReconnectionOp();
6111 case SMESHOp::OpSplitEdgeInteract:
6112 op = new SMESHGUI_AddNodeOnSegmentOp();
6114 case SMESHOp::OpSplitFaceInteract:
6115 op = new SMESHGUI_AddNodeOnFaceOp();
6117 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
6118 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
6125 op = SalomeApp_Module::createOperation( id );
6129 //================================================================================
6131 * \brief Stops current operations and starts a given one
6132 * \param id - The id of the operation to start
6134 //================================================================================
6136 void SMESHGUI::switchToOperation(int id)
6138 activeStudy()->abortAllOperations();
6139 startOperation( id );
6142 LightApp_Displayer* SMESHGUI::displayer()
6145 myDisplayer = new SMESHGUI_Displayer( getApp() );
6149 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6152 int aTolerance = 64;
6153 int anIterations = 0;
6159 if( anIterations % aPeriod == 0 )
6162 if( aTolerance < 1 )
6166 aHue = (int)( 360.0 * rand() / RAND_MAX );
6169 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6170 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6171 for( ; it != itEnd; ++it )
6173 SALOMEDS::Color anAutoColor = *it;
6174 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6177 aQColor.getHsv( &h, &s, &v );
6178 if( abs( h - aHue ) < aTolerance )
6190 aColor.setHsv( aHue, 255, 255 );
6192 SALOMEDS::Color aSColor;
6193 aSColor.R = aColor.redF();
6194 aSColor.G = aColor.greenF();
6195 aSColor.B = aColor.blueF();
6200 const char* gSeparator = "_"; // character used to separate parameter names
6201 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6202 const char* gPathSep = "|"; // character used to separate paths
6205 * \brief Store visual parameters
6207 * This method is called just before the study document is saved.
6208 * Store visual parameters in AttributeParameter attribute(s)
6210 void SMESHGUI::storeVisualParameters (int savePoint)
6213 Kernel_Utils::Localizer loc;
6215 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6216 if (!appStudy || !appStudy->studyDS())
6218 _PTR(Study) studyDS = appStudy->studyDS();
6220 // componentName is used for encoding of entries when storing them in IParameters
6221 std::string componentName = myComponentSMESH->ComponentDataType();
6222 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6223 //if (!aSComponent) return;
6226 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6227 componentName.c_str(),
6229 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6231 // store custom markers
6232 if( !myMarkerMap.empty() )
6234 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6235 for( ; anIter != myMarkerMap.end(); anIter++ )
6237 int anId = anIter->first;
6238 VTK::MarkerData aMarkerData = anIter->second;
6239 std::string aMarkerFileName = aMarkerData.first;
6240 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6241 if( aMarkerTexture.size() < 3 )
6242 continue; // should contain at least width, height and the first value
6244 QString aPropertyName( "texture" );
6245 aPropertyName += gSeparator;
6246 aPropertyName += QString::number( anId );
6248 QString aPropertyValue = aMarkerFileName.c_str();
6249 aPropertyValue += gPathSep;
6251 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6252 ushort aWidth = *aTextureIter++;
6253 ushort aHeight = *aTextureIter++;
6254 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6255 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6256 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6257 aPropertyValue += QString::number( *aTextureIter );
6259 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6263 // viewers counters are used for storing view_numbers in IParameters
6266 // main cycle to store parameters of displayed objects
6267 QList<SUIT_ViewManager*> lst;
6268 QList<SUIT_ViewManager*>::Iterator it;
6269 getApp()->viewManagers(lst);
6270 for (it = lst.begin(); it != lst.end(); it++)
6272 SUIT_ViewManager* vman = *it;
6273 QString vType = vman->getType();
6275 // saving VTK actors properties
6276 if (vType == SVTK_Viewer::Type())
6278 // store the clipping planes attached to the view manager
6279 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6280 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6281 if( anIter != myClippingPlaneInfoMap.end() )
6282 aClippingPlaneInfoList = anIter->second;
6284 if( !aClippingPlaneInfoList.empty() ) {
6285 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6286 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6288 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6289 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6291 QString aPropertyName( "ClippingPlane" );
6292 aPropertyName += gSeparator;
6293 aPropertyName += QString::number( vtkViewers );
6294 aPropertyName += gSeparator;
6295 aPropertyName += QString::number( anId );
6297 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6298 aPropertyValue += gDigitsSep;
6299 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6300 aPropertyValue += gDigitsSep;
6301 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6302 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6303 aPropertyValue += gDigitsSep;
6304 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6305 aPropertyValue += gDigitsSep;
6306 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6307 aPropertyValue += gDigitsSep;
6308 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6309 aPropertyValue += gDigitsSep;
6310 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6311 aPropertyValue += gDigitsSep;
6312 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6313 aPropertyValue += gDigitsSep;
6314 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6316 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6317 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6318 aPropertyValue += gDigitsSep;
6319 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6320 aPropertyValue += gDigitsSep;
6321 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6322 aPropertyValue += gDigitsSep;
6323 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6326 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6330 QVector<SUIT_ViewWindow*> views = vman->getViews();
6331 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6333 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6335 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6336 vtkActorCollection* allActors = aCopy.GetActors();
6337 allActors->InitTraversal();
6338 while (vtkActor* actor = allActors->GetNextActor())
6340 if (actor->GetVisibility()) // store only visible actors
6342 SMESH_Actor* aSmeshActor = 0;
6343 if (actor->IsA("SMESH_Actor"))
6344 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6345 if (aSmeshActor && aSmeshActor->hasIO())
6347 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6350 // entry is "encoded" = it does NOT contain component address,
6351 // since it is a subject to change on next component loading
6352 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6354 std::string param, vtkParam = vType.toLatin1().data();
6355 vtkParam += gSeparator;
6356 vtkParam += QString::number(vtkViewers).toLatin1().data();
6357 vtkParam += gSeparator;
6360 param = vtkParam + "Visibility";
6361 ip->setParameter(entry, param, "On");
6364 param = vtkParam + "Representation";
6365 ip->setParameter(entry, param, QString::number
6366 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6369 param = vtkParam + "IsShrunk";
6370 ip->setParameter(entry, param, QString::number
6371 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6373 // Displayed entities
6374 unsigned int aMode = aSmeshActor->GetEntityMode();
6375 bool isE = aMode & SMESH_Actor::eEdges;
6376 bool isF = aMode & SMESH_Actor::eFaces;
6377 bool isV = aMode & SMESH_Actor::eVolumes;
6378 bool is0d = aMode & SMESH_Actor::e0DElements;
6379 bool isB = aMode & SMESH_Actor::eBallElem;
6381 QString modeStr ("e");
6382 modeStr += gDigitsSep; modeStr += QString::number(isE);
6383 modeStr += gDigitsSep; modeStr += "f";
6384 modeStr += gDigitsSep; modeStr += QString::number(isF);
6385 modeStr += gDigitsSep; modeStr += "v";
6386 modeStr += gDigitsSep; modeStr += QString::number(isV);
6387 modeStr += gDigitsSep; modeStr += "0d";
6388 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6389 modeStr += gDigitsSep; modeStr += "b";
6390 modeStr += gDigitsSep; modeStr += QString::number(isB);
6392 param = vtkParam + "Entities";
6393 ip->setParameter(entry, param, modeStr.toLatin1().data());
6399 aSmeshActor->GetSufaceColor(r, g, b, delta);
6400 QStringList colorStr;
6401 colorStr << "surface";
6402 colorStr << QString::number(r);
6403 colorStr << QString::number(g);
6404 colorStr << QString::number(b);
6406 colorStr << "backsurface";
6407 colorStr << QString::number(delta);
6409 aSmeshActor->GetVolumeColor(r, g, b, delta);
6410 colorStr << "volume";
6411 colorStr << QString::number(r);
6412 colorStr << QString::number(g);
6413 colorStr << QString::number(b);
6414 colorStr << QString::number(delta);
6416 aSmeshActor->GetEdgeColor(r, g, b);
6418 colorStr << QString::number(r);
6419 colorStr << QString::number(g);
6420 colorStr << QString::number(b);
6422 aSmeshActor->GetNodeColor(r, g, b);
6424 colorStr << QString::number(r);
6425 colorStr << QString::number(g);
6426 colorStr << QString::number(b);
6428 aSmeshActor->GetOutlineColor(r, g, b);
6429 colorStr << "outline";
6430 colorStr << QString::number(r);
6431 colorStr << QString::number(g);
6432 colorStr << QString::number(b);
6434 aSmeshActor->Get0DColor(r, g, b);
6435 colorStr << "elem0d";
6436 colorStr << QString::number(r);
6437 colorStr << QString::number(g);
6438 colorStr << QString::number(b);
6440 aSmeshActor->GetBallColor(r, g, b);
6442 colorStr << QString::number(r);
6443 colorStr << QString::number(g);
6444 colorStr << QString::number(b);
6446 aSmeshActor->GetFacesOrientationColor(r, g, b);
6447 colorStr << "orientation";
6448 colorStr << QString::number(r);
6449 colorStr << QString::number(g);
6450 colorStr << QString::number(b);
6452 param = vtkParam + "Colors";
6453 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6456 QStringList sizeStr;
6458 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6459 sizeStr << "outline";
6460 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6461 sizeStr << "elem0d";
6462 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6464 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6465 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6466 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6467 sizeStr << "shrink";
6468 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6469 sizeStr << "orientation";
6470 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6471 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6473 param = vtkParam + "Sizes";
6474 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6479 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6480 if( aMarkerType == VTK::MT_USER ) {
6481 markerStr += "custom";
6482 markerStr += gDigitsSep;
6483 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6487 markerStr += gDigitsSep;
6488 markerStr += QString::number( (int)aMarkerType );
6489 markerStr += gDigitsSep;
6490 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6493 param = vtkParam + "PointMarker";
6494 ip->setParameter(entry, param, markerStr.toLatin1().data());
6497 param = vtkParam + "Opacity";
6498 ip->setParameter(entry, param,
6499 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6502 param = vtkParam + "ClippingPlane";
6504 if( !aClippingPlaneInfoList.empty() ) {
6505 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6506 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6508 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6509 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6510 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6511 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6512 if( aSmeshActor == *anIter2 ) {
6513 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6514 QString::number( anId ).toLatin1().constData() );
6521 ip->setParameter( entry, param, "Off" );
6522 } // if (io->hasEntry())
6523 } // SMESH_Actor && hasIO
6525 } // while.. actors traversal
6529 } // if (SVTK view model)
6530 } // for (viewManagers)
6533 // data structures for clipping planes processing
6537 bool isOpenGLClipping;
6538 vtkIdType RelativeOrientation;
6541 int AbsoluteOrientation;
6542 double X, Y, Z, Dx, Dy, Dz;
6544 typedef std::list<TPlaneData> TPlaneDataList;
6545 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6547 typedef std::list<vtkActor*> TActorList;
6550 TActorList ActorList;
6551 SUIT_ViewManager* ViewManager;
6553 typedef std::list<TPlaneInfo> TPlaneInfoList;
6554 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6557 * \brief Restore visual parameters
6559 * This method is called after the study document is opened.
6560 * Restore visual parameters from AttributeParameter attribute(s)
6562 void SMESHGUI::restoreVisualParameters (int savePoint)
6565 Kernel_Utils::Localizer loc;
6567 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6568 if (!appStudy || !appStudy->studyDS())
6570 _PTR(Study) studyDS = appStudy->studyDS();
6572 // componentName is used for encoding of entries when storing them in IParameters
6573 std::string componentName = myComponentSMESH->ComponentDataType();
6576 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6577 componentName.c_str(),
6579 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6581 // restore custom markers and map of clipping planes
6582 TPlaneDataMap aPlaneDataMap;
6584 std::vector<std::string> properties = ip->getProperties();
6585 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6587 std::string property = *propIt;
6588 QString aPropertyName( property.c_str() );
6589 QString aPropertyValue( ip->getProperty( property ).c_str() );
6591 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6592 if( aPropertyNameList.isEmpty() )
6595 QString aPropertyType = aPropertyNameList[0];
6596 if( aPropertyType == "texture" )
6598 if( aPropertyNameList.size() != 2 )
6602 int anId = aPropertyNameList[1].toInt( &ok );
6603 if( !ok || anId < 1 )
6606 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6607 if( aPropertyValueList.size() != 2 )
6610 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6611 QString aMarkerTextureString = aPropertyValueList[1];
6612 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6613 if( aMarkerTextureStringList.size() != 3 )
6617 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6622 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6626 VTK::MarkerTexture aMarkerTexture;
6627 aMarkerTexture.push_back( aWidth );
6628 aMarkerTexture.push_back( aHeight );
6630 QString aMarkerTextureData = aMarkerTextureStringList[2];
6631 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6633 QChar aChar = aMarkerTextureData.at( i );
6634 if( aChar.isDigit() )
6635 aMarkerTexture.push_back( aChar.digitValue() );
6638 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6640 else if( aPropertyType == "ClippingPlane" )
6642 if( aPropertyNameList.size() != 3 )
6646 int aViewId = aPropertyNameList[1].toInt( &ok );
6647 if( !ok || aViewId < 0 )
6651 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6652 if( !ok || aClippingPlaneId < 0 )
6655 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6656 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6659 TPlaneData aPlaneData;
6660 aPlaneData.AbsoluteOrientation = false;
6661 aPlaneData.RelativeOrientation = 0;
6662 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6663 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6664 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6666 aPlaneData.Id = aClippingPlaneId;
6669 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6674 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6678 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6681 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6686 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6691 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6696 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6701 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6706 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6711 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6715 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6717 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6722 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6727 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6732 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6737 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6738 aPlaneDataList.push_back( aPlaneData );
6742 TPlaneInfoMap aPlaneInfoMap;
6744 std::vector<std::string> entries = ip->getEntries();
6746 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6748 // entry is a normal entry - it should be "decoded" (setting base address of component)
6749 QString entry (ip->decodeEntry(*entIt).c_str());
6751 // Check that the entry corresponds to a real object in the Study
6752 // as the object may be deleted or modified after the visual state is saved.
6753 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6754 if (!so) continue; //Skip the not existent entry
6756 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6757 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6759 std::vector<std::string>::iterator namesIt = paramNames.begin();
6760 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6762 // actors are stored in a map after displaying of them for
6763 // quicker access in the future: map < viewID to actor >
6764 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6766 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6768 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6769 // '_' is used as separator and should not be used in viewer type or parameter names.
6770 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6771 if (lst.size() != 3)
6774 QString viewerTypStr = lst[0];
6775 QString viewIndexStr = lst[1];
6776 QString paramNameStr = lst[2];
6779 int viewIndex = viewIndexStr.toUInt(&ok);
6780 if (!ok) // bad conversion of view index to integer
6784 if (viewerTypStr == SVTK_Viewer::Type())
6786 SMESH_Actor* aSmeshActor = 0;
6787 if (vtkActors.IsBound(viewIndex))
6788 aSmeshActor = vtkActors.Find(viewIndex);
6790 QList<SUIT_ViewManager*> lst;
6791 getApp()->viewManagers(viewerTypStr, lst);
6793 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6794 SUIT_ViewManager* vman = NULL;
6795 if (viewIndex >= 0 && viewIndex < lst.count())
6796 vman = lst.at(viewIndex);
6798 if (paramNameStr == "Visibility")
6800 if (!aSmeshActor && displayer() && vman)
6802 SUIT_ViewModel* vmodel = vman->getViewModel();
6803 // SVTK view model can be casted to SALOME_View
6804 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6806 // store displayed actor in a temporary map for quicker
6807 // access later when restoring other parameters
6808 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6809 vtkRenderer* Renderer = vtkView->getRenderer();
6810 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6811 vtkActorCollection* theActors = aCopy.GetActors();
6812 theActors->InitTraversal();
6813 bool isFound = false;
6814 vtkActor *ac = theActors->GetNextActor();
6815 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6816 if (ac->IsA("SMESH_Actor")) {
6817 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6818 if (aGeomAc->hasIO()) {
6819 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6820 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6822 vtkActors.Bind(viewIndex, aGeomAc);
6828 } // if (paramNameStr == "Visibility")
6831 // the rest properties "work" with SMESH_Actor
6834 QString val ((*valuesIt).c_str());
6837 if (paramNameStr == "Representation") {
6838 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6841 else if (paramNameStr == "IsShrunk") {
6843 if (!aSmeshActor->IsShrunk())
6844 aSmeshActor->SetShrink();
6847 if (aSmeshActor->IsShrunk())
6848 aSmeshActor->UnShrink();
6851 // Displayed entities
6852 else if (paramNameStr == "Entities") {
6853 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6854 int aEntityMode = SMESH_Actor::eAllEntity;
6855 for ( int i = 0; i < mode.count(); i+=2 ) {
6856 if ( i < mode.count()-1 ) {
6857 QString type = mode[i];
6858 bool val = mode[i+1].toInt();
6859 if ( type == "e" && !val )
6860 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6861 else if ( type == "f" && !val )
6862 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6863 else if ( type == "v" && !val )
6864 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6865 else if ( type == "0d" && !val )
6866 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6867 else if ( type == "b" && !val )
6868 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6871 aSmeshActor->SetEntityMode( aEntityMode );
6874 else if (paramNameStr == "Colors") {
6875 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6882 QColor outlineColor;
6883 QColor orientationColor;
6889 // below lines are required to get default values for delta coefficients
6890 // of backface color for faces and color of reversed volumes
6891 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6892 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6893 for ( int i = 0; i < colors.count(); i++ ) {
6894 QString type = colors[i];
6895 if ( type == "surface" ) {
6896 // face color is set by 3 values r:g:b, where
6897 // - r,g,b - is rgb color components
6898 if ( i+1 >= colors.count() ) break; // format error
6899 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6900 if ( i+2 >= colors.count() ) break; // format error
6901 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6902 if ( i+3 >= colors.count() ) break; // format error
6903 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6904 faceColor.setRgbF( r, g, b );
6907 else if ( type == "backsurface" ) {
6908 // backface color can be defined in several ways
6909 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6910 // - in latest versions, it is set as delta coefficient
6911 bool rgbOk = false, deltaOk;
6912 if ( i+1 >= colors.count() ) break; // format error
6913 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6914 int delta = colors[i+1].toInt( &deltaOk );
6916 if ( i+1 < colors.count() ) // index is shifted to 1
6917 g = colors[i+1].toDouble( &rgbOk );
6918 if ( rgbOk ) i++; // shift index
6919 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6920 b = colors[i+1].toDouble( &rgbOk );
6922 // - as currently there's no way to set directly backsurface color as it was before,
6923 // we ignore old dump where r,g,b triple was set
6924 // - also we check that delta parameter is set properly
6925 if ( !rgbOk && deltaOk )
6928 else if ( type == "volume" ) {
6929 // volume color is set by 4 values r:g:b:delta, where
6930 // - r,g,b - is a normal volume rgb color components
6931 // - delta - is a reversed volume color delta coefficient
6932 if ( i+1 >= colors.count() ) break; // format error
6933 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6934 if ( i+2 >= colors.count() ) break; // format error
6935 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6936 if ( i+3 >= colors.count() ) break; // format error
6937 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6938 if ( i+4 >= colors.count() ) break; // format error
6939 int delta = colors[i+4].toInt( &bOk );
6940 if ( !bOk ) break; // format error
6941 volumeColor.setRgbF( r, g, b );
6945 else if ( type == "edge" ) {
6946 // edge color is set by 3 values r:g:b, where
6947 // - r,g,b - is rgb color components
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 edgeColor.setRgbF( r, g, b );
6957 else if ( type == "node" ) {
6958 // node color is set by 3 values r:g:b, where
6959 // - r,g,b - is rgb color components
6960 if ( i+1 >= colors.count() ) break; // format error
6961 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6962 if ( i+2 >= colors.count() ) break; // format error
6963 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6964 if ( i+3 >= colors.count() ) break; // format error
6965 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6966 nodeColor.setRgbF( r, g, b );
6969 else if ( type == "elem0d" ) {
6970 // 0d element color is set by 3 values r:g:b, where
6971 // - r,g,b - is rgb color components
6972 if ( i+1 >= colors.count() ) break; // format error
6973 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6974 if ( i+2 >= colors.count() ) break; // format error
6975 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6976 if ( i+3 >= colors.count() ) break; // format error
6977 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6978 elem0dColor.setRgbF( r, g, b );
6981 else if ( type == "ball" ) {
6982 // ball color is set by 3 values r:g:b, where
6983 // - r,g,b - is rgb color components
6984 if ( i+1 >= colors.count() ) break; // format error
6985 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6986 if ( i+2 >= colors.count() ) break; // format error
6987 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6988 if ( i+3 >= colors.count() ) break; // format error
6989 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6990 ballColor.setRgbF( r, g, b );
6993 else if ( type == "outline" ) {
6994 // outline color is set by 3 values r:g:b, where
6995 // - r,g,b - is rgb color components
6996 if ( i+1 >= colors.count() ) break; // format error
6997 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6998 if ( i+2 >= colors.count() ) break; // format error
6999 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7000 if ( i+3 >= colors.count() ) break; // format error
7001 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7002 outlineColor.setRgbF( r, g, b );
7005 else if ( type == "orientation" ) {
7006 // orientation color is set by 3 values r:g:b, where
7007 // - r,g,b - is rgb color components
7008 if ( i+1 >= colors.count() ) break; // format error
7009 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7010 if ( i+2 >= colors.count() ) break; // format error
7011 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7012 if ( i+3 >= colors.count() ) break; // format error
7013 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7014 orientationColor.setRgbF( r, g, b );
7019 if ( nodeColor.isValid() )
7020 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
7022 if ( edgeColor.isValid() )
7023 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
7025 if ( faceColor.isValid() )
7026 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7028 if ( volumeColor.isValid() )
7029 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
7030 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
7031 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7033 if ( elem0dColor.isValid() )
7034 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
7036 if ( ballColor.isValid() )
7037 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
7039 if ( outlineColor.isValid() )
7040 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
7041 // orientation color
7042 if ( orientationColor.isValid() )
7043 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
7046 else if (paramNameStr == "Sizes") {
7047 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
7050 int outlineWidth = -1;
7051 int elem0dSize = -1;
7052 //int ballSize = -1;
7053 double ballDiameter = -1.0;
7054 double ballScale = -1.0;
7055 double shrinkSize = -1;
7056 double orientationSize = -1;
7057 bool orientation3d = false;
7058 for ( int i = 0; i < sizes.count(); i++ ) {
7059 QString type = sizes[i];
7060 if ( type == "line" ) {
7061 // line (wireframe) width is given as single integer value
7062 if ( i+1 >= sizes.count() ) break; // format error
7063 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7067 if ( type == "outline" ) {
7068 // outline width is given as single integer value
7069 if ( i+1 >= sizes.count() ) break; // format error
7070 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7074 else if ( type == "elem0d" ) {
7075 // 0d element size is given as single integer value
7076 if ( i+1 >= sizes.count() ) break; // format error
7077 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7081 else if ( type == "ball" ) {
7082 // balls are specified by two values: size:scale, where
7083 // - size - is a integer value specifying size
7084 // - scale - is a double value specifying scale factor
7085 if ( i+1 >= sizes.count() ) break; // format error
7086 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7087 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7088 if ( i+2 >= sizes.count() ) break; // format error
7089 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7095 else if ( type == "shrink" ) {
7096 // shrink factor is given as single floating point value
7097 if ( i+1 >= sizes.count() ) break; // format error
7098 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7102 else if ( type == "orientation" ) {
7103 // orientation vectors are specified by two values size:3d, where
7104 // - size - is a floating point value specifying scale factor
7105 // - 3d - is a boolean
7106 if ( i+1 >= sizes.count() ) break; // format error
7107 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7108 if ( i+2 >= sizes.count() ) break; // format error
7109 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
7110 orientationSize = v1;
7111 orientation3d = (bool)v2;
7115 // line (wireframe) width
7116 if ( lineWidth > 0 )
7117 aSmeshActor->SetLineWidth( lineWidth );
7119 if ( outlineWidth > 0 )
7120 aSmeshActor->SetOutlineWidth( outlineWidth );
7121 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
7122 aSmeshActor->SetOutlineWidth( lineWidth );
7124 if ( elem0dSize > 0 )
7125 aSmeshActor->Set0DSize( elem0dSize );
7127 /*if ( ballSize > 0 )
7128 aSmeshActor->SetBallSize( ballSize );*/
7130 if ( ballDiameter > 0 )
7131 aSmeshActor->SetBallSize( ballDiameter );
7133 if ( ballScale > 0.0 )
7134 aSmeshActor->SetBallScale( ballScale );
7136 if ( shrinkSize > 0 )
7137 aSmeshActor->SetShrinkFactor( shrinkSize );
7138 // orientation vectors
7139 if ( orientationSize > 0 ) {
7140 aSmeshActor->SetFacesOrientationScale( orientationSize );
7141 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7145 else if (paramNameStr == "PointMarker") {
7146 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7147 if( data.count() >= 2 ) {
7149 int aParam1 = data[1].toInt( &ok );
7151 if( data[0] == "std" && data.count() == 3 ) {
7152 int aParam2 = data[2].toInt( &ok );
7153 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7155 else if( data[0] == "custom" ) {
7156 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7157 if( markerIt != myMarkerMap.end() ) {
7158 VTK::MarkerData aMarkerData = markerIt->second;
7159 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7166 else if (paramNameStr == "Opacity") {
7167 aSmeshActor->SetOpacity(val.toFloat());
7170 else if (paramNameStr.startsWith("ClippingPlane")) {
7171 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7172 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7173 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7174 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7175 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7176 // new format - val looks like "Off" or "0" (plane id)
7177 // (note: in new format "Off" value is used only for consistency,
7178 // so it is processed together with values in old format)
7179 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7180 if( anIsOldFormat ) {
7181 if (paramNameStr == "ClippingPlane1" || val == "Off")
7182 aSmeshActor->RemoveAllClippingPlanes();
7184 QList<SUIT_ViewManager*> lst;
7185 getApp()->viewManagers(viewerTypStr, lst);
7186 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7187 if (viewIndex >= 0 && viewIndex < lst.count()) {
7188 SUIT_ViewManager* vman = lst.at(viewIndex);
7189 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7191 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7193 SMESH::TActorList anActorList;
7194 anActorList.push_back( aSmeshActor );
7195 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7196 aPlane->myViewWindow = vtkView;
7197 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7198 aPlane->PlaneMode = aMode;
7199 bool isOpenGLClipping = ( bool )vals[1].toInt();
7200 aPlane->IsOpenGLClipping = isOpenGLClipping;
7201 if ( aMode == SMESH::Absolute ) {
7202 aPlane->myAbsoluteOrientation = vals[2].toInt();
7203 aPlane->X = vals[3].toFloat();
7204 aPlane->Y = vals[4].toFloat();
7205 aPlane->Z = vals[5].toFloat();
7206 aPlane->Dx = vals[6].toFloat();
7207 aPlane->Dy = vals[7].toFloat();
7208 aPlane->Dz = vals[8].toFloat();
7210 else if ( aMode == SMESH::Relative ) {
7211 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7212 aPlane->myDistance = vals[3].toFloat();
7213 aPlane->myAngle[0] = vals[4].toFloat();
7214 aPlane->myAngle[1] = vals[5].toFloat();
7218 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7219 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7220 aClippingPlaneInfo.Plane = aPlane;
7221 aClippingPlaneInfo.ActorList = anActorList;
7222 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7230 int aPlaneId = val.toInt( &ok );
7231 if( ok && aPlaneId >= 0 ) {
7232 bool anIsDefinedPlane = false;
7233 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7234 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7235 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7236 TPlaneInfo& aPlaneInfo = *anIter;
7237 if( aPlaneInfo.PlaneId == aPlaneId ) {
7238 aPlaneInfo.ActorList.push_back( aSmeshActor );
7239 anIsDefinedPlane = true;
7243 if( !anIsDefinedPlane ) {
7244 TPlaneInfo aPlaneInfo;
7245 aPlaneInfo.PlaneId = aPlaneId;
7246 aPlaneInfo.ActorList.push_back( aSmeshActor );
7247 aPlaneInfo.ViewManager = vman;
7249 // to make the list sorted by plane id
7250 anIter = aPlaneInfoList.begin();
7251 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7252 const TPlaneInfo& aPlaneInfoRef = *anIter;
7253 if( aPlaneInfoRef.PlaneId > aPlaneId )
7256 aPlaneInfoList.insert( anIter, aPlaneInfo );
7261 } // if (aSmeshActor)
7262 } // other parameters than Visibility
7264 } // for names/parameters iterator
7265 } // for entries iterator
7267 // take into account planes with empty list of actors referred to them
7268 QList<SUIT_ViewManager*> aVMList;
7269 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7271 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7272 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7273 int aViewId = aPlaneDataIter->first;
7274 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7275 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7277 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7279 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7280 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7281 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7282 const TPlaneData& aPlaneData = *anIter2;
7283 int aPlaneId = aPlaneData.Id;
7285 bool anIsFound = false;
7286 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7287 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7288 const TPlaneInfo& aPlaneInfo = *anIter3;
7289 if( aPlaneInfo.PlaneId == aPlaneId ) {
7296 TPlaneInfo aPlaneInfo; // ActorList field is empty
7297 aPlaneInfo.PlaneId = aPlaneId;
7298 aPlaneInfo.ViewManager = aViewManager;
7300 // to make the list sorted by plane id
7301 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7302 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7303 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7304 if( aPlaneInfoRef.PlaneId > aPlaneId )
7307 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7313 // add clipping planes to actors according to the restored parameters
7314 // and update the clipping plane map
7315 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7316 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7317 int aViewId = anIter1->first;
7318 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7320 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7321 if( anIter2 == aPlaneDataMap.end() )
7323 const TPlaneDataList& aPlaneDataList = anIter2->second;
7325 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7326 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7327 const TPlaneInfo& aPlaneInfo = *anIter3;
7328 int aPlaneId = aPlaneInfo.PlaneId;
7329 const TActorList& anActorList = aPlaneInfo.ActorList;
7330 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7334 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7338 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7340 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7341 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7342 const TPlaneData& aPlaneData = *anIter4;
7343 if( aPlaneData.Id == aPlaneId ) {
7344 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7345 aPlane->myViewWindow = aViewWindow;
7346 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7347 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7348 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7349 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7350 aPlane->X = aPlaneData.X;
7351 aPlane->Y = aPlaneData.Y;
7352 aPlane->Z = aPlaneData.Z;
7353 aPlane->Dx = aPlaneData.Dx;
7354 aPlane->Dy = aPlaneData.Dy;
7355 aPlane->Dz = aPlaneData.Dz;
7357 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7358 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7359 aPlane->myDistance = aPlaneData.Distance;
7360 aPlane->myAngle[0] = aPlaneData.Angle[0];
7361 aPlane->myAngle[1] = aPlaneData.Angle[1];
7364 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7365 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7366 aClippingPlaneInfo.Plane = aPlane;
7367 aClippingPlaneInfo.ActorList = anActorList;
7368 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7379 // update all VTK views
7380 QList<SUIT_ViewManager*> lst;
7381 getApp()->viewManagers(lst);
7382 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7383 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7384 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7385 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7386 // set OpenGL clipping planes
7387 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7388 vtkActorCollection* anAllActors = aCopy.GetActors();
7389 anAllActors->InitTraversal();
7390 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7391 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7392 anActor->SetOpenGLClippingPlane();
7394 vtkView->getRenderer()->ResetCameraClippingRange();
7401 \brief Adds preferences for dfont of VTK viewer
7403 \param pIf group identifier
7404 \param param parameter
7405 \return identifier of preferences
7407 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7409 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7411 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7414 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7415 fam.append( tr( "SMESH_FONT_COURIER" ) );
7416 fam.append( tr( "SMESH_FONT_TIMES" ) );
7418 setPreferenceProperty( tfont, "fonts", fam );
7420 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7421 if ( needSize ) f = f | QtxFontEdit::Size;
7422 setPreferenceProperty( tfont, "features", f );
7428 \brief Actions after hypothesis edition
7429 Updates object browser after hypothesis edition
7431 void SMESHGUI::onHypothesisEdit( int result )
7434 SMESHGUI::Modified();
7435 updateObjBrowser( true );
7439 \brief Actions after choosing menu of control modes
7440 Updates control mode actions according to current selection
7442 void SMESHGUI::onUpdateControlActions()
7444 SALOME_ListIO selected;
7445 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7446 aSel->selectedObjects( selected );
7448 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7449 if ( selected.Extent() ) {
7450 if ( selected.First()->hasEntry() ) {
7451 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7452 aControl = anActor->GetControlMode();
7453 SALOME_ListIteratorOfListIO it(selected);
7454 for ( it.Next(); it.More(); it.Next() ) {
7455 Handle(SALOME_InteractiveObject) anIO = it.Value();
7456 if ( anIO->hasEntry() ) {
7457 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7458 if ( aControl != anActor->GetControlMode() ) {
7459 aControl = SMESH_Actor::eNone;
7469 int anAction = ActionToControl( aControl, true );
7471 action( anAction )->setChecked( true );
7473 QMenu* send = (QMenu*)sender();
7474 QList<QAction*> actions = send->actions();
7475 for ( int i = 0; i < actions.size(); i++ )
7476 actions[i]->setChecked( false );
7482 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7483 \param pview view being closed
7485 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7486 #ifndef DISABLE_PLOT2DVIEWER
7487 //Crear all Plot2d Viewers if need.
7488 SMESH::ClearPlot2Viewers(pview);
7490 EmitSignalCloseView();
7493 void SMESHGUI::message( const QString& msg )
7496 QStringList data = msg.split("/");
7497 if ( data.count() > 0 ) {
7498 if ( data.first() == "mesh_loading" ) {
7500 QString entry = data.count() > 1 ? data[1] : QString();
7501 if ( entry.isEmpty() )
7504 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7506 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7509 name = SMESH::fromUtf8(obj->GetName());
7510 if ( name.isEmpty() )
7513 if ( data.last() == "stop" )
7514 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7516 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7517 QApplication::processEvents();
7523 \brief Connects or disconnects signals about activating and cloning view on the module slots
7524 \param pview view which is connected/disconnected
7526 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7530 SUIT_ViewManager* viewMgr = pview->getViewManager();
7532 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7533 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7535 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7536 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7541 \brief Return \c true if object can be renamed
7543 bool SMESHGUI::renameAllowed( const QString& entry) const {
7544 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7548 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7552 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7557 if(appStudy->isComponent(entry) || obj->isReference())
7560 // check type to prevent renaming of inappropriate objects
7561 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7562 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7563 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7564 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7565 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7566 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7573 Rename object by entry.
7574 \param entry entry of the object
7575 \param name new name of the object
7576 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7578 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7580 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7584 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7589 _PTR(Study) aStudy = appStudy->studyDS();
7594 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7596 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7601 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7602 _PTR(GenericAttribute) anAttr;
7603 _PTR(AttributeName) aName;
7605 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7607 // check type to prevent renaming of inappropriate objects
7608 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7609 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7610 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7611 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7612 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7613 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7614 if ( !name.isEmpty() ) {
7615 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7617 // update name of group object and its actor
7618 Handle(SALOME_InteractiveObject) IObject =
7619 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7621 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7622 if( !aGroupObject->_is_nil() ) {
7623 aGroupObject->SetName( qUtf8Printable(name) );
7624 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7625 anActor->setName( qUtf8Printable(name) );
7635 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7637 static QList<QColor> colors;
7639 if ( colors.isEmpty() ) {
7641 for (int s = 0; s < 2 ; s++)
7643 for (int v = 100; v >= 40; v = v - 20)
7645 for (int h = 0; h < 359 ; h = h + 60)
7647 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7652 static int currentColor = randomize( colors.size() );
7654 SALOMEDS::Color color;
7655 color.R = (double)colors[currentColor].red() / 255.0;
7656 color.G = (double)colors[currentColor].green() / 255.0;
7657 color.B = (double)colors[currentColor].blue() / 255.0;
7659 currentColor = (currentColor+1) % colors.count();