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 <Basics_OCCTVersion.hxx>
27 #if OCC_VERSION_LARGE < 0x07080000
29 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
34 #ifndef _USE_MATH_DEFINES
35 #define _USE_MATH_DEFINES
43 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
49 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
50 #include "SMESHGUI_AddMeshElementDlg.h"
51 #include "SMESHGUI_AddNodeOnSegmentDlg.h"
52 #include "SMESHGUI_AddNodeOnFaceDlg.h"
53 #include "SMESHGUI_AddQuadraticElementDlg.h"
54 #include "SMESHGUI_BuildCompoundDlg.h"
55 #include "SMESHGUI_ClippingDlg.h"
56 #include "SMESHGUI_ComputeDlg.h"
57 #include "SMESHGUI_ConvToQuadOp.h"
58 #include "SMESHGUI_CopyMeshDlg.h"
59 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
60 #include "SMESHGUI_DeleteGroupDlg.h"
61 #include "SMESHGUI_DisplayEntitiesDlg.h"
62 #include "SMESHGUI_Displayer.h"
63 #include "SMESHGUI_DuplicateNodesDlg.h"
64 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
65 #include "SMESHGUI_ExtrusionDlg.h"
66 #include "SMESHGUI_FaceGroupsSeparatedByEdgesDlg.h"
67 #include "SMESHGUI_FieldSelectorWdg.h"
68 #include "SMESHGUI_FileInfoDlg.h"
69 #include "SMESHGUI_FileValidator.h"
70 #include "SMESHGUI_FilterDlg.h"
71 #include "SMESHGUI_FilterLibraryDlg.h"
72 #include "SMESHGUI_FilterUtils.h"
73 #include "SMESHGUI_FindElemByPointDlg.h"
74 #include "SMESHGUI_GEOMGenUtils.h"
75 #include "SMESHGUI_GroupDlg.h"
76 #include "SMESHGUI_GroupOnShapeDlg.h"
77 #include "SMESHGUI_GroupOpDlg.h"
78 #include "SMESHGUI_GroupUtils.h"
79 #include "SMESHGUI_Hypotheses.h"
80 #include "SMESHGUI_HypothesesUtils.h"
81 #include "SMESHGUI_MG_ADAPTDRIVER.h"
82 #include "SMESHGUI_HomardAdaptDlg.h"
83 #include "SMESHGUI_Make2DFrom3DOp.h"
84 #include "SMESHGUI_MakeFull2DFrom3DOp.h"
85 #include "SMESHGUI_MakeNodeAtPointDlg.h"
86 #include "SMESHGUI_Measurements.h"
87 #include "SMESHGUI_MergeDlg.h"
88 #include "SMESHGUI_MeshInfo.h"
89 #include "SMESHGUI_Meshio.h"
90 #include "SMESHGUI_MeshOp.h"
91 #include "SMESHGUI_MeshOrderOp.h"
92 #include "SMESHGUI_MeshPatternDlg.h"
93 #include "SMESHGUI_MeshUtils.h"
94 #include "SMESHGUI_MultiEditDlg.h"
95 #include "SMESHGUI_NodesDlg.h"
96 #include "SMESHGUI_OffsetDlg.h"
97 #include "SMESHGUI_Operations.h"
98 #include "SMESHGUI_PatternUtils.h"
99 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
100 #include "SMESHGUI_PropertiesDlg.h"
101 #include "SMESHGUI_RemoveElementsDlg.h"
102 #include "SMESHGUI_RemoveNodeReconnectionDlg.h"
103 #include "SMESHGUI_RemoveNodesDlg.h"
104 #include "SMESHGUI_RenumberingDlg.h"
105 #include "SMESHGUI_ReorientFacesDlg.h"
106 #include "SMESHGUI_RevolutionDlg.h"
107 #include "SMESHGUI_RotationDlg.h"
108 #include "SMESHGUI_ScaleDlg.h"
109 #include "SMESHGUI_Selection.h"
110 #include "SMESHGUI_SewingDlg.h"
111 #include "SMESHGUI_SingleEditDlg.h"
112 #include "SMESHGUI_SmoothingDlg.h"
113 #include "SMESHGUI_SpinBox.h"
114 #include "SMESHGUI_SplitBiQuad.h"
115 #include "SMESHGUI_SymmetryDlg.h"
116 #include "SMESHGUI_TranslationDlg.h"
117 #include "SMESHGUI_TransparencyDlg.h"
118 #include "SMESHGUI_CreateDualMeshDlg.h"
119 #include "SMESHGUI_CreateDualMeshOp.h"
120 #include "SMESHGUI_Utils.h"
121 #include "SMESHGUI_VTKUtils.h"
123 #include "SMESH_version.h"
125 #include "SMESH_Actor.h"
126 #include "SMESH_ActorUtils.h"
127 #include "SMESH_Client.hxx"
128 #include "SMESH_Comment.hxx"
129 #include "SMESH_ControlsDef.hxx"
130 #include "SMESH_ScalarBarActor.h"
131 #include "SMESH_TypeFilter.hxx"
133 // SALOME GUI includes
134 #include <LightApp_DataOwner.h>
135 #include <LightApp_NameDlg.h>
136 #include <LightApp_Preferences.h>
137 #include <LightApp_SelectionMgr.h>
138 #include <LightApp_UpdateFlags.h>
139 #include <QtxFontEdit.h>
140 #include <QtxPopupMgr.h>
141 #include <QtxInfoPanel.h>
142 #include <SALOME_ListIO.hxx>
143 #include <SUIT_Desktop.h>
144 #include <SUIT_FileDlg.h>
145 #include <SUIT_MessageBox.h>
146 #include <SUIT_OverrideCursor.h>
147 #include <SUIT_ResourceMgr.h>
148 #include <SUIT_Session.h>
149 #include <SVTK_Renderer.h>
150 #include <SVTK_ViewManager.h>
151 #include <SVTK_ViewModel.h>
152 #include <SVTK_ViewWindow.h>
153 #include <SalomeApp_Application.h>
154 #include <SalomeApp_CheckFileDlg.h>
155 #include <SalomeApp_DataObject.h>
156 #include <SalomeApp_Study.h>
157 #include <SalomeApp_Tools.h>
158 #include <VTKViewer_Algorithm.h>
160 #ifndef DISABLE_PLOT2DVIEWER
161 #include <SPlot2d_ViewModel.h>
162 #include <SPlot2d_Histogram.h>
166 #include <SALOMEconfig.h>
167 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
168 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
169 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
170 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
171 #include CORBA_CLIENT_HEADER(SMESH_Homard)
174 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
175 #include <QApplication>
177 #include <QDialogButtonBox>
181 #include <QTextStream>
185 #include <boost/shared_ptr.hpp>
188 #include <vtkCallbackCommand.h>
189 #include <vtkCamera.h>
190 #include <vtkLookupTable.h>
191 #include <vtkPlane.h>
192 #include <vtkRenderer.h>
194 // SALOME KERNEL includes
195 #include <Basics_Utils.hxx>
196 #include <SALOMEDSClient_ClientFactory.hxx>
197 #include <SALOMEDSClient_IParameters.hxx>
198 #include <SALOMEDSClient_SComponent.hxx>
199 #include <SALOMEDSClient_StudyBuilder.hxx>
200 #include <SALOMEDS_SObject.hxx>
201 #include <SALOMEDS_Study.hxx>
202 #include <SALOME_GenericObj_wrap.hxx>
203 #include <SALOME_LifeCycleCORBA.hxx>
204 #include <utilities.h>
207 #include <Standard_ErrorHandler.hxx>
208 #include <NCollection_DataMap.hxx>
209 #include <NCollection_DoubleMap.hxx>
211 // Below macro, when uncommented, switches on simplified (more performant) algorithm
212 // of auto-color picking up
213 #define SIMPLE_AUTOCOLOR
218 //=============================================================
219 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
222 void ExportMeshToFile(int theCommandID);
224 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
226 void SetDisplayEntity(int theCommandID);
228 int ActionToControl( int theID, bool theReversed = false );
230 void Control( int theCommandID );
234 //================================================================================
236 * \brief Reads meshes from file
238 //================================================================================
240 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
244 std::string myExtension;
246 if ( theCommandID == SMESHOp::OpImportMED ||
247 theCommandID == SMESHOp::OpPopupImportMED ) {
248 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
249 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
251 else if ( theCommandID == SMESHOp::OpImportUNV ||
252 theCommandID == SMESHOp::OpPopupImportUNV ) {
253 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
255 else if ( theCommandID == SMESHOp::OpImportDAT ||
256 theCommandID == SMESHOp::OpPopupImportDAT ) {
257 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
259 else if ( theCommandID == SMESHOp::OpImportSTL ||
260 theCommandID == SMESHOp::OpPopupImportSTL ) {
261 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
263 else if ( theCommandID == SMESHOp::OpImportCGNS ||
264 theCommandID == SMESHOp::OpPopupImportCGNS ) {
265 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
267 else if ( theCommandID == SMESHOp::OpImportGMF ||
268 theCommandID == SMESHOp::OpPopupImportGMF ) {
269 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
270 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
272 else if (theCommandID == SMESHOp::OpImportMESHIO) {
273 if (!SMESHGUI_Meshio::IsMeshioInstalled())
276 filter = SMESHGUI_Meshio::GetImportFileFilter();
279 QString anInitialPath = "";
280 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
281 anInitialPath = QDir::currentPath();
283 QStringList filenames;
284 bool toCreateGroups = true;
286 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
287 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
288 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
289 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
290 // fd->setNameFilters( filter );
291 // fd->SetChecked( true );
293 // filenames << fd->selectedFile();
294 // toCreateGroups = fd->IsChecked();
300 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
303 QObject::tr( "SMESH_IMPORT_MESH" ) );
305 if ( filenames.count() > 0 )
307 SUIT_OverrideCursor wc;
308 _PTR(Study) aStudy = SMESH::getStudy();
311 QStringList anEntryList;
312 bool isEmpty = false;
313 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
315 QString filename = *it;
316 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
318 switch ( theCommandID ) {
319 case SMESHOp::OpImportDAT:
320 case SMESHOp::OpPopupImportDAT:
322 // DAT format (currently unsupported)
323 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
324 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
327 case SMESHOp::OpImportUNV:
328 case SMESHOp::OpPopupImportUNV:
331 aMeshes->length( 1 );
332 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
333 if ( aMeshes[0]->_is_nil() )
334 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
335 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
338 case SMESHOp::OpImportMED:
339 case SMESHOp::OpPopupImportMED:
342 SMESH::DriverMED_ReadStatus res;
343 aMeshes = theComponentMesh->CreateMeshesFromMED( 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::OpImportSTL:
351 case SMESHOp::OpPopupImportSTL:
354 aMeshes->length( 1 );
355 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
356 if ( aMeshes[0]->_is_nil() ) {
357 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
358 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
362 case SMESHOp::OpImportCGNS:
363 case SMESHOp::OpPopupImportCGNS:
366 SMESH::DriverMED_ReadStatus res;
367 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
368 if ( res != SMESH::DRS_OK ) {
369 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
370 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
374 case SMESHOp::OpImportGMF:
375 case SMESHOp::OpPopupImportGMF:
378 SMESH::ComputeError_var res;
379 aMeshes->length( 1 );
380 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
383 if ( res->code != SMESH::DRS_OK ) {
384 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
385 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
386 if ( strlen( res->comment.in() ) > 0 ) {
387 errors.back() += ": ";
388 errors.back() += res->comment.in();
393 case SMESHOp::OpImportMESHIO:
395 aMeshes = SMESHGUI_Meshio::ImportMesh(theComponentMesh, filename, errors);
400 catch ( const SALOME::SALOME_Exception& S_ex ) {
401 const QString exText(S_ex.details.text);
402 if (exText.startsWith("MESHIO"))
403 errors.append('\n' + exText);
405 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
406 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
409 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
411 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
413 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
414 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
415 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
416 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
417 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
419 anEntryList.append( aMeshSO->GetID().c_str() );
427 // update Object browser
428 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
430 // browse to the published meshes
431 if( LightApp_Application* anApp =
432 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
433 anApp->browseObjects( anEntryList );
435 // show Error message box if there were errors
436 if ( errors.count() > 0 ) {
437 SUIT_MessageBox::critical( SMESHGUI::desktop(),
438 QObject::tr( "SMESH_ERROR" ),
439 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
442 // show warning message box, if some imported mesh is empty
444 SUIT_MessageBox::warning( SMESHGUI::desktop(),
445 QObject::tr( "SMESH_WRN_WARNING" ),
446 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
451 //================================================================================
453 * \brief Export selected meshes or groups into a file
455 //================================================================================
457 void ExportMeshToFile( int theCommandID )
459 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
460 SALOME_ListIO selected;
462 aSel->selectedObjects( selected );
464 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
465 theCommandID == SMESHOp::OpPopupExportDAT );
466 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
467 theCommandID == SMESHOp::OpPopupExportMED );
468 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
469 theCommandID == SMESHOp::OpPopupExportUNV );
470 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
471 theCommandID == SMESHOp::OpPopupExportSTL );
472 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
473 theCommandID == SMESHOp::OpPopupExportCGNS );
474 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
475 theCommandID == SMESHOp::OpPopupExportGMF );
476 const bool isMESHIO = (theCommandID == SMESHOp::OpExportMESHIO);
478 if (isMESHIO && !SMESHGUI_Meshio::IsMeshioInstalled())
483 const bool multiMeshSupported = isMED || isCGNS || isMESHIO; // file can hold several meshes
484 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
486 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
487 bool aCheckWarn = true;
489 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
491 // get mesh object from selection and check duplication of their names
492 bool hasDuplicatedMeshNames = false;
493 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
494 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
495 SALOME_ListIteratorOfListIO It( selected );
496 for( ; It.More(); It.Next() )
498 Handle(SALOME_InteractiveObject) anIObject = It.Value();
499 SMESH::SMESH_IDSource_var aMeshItem =
500 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
501 if ( aMeshItem->_is_nil() ) {
502 SUIT_MessageBox::warning( SMESHGUI::desktop(),
503 QObject::tr( "SMESH_WRN_WARNING" ),
504 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
507 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
508 if ( aCheckWarn && !aGroup->_is_nil() )
510 QMessageBox msgBox(SUIT_MessageBox::Warning,
511 QObject::tr("SMESH_WRN_WARNING"),
512 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
513 QMessageBox::StandardButton::NoButton,
514 SMESHGUI::desktop());
515 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
516 msgBox.addButton(QMessageBox::Ok);
517 msgBox.addButton(QMessageBox::Cancel);
518 msgBox.setDefaultButton(QMessageBox::Cancel);
519 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
520 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
521 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
522 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
523 if ( msgBox.exec() != QMessageBox::Ok )
526 if ( dontShowCheckBox.checkState() == Qt::Checked && resMgr )
527 resMgr->setValue( "SMESH", "show_warning", false);
530 QString aMeshName = anIObject->getName();
532 // check for name duplications
533 if ( !hasDuplicatedMeshNames )
534 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
535 if( aMeshName == (*aMeshIter).second ) {
536 hasDuplicatedMeshNames = true;
541 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
544 if( hasDuplicatedMeshNames && isMED ) {
545 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
546 QObject::tr("SMESH_WRN_WARNING"),
547 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
548 QObject::tr("SMESH_BUT_YES"),
549 QObject::tr("SMESH_BUT_NO"), 0, 1);
554 aMeshIter = aMeshList.begin();
555 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
556 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
557 QString aMeshName = (*aMeshIter).second;
559 if (isMED || isCGNS || isMESHIO) // formats where group names must be unique
561 // check for equal group names within each mesh
562 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
563 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
564 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
565 int aRet = SUIT_MessageBox::warning
566 (SMESHGUI::desktop(),
567 QObject::tr("SMESH_WRN_WARNING"),
568 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
569 QObject::tr("SMESH_BUT_YES"),
570 QObject::tr("SMESH_BUT_NO"), 0, 1);
577 // Warn the user about presence of not supported elements
579 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
583 notSupportedElemTypes.push_back( SMESH::Entity_0D );
584 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
589 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
590 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
591 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
592 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
593 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
594 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
595 notSupportedElemTypes.push_back( SMESH::Entity_0D );
596 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
601 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
602 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
603 notSupportedElemTypes.push_back( SMESH::Entity_0D );
604 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
609 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
614 notSupportedElemTypes.push_back( SMESH::Entity_0D );
615 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
616 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
617 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
618 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
619 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
620 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
621 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
622 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
623 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
625 if ( ! notSupportedElemTypes.empty() )
627 SMESH::smIdType_array_var nbElems = aMeshOrGroup->GetMeshInfo();
628 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
629 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
630 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
632 if ( !presentNotSupported.empty() )
635 const char* typeMsg[] = {
636 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
637 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
638 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
639 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
640 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
641 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
642 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
643 "SMESH_BIQUADRATIC_PENTAHEDRONS",
644 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
646 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
647 static_assert( sizeof(typeMsg) / sizeof(const char*) == SMESH::Entity_Last,
648 "Update names of EntityType's!!!" );
650 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
651 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
652 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
653 if ( iType != presentNotSupported.size() - 1 )
654 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
656 int aRet = SUIT_MessageBox::warning
657 (SMESHGUI::desktop(),
658 QObject::tr("SMESH_WRN_WARNING"),
659 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
660 QObject::tr("SMESH_BUT_YES"),
661 QObject::tr("SMESH_BUT_NO"), 0, 1);
666 // Get parameters of export operation
669 QString aSelectedFilter; // for meshio to get a filter selected by user
670 int aFormat =-1; // for MED version used for write
671 bool isOkToWrite = true; // to check MED file version compatibility before adding a mesh in an existing file
673 // Init the parameters with the default values
674 bool aIsASCII_STL = true;
675 bool toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
676 bool toOverwrite = true;
677 bool toFindOutDim = true;
678 bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true );
679 bool toRenumber = true;
680 double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. );
682 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
683 QString anInitialPath = "";
684 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
685 anInitialPath = QDir::currentPath();
687 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
689 // Get a file name to write in and additional options
690 if ( isGMF ) // Export w/o options
692 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
693 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
694 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
696 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
697 anInitialPath + QString("/") + aMeshName,
698 aFilter, aTitle, false);
700 else if ( isCGNS || isUNV || isDAT ) // Export to [ CGNS | UNV | DAT ] - one option
702 const char* theOptionResource = isCGNS ? "cgns_group_elems_by_type" : "export_renumber";
703 bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
705 QStringList checkBoxes;
706 checkBoxes << QObject::tr( isCGNS ? "CGNS_EXPORT_ELEMS_BY_TYPE" : "SMESH_RENUMBER" );
708 SalomeApp_CheckFileDlg* fd =
709 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
710 fd->setWindowTitle( aTitle );
712 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
714 fd->setNameFilter( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
716 fd->setNameFilter( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
717 if ( !anInitialPath.isEmpty() )
718 fd->setDirectory( anInitialPath );
719 fd->selectFile( aMeshName );
720 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
721 fd->setValidator( fv );
722 fd->SetChecked( option, 0 );
725 aFilename = fd->selectedFile();
726 toOverwrite = fv->isOverwrite( aFilename );
727 option = fd->IsChecked( 0 );
728 SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
729 ( isCGNS ? toCreateGroups : toRenumber ) = option;
733 else if ( isSTL ) // Export to STL
735 QMap<QString, int> aFilterMap;
736 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
737 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
740 QMap<QString, int>::const_iterator it = aFilterMap.begin();
741 for ( ; it != aFilterMap.end(); ++it )
742 filters.push_back( it.key() );
744 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
745 fd->setWindowTitle( aTitle );
746 fd->setNameFilters( filters );
747 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
748 if ( !anInitialPath.isEmpty() )
749 fd->setDirectory( anInitialPath );
750 fd->selectFile(aMeshName);
754 aFilename = fd->selectedFile();
755 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
760 else if ( isMED ) // Export to MED
762 int defaultVersion = 0;
763 QMap<QString, int> aFilterMap;
764 //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
765 //QString vmed (aMesh->GetVersionString(-1, 2));
766 SMESH::long_array_var mvok = aMesh->GetMEDVersionsCompatibleForAppend();
767 if ( mvok->length() > 0)
768 defaultVersion = mvok[0]; // the current version to set the default filter on it
769 for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
771 QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
772 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
775 QMap<QString, int>::const_iterator it = aFilterMap.begin();
776 QString aDefaultFilter = it.key();
777 for ( ; it != aFilterMap.end(); ++it ) {
778 filters.push_back( it.key() );
779 if (it.value() == defaultVersion) // explicit default for MED = current MED version
780 aDefaultFilter = it.key();
782 QStringList checkBoxes;
783 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS")
784 << QObject::tr("SMESH_AUTO_DIM")
785 << QObject::tr("SMESH_MED_SAVE_NUMS");
787 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
788 QList< QWidget* > wdgList;
789 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
790 wdgList.append( fieldSelWdg );
792 QWidget* zTolWdg = new QWidget();
793 QCheckBox* zTolCheck = new QCheckBox( QObject::tr( "SMESH_ZTOLERANCE" ), zTolWdg );
794 SMESHGUI_SpinBox* zTolSpin = new SMESHGUI_SpinBox( zTolWdg );
795 QHBoxLayout* zTolLayout = new QHBoxLayout( zTolWdg );
796 zTolLayout->addWidget( zTolCheck );
797 zTolLayout->addWidget( zTolSpin );
798 zTolLayout->setMargin( 0 );
799 zTolSpin->RangeStepAndValidator( 0, 1e+100, 1., "length_precision" );
800 zTolSpin->setValue( zTol );
801 QObject::connect( zTolCheck, SIGNAL( toggled(bool)), zTolSpin, SLOT( setEnabled(bool)));
802 zTolCheck->setChecked( resMgr->booleanValue( "SMESH", "enable_ztolerance", false ));
803 zTolSpin ->setEnabled( zTolCheck->isChecked() );
804 wdgList.append( zTolWdg );
806 SalomeApp_CheckFileDlg* fd =
807 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
808 fd->setWindowTitle( aTitle );
809 fd->setNameFilters( filters );
810 fd->selectNameFilter( aDefaultFilter );
811 fd->SetChecked( toCreateGroups, 0 );
812 fd->SetChecked( toFindOutDim, 1 );
813 fd->SetChecked( saveNumbers, 2 );
814 if ( !anInitialPath.isEmpty() )
815 fd->setDirectory( anInitialPath );
816 fd->selectFile(aMeshName);
819 QListView *lview = fd->findChild<QListView*>("listView");
821 lview->setMinimumHeight(200);
823 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
825 tview->setMinimumHeight(200);
828 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
829 fd->setValidator( fv );
834 //MESSAGE("******* Loop on file dialog ***********");
837 aFilename = fd->selectedFile();
839 aFilename = QString::null;
842 aFormat = aFilterMap[fd->selectedNameFilter()];
843 //MESSAGE("selected version: " << aFormat << " file: " << aFilename.toUtf8().constData());
844 toOverwrite = fv->isOverwrite(aFilename);
845 //MESSAGE("toOverwrite:" << toOverwrite);
847 if ( !aFilename.isEmpty() ) {
849 // append is only possible if the existing file format is compatible
850 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckWriteCompatibility( aFilename.toUtf8().constData() );
851 MESSAGE("Append check, isVersionOk:" << isVersionOk);
852 if ( !isVersionOk ) {
853 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
854 QObject::tr("SMESH_WRN_WARNING"),
855 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
856 QObject::tr("SMESH_BUT_YES"),
857 QObject::tr("SMESH_BUT_NO"), 0, 1);
861 //MESSAGE("incompatible MED file version for add, overwrite accepted");
867 //MESSAGE("incompatible MED file version for add, overwrite refused");
870 QStringList aMeshNamesCollisionList;
871 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
872 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
873 QString anExistingMeshName( aMeshNames[ i ] );
874 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
875 QString anExportMeshName = (*aMeshIter).second;
876 if( anExportMeshName == anExistingMeshName ) {
877 aMeshNamesCollisionList.append( anExportMeshName );
882 if( !aMeshNamesCollisionList.isEmpty() ) {
884 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
885 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
886 QObject::tr("SMESH_WRN_WARNING"),
887 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
888 QObject::tr("SMESH_BUT_YES"),
889 QObject::tr("SMESH_BUT_NO"),
890 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
891 MESSAGE("answer collision name " << aRet);
902 toCreateGroups = fd->IsChecked(0);
903 toFindOutDim = fd->IsChecked(1);
904 saveNumbers = fd->IsChecked(2);
905 zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1;
906 fieldSelWdg->GetSelectedFields();
907 if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() );
909 if ( !fieldSelWdg->parent() )
911 if ( !zTolWdg->parent() )
917 if (SMESHGUI_Meshio::CheckMeshCount(aMeshList))
919 aFilename = SMESHGUI_Meshio::GetFileName(aSelectedFilter);
920 MESSAGE("aSelectedFilter: " << aSelectedFilter.toStdString());
930 if ( !aFilename.isEmpty() ) {
931 // Check whether the file already exists and delete it if yes
932 QFile aFile( aFilename );
933 if ( aFile.exists() && toOverwrite )
935 SUIT_OverrideCursor wc;
938 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
939 // bool Renumber = false;
940 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
942 // Renumber= resMgr->booleanValue("renumbering");
944 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
945 // aMeshEditor->RenumberNodes();
946 // aMeshEditor->RenumberElements();
947 // if ( SMESHGUI::automaticUpdate() )
948 // SMESH::UpdateView();
950 if ( isMED && isOkToWrite )
952 aMeshIter = aMeshList.begin();
953 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
955 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
956 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
957 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
958 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
960 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
961 toCreateGroups, aFormat,
962 toOverwrite && aMeshIndex == 0, toFindOutDim,
963 fields, geoAssFields.toLatin1().data(), zTol, saveNumbers );
968 if ( aMeshOrGroup->_is_equivalent( aMesh ))
969 aMesh->ExportDAT( aFilename.toUtf8().data(), toRenumber );
971 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
975 if ( aMeshOrGroup->_is_equivalent( aMesh ))
976 aMesh->ExportUNV( aFilename.toUtf8().data(), toRenumber );
978 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
982 if ( aMeshOrGroup->_is_equivalent( aMesh ))
983 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
985 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
989 aMeshIter = aMeshList.begin();
990 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
992 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
993 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
994 aMeshItem->ExportCGNS( aMeshOrGroup,
995 aFilename.toUtf8().data(),
996 toOverwrite && aMeshIndex == 0,
1002 toCreateGroups = true;
1003 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
1007 SMESHGUI_Meshio::ExportMesh(aMeshList, aFilename, aSelectedFilter);
1010 catch (const SALOME::SALOME_Exception& S_ex)
1013 const QString exText(S_ex.details.text);
1015 if ( S_ex.details.type == SALOME::COMM && // communicate about too large mesh
1016 strncmp( "format=", S_ex.details.sourceFile.in(), 7 ) == 0 )
1018 SUIT_MessageBox::critical(SMESHGUI::desktop(),
1019 QObject::tr("SMESH_WRN_WARNING"),
1020 QObject::tr(S_ex.details.text.in() ));
1021 else if (exText.startsWith("MESHIO"))
1023 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1024 QObject::tr("SMESH_WRN_WARNING"),
1025 QObject::tr("SMESH_EXPORT_FAILED_SHORT") + "\n\n" + exText);
1028 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1029 QObject::tr("SMESH_WRN_WARNING"),
1030 QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
1036 inline void InverseEntityMode(unsigned int& theOutputMode,
1037 unsigned int theMode)
1039 bool anIsNotPresent = ~theOutputMode & theMode;
1041 theOutputMode |= theMode;
1043 theOutputMode &= ~theMode;
1046 void SetDisplayEntity(int theCommandID)
1048 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1049 SALOME_ListIO selected;
1051 aSel->selectedObjects( selected );
1053 if ( selected.Extent() >= 1 ) {
1054 SUIT_OverrideCursor wc;
1055 SALOME_ListIteratorOfListIO It( selected );
1056 for( ; It.More(); It.Next()){
1057 Handle(SALOME_InteractiveObject) IObject = It.Value();
1058 if(IObject->hasEntry()){
1059 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1060 unsigned int aMode = anActor->GetEntityMode();
1061 switch(theCommandID){
1062 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1063 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1064 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1065 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1066 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1067 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1070 anActor->SetEntityMode(aMode);
1079 SalomeApp_Application* app =
1080 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1084 LightApp_SelectionMgr* aSel = app->selectionMgr();
1085 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1086 if ( !aSel || !appStudy )
1089 SALOME_ListIO selected;
1090 aSel->selectedObjects( selected );
1091 if ( selected.IsEmpty() )
1094 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1096 _PTR(Study) aStudy = appStudy->studyDS();
1097 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1098 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1099 if ( aMainObject->_is_nil() )
1102 SUIT_OverrideCursor wc;
1104 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1106 QList<SALOMEDS::Color> aReservedColors;
1108 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1109 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1111 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1113 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1114 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1115 #else // old algorithm for auto-colors
1116 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1117 aReservedColors.append( aColor );
1118 #endif // SIMPLE_AUTOCOLOR
1119 aGroupObject->SetColor( aColor );
1121 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1122 if ( aGroupSObject ) {
1125 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1126 switch ( aGroupObject->GetType ()) {
1128 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1130 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1132 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1134 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1136 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1137 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1140 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1141 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1147 SMESH::RepaintCurrentView();
1150 void OverallMeshQuality()
1152 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1153 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1154 SALOME_ListIO selected;
1156 aSel->selectedObjects( selected );
1158 if ( selected.IsEmpty() ) return;
1159 SALOME_ListIteratorOfListIO It( selected );
1160 for ( ; It.More(); It.Next() ) {
1161 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1162 ctrlDlg->showInfo( It.Value() );
1167 QString functorToString( SMESH::Controls::FunctorPtr f )
1169 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1170 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1171 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1172 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1173 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1174 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1175 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1176 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1177 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1178 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1179 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1180 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1181 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1182 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1183 type = QObject::tr( "WARP_ELEMENTS" );
1184 else if (dynamic_cast<SMESH::Controls::Warping3D*>(f.get()))
1185 type = QObject::tr("WARP_3D_ELEMENTS");
1186 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1187 type = QObject::tr( "TAPER_ELEMENTS" );
1188 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1189 type = QObject::tr( "SKEW_ELEMENTS" );
1190 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1191 type = QObject::tr( "AREA_ELEMENTS" );
1192 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1193 type = QObject::tr( "LENGTH_EDGES" );
1194 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1195 type = QObject::tr( "LENGTH2D_EDGES" );
1196 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1197 type = QObject::tr( "DEFLECTION2D_FACES" );
1198 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1199 type = QObject::tr( "MULTI_BORDERS" );
1200 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1201 type = QObject::tr( "MULTI2D_BORDERS" );
1202 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1203 type = QObject::tr( "FREE_NODES" );
1204 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1205 type = QObject::tr( "FREE_EDGES" );
1206 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1207 type = QObject::tr( "FREE_BORDERS" );
1208 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1209 type = QObject::tr( "FREE_FACES" );
1210 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1211 type = QObject::tr( "BARE_BORDER_VOLUME" );
1212 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1213 type = QObject::tr( "BARE_BORDER_FACE" );
1214 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1215 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1216 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1217 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1218 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1219 type = QObject::tr( "EQUAL_NODE" );
1220 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1221 type = QObject::tr( "EQUAL_EDGE" );
1222 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1223 type = QObject::tr( "EQUAL_FACE" );
1224 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1225 type = QObject::tr( "EQUAL_VOLUME" );
1226 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1227 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1228 else if ( dynamic_cast< SMESH::Controls::ScaledJacobian* >( f.get() ) )
1229 type = QObject::tr( "SCALED_JACOBIAN" );
1233 void SaveDistribution()
1235 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1236 SALOME_ListIO selected;
1238 aSel->selectedObjects( selected );
1240 if ( selected.Extent() == 1 ) {
1241 Handle(SALOME_InteractiveObject) anIO = selected.First();
1242 if ( anIO->hasEntry() ) {
1243 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1245 anActor->GetScalarBarActor() &&
1246 anActor->GetControlMode() != SMESH_Actor::eNone )
1248 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1249 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1250 if ( aScalarBarActor && aFunctor ) {
1251 SMESH::Controls::NumericalFunctor* aNumFun =
1252 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1254 std::vector<smIdType> elements;
1255 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1256 if ( mesh->_is_nil() ) {
1257 SMESH::SMESH_IDSource_var idSource =
1258 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1259 if ( !idSource->_is_nil() )
1261 SMESH::smIdType_array_var ids = idSource->GetIDs();
1262 elements.resize( ids->length() );
1263 for ( unsigned i = 0; i < elements.size(); ++i )
1264 elements[i] = ids[i];
1267 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1268 vtkLookupTable* lookupTable =
1269 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1270 double * minmax = lookupTable->GetRange();
1271 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1272 std::vector<int> nbEvents;
1273 std::vector<double> funValues;
1274 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1275 elements, minmax, isLogarithmic );
1276 QString anInitialPath = "";
1277 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1278 anInitialPath = QDir::currentPath();
1279 QString aMeshName = anIO->getName();
1281 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1282 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1283 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1284 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1285 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1288 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1290 if ( !aFilename.isEmpty() ) {
1291 QFile f( aFilename );
1292 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1293 QTextStream out( &f );
1294 out << "# Mesh: " << aMeshName << endl;
1295 out << "# Control: " << functorToString( aFunctor ) << endl;
1297 out.setFieldWidth( 10 );
1298 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1299 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1310 void ShowElement( int theCommandID )
1312 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1313 SALOME_ListIO selected;
1315 aSel->selectedObjects( selected );
1317 if ( selected.Extent() == 1 ) {
1318 Handle(SALOME_InteractiveObject) anIO = selected.First();
1319 if ( anIO->hasEntry() ) {
1320 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1322 anActor->GetScalarBarActor() &&
1323 anActor->GetControlMode() != SMESH_Actor::eNone )
1325 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1326 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1327 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1329 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1330 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1337 #ifndef DISABLE_PLOT2DVIEWER
1338 void PlotDistribution()
1340 SalomeApp_Application* app =
1341 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1345 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1346 SALOME_ListIO selected;
1348 aSel->selectedObjects( selected );
1350 if ( selected.Extent() == 1 ) {
1351 Handle(SALOME_InteractiveObject) anIO = selected.First();
1352 if ( anIO->hasEntry() ) {
1353 //Find Actor by entry before getting Plot2d viewer,
1354 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1355 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1357 SUIT_ViewManager* aViewManager =
1358 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1362 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1366 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1370 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1372 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1373 QString functorName = functorToString( anActor->GetFunctor());
1374 QString aHistogramName("%1 : %2");
1375 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1376 aHistogram->setName(aHistogramName);
1377 aHistogram->setHorTitle(functorName);
1378 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1379 aPlot->displayObject(aHistogram, true);
1384 #endif //DISABLE_PLOT2DVIEWER
1386 void DisableAutoColor()
1388 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1389 SALOME_ListIO selected;
1391 aSel->selectedObjects( selected );
1393 if ( selected.Extent() ) {
1394 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1395 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1396 if ( !aMesh->_is_nil() ) {
1397 aMesh->SetAutoColor( false );
1404 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1405 SALOME_ListIO selected;
1407 aSel->selectedObjects( selected );
1408 if ( selected.Extent() )
1410 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1411 _PTR(Study) aStudy = SMESH::getStudy();
1412 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1414 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1415 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1422 // Break link with Shaper model
1423 void breakShaperLink()
1425 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1426 SALOME_ListIO selected;
1428 aSel->selectedObjects(selected);
1429 if (selected.Extent()) {
1430 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1431 _PTR(Study) aStudy = SMESH::getStudy();
1432 std::string aEntry = anIObject->getEntry();
1433 _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
1435 std::string aName = aSObj->GetName();
1436 QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
1437 QObject::tr("SMESH_WRN_WARNING"),
1438 QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
1439 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
1440 if (aRes == SUIT_MessageBox::Yes) {
1441 SUIT_DataOwnerPtrList aList;
1442 aSel->selected(aList, "ObjectBrowser", true);
1443 SUIT_DataOwner* aOwn = aList.first();
1444 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
1445 QString aREntry = sowner->entry();
1447 static GEOM::GEOM_Gen_var geomGen;
1448 if (CORBA::is_nil(geomGen)) {
1449 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1450 (SUIT_Session::session()->activeApplication());
1452 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
1453 Engines::EngineComponent_var comp =
1454 ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
1455 geomGen = GEOM::GEOM_Gen::_narrow(comp);
1458 if (!CORBA::is_nil(geomGen))
1460 geomGen->BreakLink(aREntry.toStdString().c_str());
1461 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1463 // remove actors whose objects are removed by BreakLink()
1464 QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
1465 SUIT_ViewWindow* wnd;
1466 foreach(wnd, wndList)
1467 SMESH::UpdateActorsAfterUpdateStudy(wnd);
1475 //================================================================================
1477 * \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
1478 * which means that the mesh can't be modified. It should be either re-computed
1479 * or breakShaperLink()'ed. Warn the user about it.
1481 //================================================================================
1483 bool warnOnGeomModif()
1485 SALOME_ListIO selected;
1486 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1487 aSel->selectedObjects(selected,"",/*convertReferences=*/false);
1489 SALOME_ListIteratorOfListIO It( selected );
1490 for ( ; It.More(); It.Next() )
1492 Handle(SALOME_InteractiveObject) io = It.Value();
1493 if ( !io->hasEntry() ) continue;
1494 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
1495 SMESH::SMESH_Mesh_var mesh;
1496 while ( mesh->_is_nil() && so && so->GetID() != "0:" )
1498 CORBA::Object_var obj = SMESH::SObjectToObject( so );
1499 SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
1500 if ( isrc->_is_nil() )
1501 so = so->GetFather();
1503 mesh = isrc->GetMesh();
1505 if ( mesh->_is_nil() ) continue;
1506 so = SMESH::FindSObject( mesh );
1507 if ( !so ) continue;
1508 _PTR(GenericAttribute) attr;
1509 so->FindAttribute( attr, "AttributePixMap" );
1510 _PTR(AttributePixMap) pixmap = attr;
1511 if ( !pixmap ) continue;
1513 if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
1515 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1516 QObject::tr("SMESH_WRN_WARNING"),
1517 QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
1524 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1526 SALOME_ListIO selected;
1527 SalomeApp_Application* app =
1528 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1532 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1533 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1534 if ( !aSel || !appStudy )
1537 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1538 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1539 aModule->EmitSignalDeactivateDialog();
1540 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1541 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1546 aSel->selectedObjects( selected );
1548 if ( selected.Extent() >= 1 )
1550 switch ( theCommandID ) {
1551 case SMESHOp::OpTransparency:
1553 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1554 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1557 case SMESHOp::OpProperties:
1560 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1561 QColor orientationColor, outlineColor, volumeColor;
1562 int deltaF = 0, deltaV = 0;
1565 double ballScale = 1.0;
1567 int outlineWidth = 1;
1568 double shrinkCoef = 0.0;
1569 double orientationScale = 0.0;
1570 bool orientation3d = false;
1571 VTK::MarkerType markerType = VTK::MT_NONE;
1572 VTK::MarkerScale markerScale = VTK::MS_NONE;
1574 bool hasNodes = false;
1575 int presentEntities = 0;
1576 bool firstTime = true;
1578 SALOME_ListIteratorOfListIO It( selected );
1579 for ( ; It.More(); It.Next() ) {
1580 Handle(SALOME_InteractiveObject) IObject = It.Value();
1581 if ( !IObject->hasEntry() ) continue;
1582 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1583 if ( !anActor || !anActor->GetObject() ) continue;
1586 // nodes: color, marker
1587 anActor->GetNodeColor( color[0], color[1], color[2] );
1588 nodeColor.setRgbF( color[0], color[1], color[2] );
1589 markerType = anActor->GetMarkerType();
1590 markerScale = anActor->GetMarkerScale();
1591 markerId = anActor->GetMarkerTexture();
1592 // edges: color, width
1593 anActor->GetEdgeColor( color[0], color[1], color[2] );
1594 edgeColor.setRgbF( color[0], color[1], color[2] );
1595 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1596 // faces: front color, back color (delta)
1597 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1598 faceColor.setRgbF( color[0], color[1], color[2] );
1599 // faces: front color, back color (delta)
1600 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1601 volumeColor.setRgbF( color[0], color[1], color[2] );
1602 // 0d elements: color, size
1603 anActor->Get0DColor( color[0], color[1], color[2] );
1604 elem0dColor.setRgbF( color[0], color[1], color[2] );
1605 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1606 // balls: color, size
1607 anActor->GetBallColor( color[0], color[1], color[2] );
1608 ballColor.setRgbF( color[0], color[1], color[2] );
1609 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1610 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1612 anActor->GetOutlineColor( color[0], color[1], color[2] );
1613 outlineColor.setRgbF( color[0], color[1], color[2] );
1614 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1615 // orientation vectors: color, scale, 3d flag
1616 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1617 orientationColor.setRgbF( color[0], color[1], color[2] );
1618 orientationScale = anActor->GetFacesOrientationScale();
1619 orientation3d = anActor->GetFacesOrientation3DVectors();
1621 shrinkCoef = anActor->GetShrinkFactor();
1624 firstTime = false; // we only take properties from first object (for performance reasons)
1627 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1628 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1629 presentEntities = presentEntities | SMESH_Actor::eEdges;
1630 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1631 presentEntities = presentEntities | SMESH_Actor::eFaces;
1632 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1633 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1634 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1635 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1636 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1637 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1639 // as we know that all types of elements are present, we can exit the loop
1640 if ( presentEntities == SMESH_Actor::eAllEntity )
1644 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1645 // nodes: color, marker
1646 dlg.setNodeColor( nodeColor );
1647 if( markerType != VTK::MT_USER )
1648 dlg.setNodeMarker( markerType, markerScale );
1650 dlg.setNodeCustomMarker( markerId );
1651 // edges: color, line width
1652 dlg.setEdgeColor( edgeColor );
1653 dlg.setEdgeWidth( edgeWidth );
1654 // faces: front color, back color
1655 dlg.setFaceColor( faceColor, deltaF );
1656 // volumes: normal color, reversed color
1657 dlg.setVolumeColor( volumeColor, deltaV );
1658 // outlines: color, line width
1659 dlg.setOutlineColor( outlineColor );
1660 dlg.setOutlineWidth( outlineWidth );
1661 // 0d elements: color, size
1662 dlg.setElem0dColor( elem0dColor );
1663 dlg.setElem0dSize( elem0dSize );
1664 // balls: color, size
1665 dlg.setBallColor( ballColor );
1666 //dlg.setBallSize( ballSize );
1667 dlg.setBallScale( ballScale );
1668 // orientation: color, scale, 3d flag
1669 dlg.setOrientationColor( orientationColor );
1670 dlg.setOrientationSize( int( orientationScale * 100. ) );
1671 dlg.setOrientation3d( orientation3d );
1672 // shrink: scale factor
1673 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1674 // hide unused controls
1675 dlg.showControls( presentEntities, hasNodes );
1678 nodeColor = dlg.nodeColor();
1679 markerType = dlg.nodeMarkerType();
1680 markerScale = dlg.nodeMarkerScale();
1681 markerId = dlg.nodeMarkerId();
1682 edgeColor = dlg.edgeColor();
1683 edgeWidth = dlg.edgeWidth();
1684 faceColor = dlg.faceColor();
1685 deltaF = dlg.faceColorDelta();
1686 volumeColor = dlg.volumeColor();
1687 deltaV = dlg.volumeColorDelta();
1688 outlineColor = dlg.outlineColor();
1689 outlineWidth = dlg.outlineWidth();
1690 elem0dColor = dlg.elem0dColor();
1691 elem0dSize = dlg.elem0dSize();
1692 ballColor = dlg.ballColor();
1693 // ballSize = dlg.ballSize();
1694 ballScale = dlg.ballScale();
1695 orientationColor = dlg.orientationColor();
1696 orientationScale = dlg.orientationSize() / 100.;
1697 orientation3d = dlg.orientation3d();
1698 shrinkCoef = dlg.shrinkCoef() / 100.;
1700 // store point markers that might be changed by the user
1701 theMarkerMap = dlg.customMarkers();
1703 // set properties from dialog box to the presentations
1704 SALOME_ListIteratorOfListIO It( selected );
1705 for ( ; It.More(); It.Next() ) {
1706 Handle(SALOME_InteractiveObject) IObject = It.Value();
1707 if ( !IObject->hasEntry() ) continue;
1708 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1709 if ( !anActor ) continue;
1711 // nodes: color, marker
1712 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1713 if ( markerType != VTK::MT_USER ) {
1714 anActor->SetMarkerStd( markerType, markerScale );
1717 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1718 if ( iter != theMarkerMap.end() )
1719 anActor->SetMarkerTexture( markerId, iter->second.second );
1721 // volumes: normal color, reversed color (delta)
1722 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1723 // faces: front color, back color (delta)
1724 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1725 // edges: color, width
1726 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1727 anActor->SetLineWidth( edgeWidth );
1729 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1730 anActor->SetOutlineWidth( outlineWidth );
1731 // 0D elements: color, size
1732 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1733 anActor->Set0DSize( elem0dSize );
1734 // balls: color, size
1735 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1736 // anActor->SetBallSize( ballSize );
1737 anActor->SetBallScale( ballScale );
1738 // orientation: color, scale, 3d flag
1739 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1740 anActor->SetFacesOrientationScale( orientationScale );
1741 anActor->SetFacesOrientation3DVectors( orientation3d );
1743 anActor->SetShrinkFactor( shrinkCoef );
1745 // for groups, set also proper color
1746 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1747 if ( !aGroupObject->_is_nil() ) {
1748 SMESH::ElementType anElementType = aGroupObject->GetType();
1750 switch( anElementType ) {
1752 aColor = nodeColor; break;
1754 aColor = edgeColor; break;
1756 aColor = faceColor; break;
1758 aColor = volumeColor; break;
1760 aColor = elem0dColor; break;
1762 aColor = ballColor; break;
1766 if ( aColor.isValid() ) {
1767 SALOMEDS::Color aGroupColor;
1768 aGroupColor.R = aColor.redF();
1769 aGroupColor.G = aColor.greenF();
1770 aGroupColor.B = aColor.blueF();
1771 aGroupObject->SetColor( aGroupColor );
1773 } // if ( !aGroupObject->_is_nil() )
1774 } // for ( ; It.More(); It.Next() )
1775 SMESH::RepaintCurrentView();
1776 } // if ( dlg.exec() )
1778 } // case SMESHOp::OpProperties:
1779 } // switch(theCommandID)
1780 SUIT_OverrideCursor wc;
1781 SALOME_ListIteratorOfListIO It( selected );
1782 for( ; It.More(); It.Next()){
1783 Handle(SALOME_InteractiveObject) IObject = It.Value();
1784 if(IObject->hasEntry()){
1785 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1786 switch(theCommandID){
1787 case SMESHOp::OpDMWireframe:
1788 anActor->SetRepresentation(SMESH_Actor::eEdge);
1790 case SMESHOp::OpDMShading:
1791 anActor->SetRepresentation(SMESH_Actor::eSurface);
1793 case SMESHOp::OpDMShrink:
1794 if(anActor->IsShrunk())
1795 anActor->UnShrink();
1797 anActor->SetShrink();
1799 case SMESHOp::OpDMNodes:
1800 anActor->SetRepresentation(SMESH_Actor::ePoint);
1802 case SMESHOp::OpRepresentationLines:
1803 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1804 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1806 case SMESHOp::OpRepresentationArcs:
1807 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1808 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1814 SMESH::RepaintCurrentView();
1818 int ActionToControl( int theID, bool theReversed )
1820 NCollection_DoubleMap<int,int> ActionControl;
1821 ActionControl.Bind( 0, SMESH_Actor::eNone );
1822 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1823 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1824 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1825 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1826 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1827 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1828 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1829 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1830 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1831 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1832 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1833 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1834 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1835 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1836 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1837 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1838 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1839 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1840 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1841 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1842 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1843 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1844 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1845 ActionControl.Bind( SMESHOp::OpWarping3D, SMESH_Actor::eWarping3D );
1846 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1847 ActionControl.Bind( SMESHOp::OpScaledJacobian, SMESH_Actor::eScaledJacobian );
1848 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1849 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1850 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1851 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1854 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1855 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1858 void Control( int theCommandID )
1860 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1861 _PTR(Study) aStudy = SMESH::getStudy();
1863 SALOME_ListIO selected;
1864 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1865 aSel->selectedObjects( selected );
1867 if ( !selected.IsEmpty() ) {
1868 SALOME_ListIteratorOfListIO It(selected);
1869 for ( ; It.More(); It.Next())
1871 Handle(SALOME_InteractiveObject) anIO = It.Value();
1872 if ( !anIO.IsNull() ) {
1873 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1875 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1876 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1877 if ( !anIDSrc->_is_nil() ) {
1878 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1879 if (( !anActor && selected.Extent() == 1 ) &&
1880 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1882 anActor->SetControlMode( aControl );
1883 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1884 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1888 if ( anActor->GetControlMode() != aControl )
1889 anActor->SetControlMode( aControl );
1890 QString functorName = functorToString( anActor->GetFunctor() );
1891 smIdType anEntitiesCount = anActor->GetNumberControlEntities();
1892 if (anEntitiesCount >= 0)
1893 functorName = functorName + ": " + QString::number(anEntitiesCount);
1894 anActor->GetScalarBarActor()->SetTitle( functorName.toUtf8().constData() );
1895 SMESH::RepaintCurrentView();
1896 #ifndef DISABLE_PLOT2DVIEWER
1897 if ( anActor->GetPlot2Histogram() ) {
1898 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1899 QString aHistogramName("%1 : %2");
1900 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1901 aHistogram->setName( aHistogramName );
1902 aHistogram->setHorTitle( functorName );
1903 SMESH::ProcessIn2DViewers( anActor );
1915 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1916 SMESH::MeshObjectType theType,
1917 const QString theInTypeName,
1918 QString & theOutTypeName)
1920 SMESH_TypeFilter aTypeFilter( theType );
1922 if ( !theIO.IsNull() )
1924 entry = theIO->getEntry();
1925 LightApp_DataOwner owner( entry );
1926 if ( aTypeFilter.isOk( &owner )) {
1927 theOutTypeName = theInTypeName;
1935 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1937 _PTR(Study) aStudy = SMESH::getStudy();
1938 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1940 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1941 CORBA::String_var anID = aSComp->GetID().c_str();
1942 if ( !strcmp(anID.in(),theIO->getEntry()) )
1948 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1949 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1950 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1951 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1952 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1960 // QString CheckHomogeneousSelection()
1962 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1963 // SALOME_ListIO selected;
1965 // aSel->selectedObjects( selected );
1967 // QString RefType = CheckTypeObject(selected.First());
1968 // SALOME_ListIteratorOfListIO It(selected);
1969 // for ( ; It.More(); It.Next())
1971 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1972 // QString Type = CheckTypeObject(IObject);
1973 // if ( Type.compare(RefType) != 0 )
1974 // return "Heterogeneous Selection";
1980 uint randomize( uint size )
1982 static bool initialized = false;
1983 if ( !initialized ) {
1984 qsrand( QDateTime::currentDateTime().toTime_t() );
1988 v = uint( (double)( v ) / RAND_MAX * size );
1989 v = qMax( uint(0), qMin ( v, size-1 ) );
1995 void SMESHGUI::OnEditDelete()
1997 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1998 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1999 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
2001 _PTR(Study) aStudy = SMESH::getStudy();
2002 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
2003 _PTR(GenericAttribute) anAttr;
2004 _PTR(AttributeIOR) anIOR;
2006 const int objectCountLimit = 30; // PAL23599
2007 int objectCount = 0;
2009 QString aParentComponent = QString::null;
2011 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
2013 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
2014 if ( anIO.IsNull() ) continue;
2016 QString father = "unknown", name;
2018 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
2020 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
2021 // check if object is reference
2022 _PTR(SObject) aRefSObj;
2023 if ( aSO->ReferencedObject( aRefSObj ) ) {
2024 name = QString::fromStdString ( aRefSObj->GetName() );
2025 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
2028 name = anIO->getName();
2031 if ( objectCount < objectCountLimit ) { // avoid occupying the whole screen
2032 aNameList.append("\n - ");
2033 aNameList.append( name );
2036 if( aParentComponent.isNull() )
2037 aParentComponent = father;
2038 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
2039 aParentComponent = "";
2041 if ( objectCount >= objectCountLimit )
2042 aNameList.append("\n - ...");
2044 if ( objectCount == 0 )
2045 return; // No Valid Objects Selected
2047 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
2048 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2049 QObject::tr("ERR_ERROR"),
2050 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
2053 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
2054 if (SUIT_MessageBox::warning
2055 (SMESHGUI::desktop(),
2056 QObject::tr("SMESH_WRN_WARNING"),
2057 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
2058 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
2059 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
2062 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2064 // Put one level of sub-objects of the selected SO's into a list
2065 // in order to get objects inside folders like "Assigned Algorithms"
2066 std::list< _PTR(SObject) > listSO;
2067 SALOME_ListIteratorOfListIO It(selected);
2068 for( ; It.More(); It.Next()) // loop on selected IO's
2070 Handle(SALOME_InteractiveObject) IObject = It.Value();
2071 if(IObject->hasEntry()) {
2072 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
2074 // disable removal of "SMESH" component object
2075 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
2077 if ( engineIOR() == anIOR->Value().c_str() )
2080 //Check the referenced object
2081 _PTR(SObject) aRefSObject;
2082 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
2083 aSO = aRefSObject; // Delete main Object instead of reference
2085 listSO.push_back( aSO );
2087 _PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
2088 for (it->InitEx(false); it->More(); it->Next())
2089 listSO.push_back( it->Value() );
2092 // Check if none of objects to delete is referred from outside
2093 std::list< _PTR(SObject) >::reverse_iterator ritSO;
2094 std::vector< _PTR(SObject) > subSO;
2095 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2097 _PTR(SObject) SO = *ritSO;
2098 if ( !SO ) continue;
2100 int nbChildren = SO->GetLastChildTag();
2102 subSO.reserve( 1 + nbChildren );
2103 subSO.push_back( SO );
2104 if ( nbChildren > 0 )
2106 _PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
2107 for ( it->InitEx( true ); it->More(); it->Next() )
2108 subSO.push_back( it->Value() );
2110 for ( size_t i = 0; i < subSO.size(); ++i )
2112 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
2113 for ( size_t j = 0; j < aReferences.size(); j++ ) {
2114 _PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
2115 std::string type = aComponent->ComponentDataType();
2116 if ( type != "SMESH" )
2118 SUIT_MessageBox::warning( anApp->desktop(),
2119 QObject::tr("WRN_WARNING"),
2120 QObject::tr("DEP_OBJECT") );
2121 return; // outside SMESH, there is an object depending on a SMESH object
2127 // Treat SO's in the list starting from the back
2128 aStudyBuilder->NewCommand(); // There is a transaction
2129 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2131 _PTR(SObject) SO = *ritSO;
2132 if ( !SO ) continue;
2133 std::string anEntry = SO->GetID();
2135 /** Erase graphical object and remove all its data **/
2136 if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
2137 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
2139 /** Remove an object from data structures **/
2140 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
2141 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
2142 if ( !aGroup->_is_nil() ) { // DELETE GROUP
2143 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
2144 aMesh->RemoveGroup( aGroup );
2146 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
2147 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2148 aMesh->RemoveSubMesh( aSubMesh );
2151 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
2152 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
2153 QString objType = CheckTypeObject(IObject);
2154 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
2155 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2156 aStudyBuilder->RemoveObjectWithChildren( SO );
2158 else {// default action: remove SObject from the study
2159 // Find Sub-Meshes and Group and delete corresopning visual objects and actors
2160 _PTR(ChildIterator) it1 = aStudy->NewChildIterator(SO);
2161 for (it1->InitEx(false); it1->More(); it1->Next()) {
2162 _PTR(SObject) SObj = it1->Value();
2163 if (!SObj) continue;
2164 if (SObj->FindAttribute(anAttr, "AttributeIOR")) {
2165 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(SMESH::SObjectToObject(SObj));
2166 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(SMESH::SObjectToObject(SObj));
2167 if (!aGroup->_is_nil() || !aSubMesh->_is_nil()) {
2168 SMESH::RemoveVisualObjectWithActors(SObj->GetID().c_str(), true);
2172 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2173 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2175 aStudyBuilder->RemoveObjectWithChildren( SO );
2179 } /* listSO back loop */
2181 aStudyBuilder->CommitCommand();
2183 /* Clear any previous selection */
2185 aSel->setSelectedObjects( l1 );
2187 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2191 SMESHGUI_EXPORT CAM_Module* createModule()
2193 return new SMESHGUI();
2196 SMESHGUI_EXPORT char* getModuleVersion() {
2197 return (char*)SMESH_VERSION_STR;
2201 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2203 //=============================================================================
2207 //=============================================================================
2208 SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" )
2210 if ( CORBA::is_nil( myComponentSMESH ) )
2212 CORBA::Boolean anIsEmbeddedMode;
2213 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2215 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2217 // 0019923: EDF 765 SMESH : default values of hypothesis
2218 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2219 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2220 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2221 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2222 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2224 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2225 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2226 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2228 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2229 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2233 myActiveDialogBox = 0;
2234 myFilterLibraryDlg = 0;
2238 myEventCallbackCommand = vtkCallbackCommand::New();
2239 myEventCallbackCommand->Delete();
2240 myEventCallbackCommand->SetClientData( this );
2241 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2244 /* load resources for all available meshers */
2245 SMESH::InitAvailableHypotheses();
2248 //=============================================================================
2252 //=============================================================================
2253 SMESHGUI::~SMESHGUI()
2257 //=============================================================================
2261 //=============================================================================
2262 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2264 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2266 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2271 //=============================================================================
2275 //=============================================================================
2276 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2278 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2282 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2283 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2284 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2285 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2286 return autoUpdate && !exceeded;
2289 //=============================================================================
2293 //=============================================================================
2294 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2295 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2297 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2301 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2302 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2303 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2305 SMESH::smIdType_array_var info = theMesh->GetMeshInfo();
2306 long nbOdElems = info[SMDSEntity_0D];
2307 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2308 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2309 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2310 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2311 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2312 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2313 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2314 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2315 info[SMDSEntity_Polyhedra] +
2316 info[SMDSEntity_Hexagonal_Prism];
2317 long nbBalls = info[SMDSEntity_Ball];
2319 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2320 *nbElements = requestedSize;
2322 *entities = SMESH_Actor::eAllEntity;
2325 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2327 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2329 if ( incrementalLimit ) {
2332 if ( nbOdElems > 0 ) {
2333 if ( total + nbOdElems > updateLimit ) {
2334 *entities = *entities & ~SMESH_Actor::e0DElements;
2335 *hidden = *hidden | SMESH_Actor::e0DElements;
2342 if ( nbEdges > 0 ) {
2343 if ( total + nbEdges > updateLimit ) {
2344 *entities = *entities & ~SMESH_Actor::eEdges;
2345 *hidden = *hidden | SMESH_Actor::eEdges;
2352 if ( nbFaces > 0 ) {
2353 if ( total + nbFaces > updateLimit ) {
2354 *entities = *entities & ~SMESH_Actor::eFaces;
2355 *hidden = *hidden | SMESH_Actor::eFaces;
2362 if ( nbVolumes > 0 ) {
2363 if ( total + nbVolumes > updateLimit ) {
2364 *entities = *entities & ~SMESH_Actor::eVolumes;
2365 *hidden = *hidden | SMESH_Actor::eVolumes;
2372 if ( nbBalls > 0 ) {
2373 if ( total + nbBalls > updateLimit ) {
2374 *entities = *entities & ~SMESH_Actor::eBallElem;
2375 *hidden = *hidden | SMESH_Actor::eBallElem;
2383 return autoUpdate && !exceeded;
2386 //=============================================================================
2390 //=============================================================================
2391 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2393 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2396 //=============================================================================
2400 //=============================================================================
2401 SMESHGUI* SMESHGUI::GetSMESHGUI()
2403 SMESHGUI* smeshMod = 0;
2404 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2407 CAM_Module* module = app->module( "Mesh" );
2408 smeshMod = dynamic_cast<SMESHGUI*>( module );
2416 Standard_EXPORT SMESHGUI* GetComponentGUI()
2418 return SMESHGUI::GetSMESHGUI();
2422 //=============================================================================
2426 //=============================================================================
2427 void SMESHGUI::SetState(int aState)
2432 //=============================================================================
2436 //=============================================================================
2437 void SMESHGUI::ResetState()
2442 //=============================================================================
2446 //=============================================================================
2447 void SMESHGUI::EmitSignalDeactivateDialog()
2449 emit SignalDeactivateActiveDialog();
2452 //=============================================================================
2456 //=============================================================================
2457 void SMESHGUI::EmitSignalStudyFrameChanged()
2459 emit SignalStudyFrameChanged();
2462 //=============================================================================
2466 //=============================================================================
2467 void SMESHGUI::EmitSignalCloseAllDialogs()
2469 emit SignalCloseAllDialogs();
2472 //=============================================================================
2476 //=============================================================================
2477 void SMESHGUI::EmitSignalVisibilityChanged()
2479 emit SignalVisibilityChanged();
2482 //=============================================================================
2486 //=============================================================================
2487 void SMESHGUI::EmitSignalCloseView()
2489 emit SignalCloseView();
2492 //=============================================================================
2496 //=============================================================================
2497 void SMESHGUI::EmitSignalActivatedViewManager()
2499 emit SignalActivatedViewManager();
2502 //=============================================================================
2506 //=============================================================================
2507 QDialog *SMESHGUI::GetActiveDialogBox()
2509 return myActiveDialogBox;
2512 //=============================================================================
2516 //=============================================================================
2517 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2519 myActiveDialogBox = (QDialog *) aDlg;
2523 //=============================================================================
2527 //=============================================================================
2528 SUIT_Desktop* SMESHGUI::desktop()
2530 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2532 return app->desktop();
2537 //=============================================================================
2541 //=============================================================================
2542 SalomeApp_Study* SMESHGUI::activeStudy()
2544 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2546 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2551 //=============================================================================
2555 //=============================================================================
2556 void SMESHGUI::Modified( bool theIsUpdateActions )
2558 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2559 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2560 appStudy->Modified();
2561 if( theIsUpdateActions )
2562 app->updateActions();
2567 //=============================================================================
2571 //=============================================================================
2572 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2574 /* Here the position is on the bottom right corner - 10 */
2575 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2577 SUIT_Desktop *PP = desktop();
2578 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2579 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2584 * \brief Verifies whether study of operation is locked
2585 * \param theMess - specifies whether message box must be shown if study is locked
2586 * \return State of study.
2588 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2589 * is locked when corresponding message box appears
2591 bool SMESHGUI::isStudyLocked( bool theMessage )
2593 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2596 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2597 QObject::tr( "WRN_WARNING" ),
2598 QObject::tr( "WRN_STUDY_LOCKED" ) );
2604 //=============================================================================
2608 //=============================================================================
2609 bool SMESHGUI::OnGUIEvent( int theCommandID )
2611 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2615 SUIT_ResourceMgr* mgr = resourceMgr();
2619 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2620 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2622 //QAction* act = action( theCommandID );
2623 bool logAction(false);
2625 switch (theCommandID) {
2626 case SMESHOp::OpDelete:
2627 if(isStudyLocked()) break;
2630 case SMESHOp::OpImportDAT:
2631 case SMESHOp::OpImportUNV:
2632 case SMESHOp::OpImportMED:
2633 case SMESHOp::OpImportSTL:
2634 case SMESHOp::OpImportCGNS:
2635 case SMESHOp::OpImportGMF:
2636 case SMESHOp::OpImportMESHIO:
2637 case SMESHOp::OpPopupImportDAT:
2638 case SMESHOp::OpPopupImportUNV:
2639 case SMESHOp::OpPopupImportMED:
2640 case SMESHOp::OpPopupImportSTL:
2641 case SMESHOp::OpPopupImportCGNS:
2642 case SMESHOp::OpPopupImportGMF:
2644 if(isStudyLocked()) break;
2645 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2649 case SMESHOp::OpFileInformation:
2651 SALOME_ListIO selected;
2652 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2654 aSel->selectedObjects( selected );
2655 if( selected.Extent() )
2657 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2658 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2659 if ( !aMesh->_is_nil() )
2661 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2667 case SMESHOp::OpExportDAT:
2668 case SMESHOp::OpExportMED:
2669 case SMESHOp::OpExportUNV:
2670 case SMESHOp::OpExportSTL:
2671 case SMESHOp::OpExportCGNS:
2672 case SMESHOp::OpExportGMF:
2673 case SMESHOp::OpExportMESHIO:
2674 case SMESHOp::OpPopupExportDAT:
2675 case SMESHOp::OpPopupExportMED:
2676 case SMESHOp::OpPopupExportUNV:
2677 case SMESHOp::OpPopupExportSTL:
2678 case SMESHOp::OpPopupExportCGNS:
2679 case SMESHOp::OpPopupExportGMF:
2681 ::ExportMeshToFile(theCommandID);
2685 case SMESHOp::OpReset: // SCALAR BAR
2687 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2688 SALOME_ListIO selected;
2690 aSel->selectedObjects( selected );
2692 SALOME_ListIteratorOfListIO it(selected);
2693 for( ; it.More(); it.Next()) {
2694 Handle(SALOME_InteractiveObject) anIO = it.Value();
2695 if( anIO->hasEntry() ) {
2696 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2697 anActor->SetControlMode( SMESH_Actor::eNone );
2698 #ifndef DISABLE_PLOT2DVIEWER
2699 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2701 anActor->UpdateFilter();
2705 SMESH::UpdateView();
2708 case SMESHOp::OpScalarBarProperties:
2710 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2713 case SMESHOp::OpShowScalarBar:
2715 // show/hide scalar bar
2716 ::ShowElement(theCommandID);
2719 case SMESHOp::OpSaveDistribution:
2721 // dump control distribution data to the text file
2722 ::SaveDistribution();
2726 case SMESHOp::OpShowDistribution:
2728 // show/hide distribution
2729 ::ShowElement(theCommandID);
2733 #ifndef DISABLE_PLOT2DVIEWER
2734 case SMESHOp::OpPlotDistribution:
2736 // plot distribution
2737 ::PlotDistribution();
2743 case SMESHOp::OpAutoColor:
2747 case SMESHOp::OpDisableAutoColor:
2748 ::DisableAutoColor();
2751 case SMESHOp::OpClipping:
2752 case SMESHOp::OpTransparency:
2753 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2756 case SMESHOp::OpDMWireframe:
2757 case SMESHOp::OpDMShading:
2758 case SMESHOp::OpDMNodes:
2759 case SMESHOp::OpDMShrink:
2760 ::SetDisplayMode(theCommandID, myMarkerMap);
2763 //2D quadratic representation
2764 case SMESHOp::OpRepresentationLines:
2765 case SMESHOp::OpRepresentationArcs:
2766 ::SetDisplayMode(theCommandID, myMarkerMap);
2770 case SMESHOp::OpDE0DElements:
2771 case SMESHOp::OpDEEdges:
2772 case SMESHOp::OpDEFaces:
2773 case SMESHOp::OpDEVolumes:
2774 case SMESHOp::OpDEBalls:
2775 case SMESHOp::OpDEAllEntity:
2776 ::SetDisplayEntity(theCommandID);
2779 // Choose entities to be displayed
2780 case SMESHOp::OpDEChoose:
2782 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2786 case SMESHOp::OpOrientationOnFaces:
2788 SUIT_OverrideCursor wc;
2789 LightApp_SelectionMgr* mgr = selectionMgr();
2790 SALOME_ListIO selected; mgr->selectedObjects( selected );
2792 SALOME_ListIteratorOfListIO it(selected);
2793 for( ; it.More(); it.Next()) {
2794 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2795 if(anIObject->hasEntry()) {
2796 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2797 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2804 case SMESHOp::OpUpdate:
2806 if(isStudyLocked()) break;
2807 SUIT_OverrideCursor wc;
2810 SMESH::UpdateView();
2812 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2813 SMESH::OnVisuException();
2815 catch (...) { // PAL16774 (Crash after display of many groups)
2816 SMESH::OnVisuException();
2820 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2821 aSel->selectedObjects( l );
2822 aSel->setSelectedObjects( l );
2826 case SMESHOp::OpHide:
2827 case SMESHOp::OpShow:
2828 case SMESHOp::OpShowOnly:
2830 SUIT_OverrideCursor wc;
2831 SMESH::EDisplaing anAction;
2832 switch (theCommandID) {
2833 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2834 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2835 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2838 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2839 SALOME_ListIO sel_objects, to_process;
2841 aSel->selectedObjects( sel_objects );
2843 if ( theCommandID==SMESHOp::OpShowOnly )
2845 //MESSAGE("anAction = SMESH::eDisplayOnly");
2846 startOperation( myEraseAll );
2849 extractContainers( sel_objects, to_process );
2854 SALOME_ListIteratorOfListIO It( to_process );
2855 for ( ; It.More(); It.Next())
2857 Handle(SALOME_InteractiveObject) IOS = It.Value();
2858 if ( IOS->hasEntry() )
2860 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2861 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2862 break; // PAL16774 (Crash after display of many groups)
2864 if (anAction == SMESH::eDisplayOnly)
2865 anAction = SMESH::eDisplay;
2870 // PAL13338 + PAL15161 -->
2871 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2872 SMESH::UpdateView();
2873 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2875 // PAL13338 + PAL15161 <--
2877 catch (...) { // PAL16774 (Crash after display of many groups)
2878 SMESH::OnVisuException();
2881 if (anAction == SMESH::eErase) {
2883 aSel->setSelectedObjects( l1 );
2886 aSel->setSelectedObjects( to_process );
2888 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2889 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2890 vtkwnd->GetRenderer()->AdjustActors();
2895 case SMESHOp::OpNode:
2897 if(isStudyLocked()) break;
2900 EmitSignalDeactivateDialog();
2902 ( new SMESHGUI_NodesDlg( this ) )->show();
2905 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2910 case SMESHOp::OpEditMeshOrSubMesh:
2911 case SMESHOp::OpEditMesh:
2912 case SMESHOp::OpEditSubMesh:
2913 case SMESHOp::OpMeshOrder:
2914 case SMESHOp::OpCreateSubMesh:
2915 if ( warnOnGeomModif() )
2916 break; // action forbidden as geometry modified
2918 case SMESHOp::OpCreateMesh:
2919 case SMESHOp::OpCompute:
2920 case SMESHOp::OpComputeSubMesh:
2921 case SMESHOp::OpPreCompute:
2922 case SMESHOp::OpEvaluate:
2923 case SMESHOp::OpShowErrors:
2924 startOperation( theCommandID );
2926 case SMESHOp::OpRecompute:
2928 if ( isStudyLocked() )
2930 SALOME_ListIO selected;
2931 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2932 sel->selectedObjects( selected );
2933 if ( selected.Extent() == 1 ) {
2934 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2935 if ( !aMesh->_is_nil() )
2937 startOperation( SMESHOp::OpCompute );
2941 case SMESHOp::OpCopyMesh:
2944 if (isStudyLocked()) break;
2945 EmitSignalDeactivateDialog();
2946 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2949 case SMESHOp::OpBuildCompoundMesh:
2951 if (isStudyLocked()) break;
2952 EmitSignalDeactivateDialog();
2953 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2957 case SMESHOp::OpDiagonalInversion:
2958 case SMESHOp::OpUnionOfTwoTriangle:
2962 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2966 if ( isStudyLocked() )
2968 if ( warnOnGeomModif() )
2969 break; // action forbidden as geometry modified
2971 /*Standard_Boolean aRes;
2972 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2973 if ( aMesh->_is_nil() )
2975 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2976 tr( "SMESH_BAD_SELECTION" ) );
2980 EmitSignalDeactivateDialog();
2981 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2982 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2984 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2987 case SMESHOp::OpOrientation:
2988 case SMESHOp::OpUnionOfTriangles:
2989 case SMESHOp::OpCuttingOfQuadrangles:
2990 case SMESHOp::OpSplitVolumes:
2994 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2998 if ( isStudyLocked() )
3000 if ( warnOnGeomModif() )
3001 break; // action forbidden as geometry modified
3003 EmitSignalDeactivateDialog();
3004 SMESHGUI_MultiEditDlg* aDlg = NULL;
3005 if ( theCommandID == SMESHOp::OpOrientation )
3006 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
3007 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
3008 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
3009 else if ( theCommandID == SMESHOp::OpSplitVolumes )
3010 aDlg = new SMESHGUI_SplitVolumesDlg(this);
3012 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
3017 case SMESHOp::OpSmoothing:
3019 if(isStudyLocked()) break;
3020 if ( warnOnGeomModif() )
3021 break; // action forbidden as geometry modified
3023 EmitSignalDeactivateDialog();
3024 ( new SMESHGUI_SmoothingDlg( this ) )->show();
3027 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3031 case SMESHOp::OpExtrusion:
3033 if (isStudyLocked()) break;
3034 if ( warnOnGeomModif() )
3035 break; // action forbidden as geometry modified
3037 EmitSignalDeactivateDialog();
3038 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
3040 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3044 case SMESHOp::OpExtrusionAlongAPath:
3046 if (isStudyLocked()) break;
3047 if ( warnOnGeomModif() )
3048 break; // action forbidden as geometry modified
3050 EmitSignalDeactivateDialog();
3051 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
3053 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3057 case SMESHOp::OpRevolution:
3059 if(isStudyLocked()) break;
3060 if ( warnOnGeomModif() )
3061 break; // action forbidden as geometry modified
3063 EmitSignalDeactivateDialog();
3064 ( new SMESHGUI_RevolutionDlg( this ) )->show();
3067 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3071 case SMESHOp::OpPatternMapping:
3073 if ( isStudyLocked() )
3075 if ( warnOnGeomModif() )
3076 break; // action forbidden as geometry modified
3079 EmitSignalDeactivateDialog();
3080 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3083 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3087 // Adaptation - begin
3088 #ifndef DISABLE_MG_ADAPT
3089 case SMESHOp::OpMGAdapt:
3091 if ( isStudyLocked() )
3093 EmitSignalDeactivateDialog();
3095 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3096 bool isCreation = false;
3097 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3101 #ifndef DISABLE_HOMARD_ADAPT
3102 case SMESHOp::OpHomardAdapt:
3104 if ( isStudyLocked() )
3106 EmitSignalDeactivateDialog();
3108 SALOME::GenericObj_wrap< SMESHHOMARD::HOMARD_Gen > homardGen;
3110 homardGen = GetSMESHGen()->CreateHOMARD_ADAPT();
3112 catch ( const SALOME::SALOME_Exception& S_ex ) {
3113 SUIT_MessageBox::critical(SMESHGUI::desktop(),
3114 QObject::tr("SMESH_ERROR"),
3115 QObject::tr(S_ex.details.text.in()));
3117 if (!homardGen->_is_nil()) {
3118 SMESHGUI_HomardAdaptDlg *aDlg = new SMESHGUI_HomardAdaptDlg(homardGen);
3125 case SMESHOp::OpSplitBiQuadratic:
3126 case SMESHOp::OpConvertMeshToQuadratic:
3127 case SMESHOp::OpCreateDualMesh:
3128 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3129 case SMESHOp::OpCreate2DElements: // create full 2D mesh from 3D
3130 case SMESHOp::OpReorientFaces:
3131 case SMESHOp::OpCreateGeometryGroup:
3133 if ( warnOnGeomModif() )
3134 break; // action forbidden as geometry modified
3135 startOperation( theCommandID );
3138 case SMESHOp::OpCreateGroup:
3142 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3146 if(isStudyLocked()) break;
3147 if ( warnOnGeomModif() )
3148 break; // action forbidden as geometry modified
3149 EmitSignalDeactivateDialog();
3150 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3152 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3153 SALOME_ListIO selected;
3155 aSel->selectedObjects( selected );
3157 int nbSel = selected.Extent();
3159 // check if mesh is selected
3160 aMesh = SMESH::GetMeshByIO( selected.First() );
3162 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3167 case SMESHOp::OpConstructGroup:
3171 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3175 if(isStudyLocked()) break;
3176 if ( warnOnGeomModif() )
3177 break; // action forbidden as geometry modified
3178 EmitSignalDeactivateDialog();
3180 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3181 SALOME_ListIO selected;
3183 aSel->selectedObjects( selected );
3185 int nbSel = selected.Extent();
3187 // check if submesh is selected
3188 Handle(SALOME_InteractiveObject) IObject = selected.First();
3189 if (IObject->hasEntry()) {
3190 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3192 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3193 if (!aSubMesh->_is_nil()) {
3195 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3196 // get submesh elements list by types
3197 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3198 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3199 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3200 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3201 // create group for each type o elements
3202 QString aName = IObject->getName();
3203 QStringList anEntryList;
3204 if (aNodes->length() > 0) {
3205 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3206 aGroup->Add(aNodes.inout());
3207 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3208 anEntryList.append( aSObject->GetID().c_str() );
3210 if (aEdges->length() > 0) {
3211 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3212 aGroup->Add(aEdges.inout());
3213 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3214 anEntryList.append( aSObject->GetID().c_str() );
3216 if (aFaces->length() > 0) {
3217 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3218 aGroup->Add(aFaces.inout());
3219 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3220 anEntryList.append( aSObject->GetID().c_str() );
3222 if (aVolumes->length() > 0) {
3223 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3224 aGroup->Add(aVolumes.inout());
3225 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3226 anEntryList.append( aSObject->GetID().c_str() );
3229 anApp->browseObjects( anEntryList );
3231 catch(const SALOME::SALOME_Exception & S_ex){
3232 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3239 SUIT_MessageBox::warning(desktop(),
3240 tr("SMESH_WRN_WARNING"),
3241 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3246 case SMESHOp::OpEditGroup:
3250 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3254 if(isStudyLocked()) break;
3255 if ( warnOnGeomModif() )
3256 break; // action forbidden as geometry modified
3257 EmitSignalDeactivateDialog();
3259 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3260 SALOME_ListIO selected;
3262 aSel->selectedObjects( selected );
3264 SALOME_ListIteratorOfListIO It (selected);
3265 int nbSelectedGroups = 0;
3266 for ( ; It.More(); It.Next() )
3268 SMESH::SMESH_GroupBase_var aGroup =
3269 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3270 if (!aGroup->_is_nil()) {
3272 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3276 if (nbSelectedGroups == 0)
3278 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3284 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3286 if(isStudyLocked()) break;
3287 if (myState == 800) {
3288 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3289 if (aDlg) aDlg->onAdd();
3294 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3296 if(isStudyLocked()) break;
3297 if (myState == 800) {
3298 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3299 if (aDlg) aDlg->onRemove();
3304 case SMESHOp::OpEditGeomGroupAsGroup:
3308 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3312 if(isStudyLocked()) break;
3313 EmitSignalDeactivateDialog();
3315 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3316 SALOME_ListIO selected;
3318 aSel->selectedObjects( selected );
3320 SALOME_ListIteratorOfListIO It (selected);
3321 for ( ; It.More(); It.Next() )
3323 SMESH::SMESH_GroupOnGeom_var aGroup =
3324 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3325 if (!aGroup->_is_nil()) {
3326 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3331 SMESH::SMESH_GroupOnFilter_var aGroup =
3332 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3333 if (!aGroup->_is_nil()) {
3334 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3342 case SMESHOp::OpUnionGroups:
3343 case SMESHOp::OpIntersectGroups:
3344 case SMESHOp::OpCutGroups:
3348 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3352 if ( isStudyLocked() )
3354 if ( warnOnGeomModif() )
3355 break; // action forbidden as geometry modified
3357 EmitSignalDeactivateDialog();
3359 SMESHGUI_GroupOpDlg* aDlg = 0;
3360 if ( theCommandID == SMESHOp::OpUnionGroups )
3361 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3362 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3363 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3365 aDlg = new SMESHGUI_CutGroupsDlg( this );
3372 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3374 if ( isStudyLocked() )
3376 if ( warnOnGeomModif() )
3377 break; // action forbidden as geometry modified
3379 EmitSignalDeactivateDialog();
3380 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3386 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3388 if ( isStudyLocked() )
3390 if ( warnOnGeomModif() )
3391 break; // action forbidden as geometry modified
3393 EmitSignalDeactivateDialog();
3394 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3400 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3404 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3408 if ( isStudyLocked() )
3411 EmitSignalDeactivateDialog();
3413 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3417 case SMESHOp::OpMeshInformation:
3418 case SMESHOp::OpWhatIs:
3420 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3421 EmitSignalDeactivateDialog();
3422 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3423 SALOME_ListIO selected;
3425 aSel->selectedObjects( selected );
3427 if ( selected.Extent() > 1 ) { // a dlg for each IO
3428 SALOME_ListIteratorOfListIO It( selected );
3429 for ( ; It.More(); It.Next() ) {
3430 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3431 dlg->showInfo( It.Value() );
3436 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3442 case SMESHOp::OpFindElementByPoint:
3444 startOperation( theCommandID );
3448 case SMESHOp::OpEditHypothesis:
3450 if(isStudyLocked()) break;
3451 if ( warnOnGeomModif() )
3452 break; // action forbidden as geometry modified
3454 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3455 SALOME_ListIO selected;
3457 aSel->selectedObjects( selected );
3459 int nbSel = selected.Extent();
3462 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3463 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3465 if ( !aHypothesis->_is_nil() )
3467 SMESHGUI_GenericHypothesisCreator* aCreator =
3468 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3471 // set geometry of mesh and sub-mesh to aCreator
3472 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3473 if ( selected.Extent() == 1 )
3475 QString subGeomID, meshGeomID;
3476 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3477 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3479 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3480 aCreator->setShapeEntry( subGeomID );
3481 aCreator->setMainShapeEntry( meshGeomID );
3485 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3495 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3497 if(isStudyLocked()) break;
3498 if ( warnOnGeomModif() )
3499 break; // action forbidden as geometry modified
3500 SUIT_OverrideCursor wc;
3502 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3503 SALOME_ListIO selected;
3505 aSel->selectedObjects( selected, QString::null, false );
3507 SALOME_ListIteratorOfListIO It(selected);
3508 for (int i = 0; It.More(); It.Next(), i++) {
3509 Handle(SALOME_InteractiveObject) IObject = It.Value();
3510 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3513 aSel->setSelectedObjects( l1 );
3518 case SMESHOp::OpElem0D:
3519 case SMESHOp::OpBall:
3520 case SMESHOp::OpEdge:
3521 case SMESHOp::OpTriangle:
3522 case SMESHOp::OpQuadrangle:
3523 case SMESHOp::OpPolygon:
3524 case SMESHOp::OpTetrahedron:
3525 case SMESHOp::OpHexahedron:
3526 case SMESHOp::OpPentahedron:
3527 case SMESHOp::OpPyramid:
3528 case SMESHOp::OpHexagonalPrism:
3530 if(isStudyLocked()) break;
3531 if ( warnOnGeomModif() )
3532 break; // action forbidden as geometry modified
3534 EmitSignalDeactivateDialog();
3535 SMDSAbs_EntityType type = SMDSEntity_Edge;
3536 switch (theCommandID) {
3537 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3538 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3539 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3540 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3541 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3542 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3543 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3544 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3545 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3546 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3549 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3552 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3556 case SMESHOp::OpPolyhedron:
3558 if(isStudyLocked()) break;
3559 if ( warnOnGeomModif() )
3560 break; // action forbidden as geometry modified
3562 EmitSignalDeactivateDialog();
3563 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3566 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3570 case SMESHOp::OpQuadraticEdge:
3571 case SMESHOp::OpQuadraticTriangle:
3572 case SMESHOp::OpBiQuadraticTriangle:
3573 case SMESHOp::OpQuadraticQuadrangle:
3574 case SMESHOp::OpBiQuadraticQuadrangle:
3575 case SMESHOp::OpQuadraticPolygon:
3576 case SMESHOp::OpQuadraticTetrahedron:
3577 case SMESHOp::OpQuadraticPyramid:
3578 case SMESHOp::OpQuadraticPentahedron:
3579 case SMESHOp::OpBiQuadraticPentahedron:
3580 case SMESHOp::OpQuadraticHexahedron:
3581 case SMESHOp::OpTriQuadraticHexahedron:
3583 if(isStudyLocked()) break;
3584 if ( warnOnGeomModif() )
3585 break; // action forbidden as geometry modified
3587 EmitSignalDeactivateDialog();
3588 SMDSAbs_EntityType type = SMDSEntity_Last;
3590 switch (theCommandID) {
3591 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3592 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3593 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3594 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3595 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3596 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3597 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3598 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3599 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3600 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3601 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3602 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3605 if ( type != SMDSEntity_Last )
3606 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3609 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3610 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3614 case SMESHOp::OpRemoveNodes:
3616 if(isStudyLocked()) break;
3617 if ( warnOnGeomModif() )
3618 break; // action forbidden as geometry modified
3620 EmitSignalDeactivateDialog();
3621 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3624 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3625 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3629 case SMESHOp::OpRemoveNodeWithReconn:
3631 if(isStudyLocked()) break;
3632 if ( warnOnGeomModif() )
3633 break; // action forbidden as geometry modified
3634 startOperation( SMESHOp::OpRemoveNodeWithReconn );
3637 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3639 if(isStudyLocked()) break;
3640 if ( warnOnGeomModif() )
3641 break; // action forbidden as geometry modified
3643 EmitSignalDeactivateDialog();
3644 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3648 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3649 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3653 case SMESHOp::OpClearMesh: {
3655 if(isStudyLocked()) break;
3656 if ( warnOnGeomModif() )
3657 break; // action forbidden as geometry modified
3659 SALOME_ListIO selected;
3660 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3661 aSel->selectedObjects( selected );
3663 SUIT_OverrideCursor wc;
3664 SALOME_ListIteratorOfListIO It (selected);
3665 for ( ; It.More(); It.Next() )
3667 Handle(SALOME_InteractiveObject) IOS = It.Value();
3668 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3669 if ( aMesh->_is_nil()) continue;
3672 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3673 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3674 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3675 // hide groups and submeshes
3676 _PTR(ChildIterator) anIter =
3677 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3678 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3680 _PTR(SObject) so = anIter->Value();
3681 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3684 catch (const SALOME::SALOME_Exception& S_ex){
3686 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3690 SMESH::UpdateView();
3694 case SMESHOp::OpRemoveOrphanNodes:
3696 if(isStudyLocked()) break;
3697 if ( warnOnGeomModif() )
3698 break; // action forbidden as geometry modified
3699 SALOME_ListIO selected;
3700 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3701 aSel->selectedObjects( selected );
3702 if ( selected.Extent() == 1 ) {
3703 Handle(SALOME_InteractiveObject) anIO = selected.First();
3704 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3705 if ( !aMesh->_is_nil() ) {
3706 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3707 tr( "SMESH_WARNING" ),
3708 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3709 SUIT_MessageBox::Yes |
3710 SUIT_MessageBox::No,
3711 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3714 SUIT_OverrideCursor wc;
3715 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3716 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3717 SUIT_MessageBox::information(SMESHGUI::desktop(),
3718 tr("SMESH_INFORMATION"),
3719 tr("NB_NODES_REMOVED").arg(removed));
3720 if ( removed > 0 ) {
3721 SMESH::UpdateView();
3722 SMESHGUI::Modified();
3725 catch (const SALOME::SALOME_Exception& S_ex) {
3726 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3735 case SMESHOp::OpRenumberingNodes:
3737 if(isStudyLocked()) break;
3738 if ( warnOnGeomModif() )
3739 break; // action forbidden as geometry modified
3741 EmitSignalDeactivateDialog();
3742 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3746 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3747 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3751 case SMESHOp::OpRenumberingElements:
3753 if(isStudyLocked()) break;
3754 if ( warnOnGeomModif() )
3755 break; // action forbidden as geometry modified
3757 EmitSignalDeactivateDialog();
3758 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3762 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3763 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3767 case SMESHOp::OpTranslation:
3770 if(isStudyLocked()) break;
3771 if ( warnOnGeomModif() )
3772 break; // action forbidden as geometry modified
3774 EmitSignalDeactivateDialog();
3775 ( new SMESHGUI_TranslationDlg( this ) )->show();
3778 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3779 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3783 case SMESHOp::OpRotation:
3786 if(isStudyLocked()) break;
3787 if ( warnOnGeomModif() )
3788 break; // action forbidden as geometry modified
3790 EmitSignalDeactivateDialog();
3791 ( new SMESHGUI_RotationDlg( this ) )->show();
3794 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3795 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3799 case SMESHOp::OpSymmetry:
3802 if(isStudyLocked()) break;
3803 if ( warnOnGeomModif() )
3804 break; // action forbidden as geometry modified
3806 EmitSignalDeactivateDialog();
3807 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3810 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3811 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3815 case SMESHOp::OpScale:
3818 if(isStudyLocked()) break;
3819 if ( warnOnGeomModif() )
3820 break; // action forbidden as geometry modified
3822 EmitSignalDeactivateDialog();
3823 ( new SMESHGUI_ScaleDlg( this ) )->show();
3826 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3827 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3832 case SMESHOp::OpOffset:
3835 if(isStudyLocked()) break;
3836 if ( warnOnGeomModif() )
3837 break; // action forbidden as geometry modified
3839 EmitSignalDeactivateDialog();
3840 ( new SMESHGUI_OffsetDlg( this ) )->show();
3843 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3844 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3849 case SMESHOp::OpSewing:
3852 if(isStudyLocked()) break;
3853 if ( warnOnGeomModif() )
3854 break; // action forbidden as geometry modified
3856 EmitSignalDeactivateDialog();
3857 ( new SMESHGUI_SewingDlg( this ) )->show();
3860 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3861 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3865 case SMESHOp::OpMergeNodes:
3867 if(isStudyLocked()) break;
3868 if ( warnOnGeomModif() )
3869 break; // action forbidden as geometry modified
3871 EmitSignalDeactivateDialog();
3872 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3875 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3876 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3880 case SMESHOp::OpMergeElements:
3882 if (isStudyLocked()) break;
3883 if ( warnOnGeomModif() )
3884 break; // action forbidden as geometry modified
3886 EmitSignalDeactivateDialog();
3887 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3889 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3890 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3895 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3896 if ( warnOnGeomModif() )
3897 break; // action forbidden as geometry modified
3898 startOperation( SMESHOp::OpMoveNode );
3901 case SMESHOp::OpMoveNodeInteractive:
3902 if ( warnOnGeomModif() )
3903 break; // action forbidden as geometry modified
3904 startOperation( SMESHOp::OpMoveNodeInteractive );
3907 case SMESHOp::OpSplitEdgeInteract:
3908 if ( warnOnGeomModif() )
3909 break; // action forbidden as geometry modified
3910 startOperation( SMESHOp::OpSplitEdgeInteract );
3913 case SMESHOp::OpSplitFaceInteract:
3914 if ( warnOnGeomModif() )
3915 break; // action forbidden as geometry modified
3916 startOperation( SMESHOp::OpSplitFaceInteract );
3919 case SMESHOp::OpDuplicateNodes:
3921 if(isStudyLocked()) break;
3922 if ( warnOnGeomModif() )
3923 break; // action forbidden as geometry modified
3925 EmitSignalDeactivateDialog();
3926 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3929 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3930 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3935 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3936 if ( warnOnGeomModif() )
3937 break; // action forbidden as geometry modified
3938 startOperation( SMESHOp::OpElem0DOnElemNodes );
3941 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3943 static QList<int> aTypes;
3944 if ( aTypes.isEmpty() )
3946 aTypes.append( SMESH::NODE );
3947 aTypes.append( SMESH::EDGE );
3948 aTypes.append( SMESH::FACE );
3949 aTypes.append( SMESH::VOLUME );
3951 if (!myFilterLibraryDlg)
3952 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3953 else if (myFilterLibraryDlg->isHidden())
3954 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3955 myFilterLibraryDlg->raise();
3959 case SMESHOp::OpFreeNode:
3960 case SMESHOp::OpEqualNode:
3961 case SMESHOp::OpNodeConnectivityNb:
3962 case SMESHOp::OpFreeEdge:
3963 case SMESHOp::OpFreeBorder:
3964 case SMESHOp::OpLength:
3965 case SMESHOp::OpConnection:
3966 case SMESHOp::OpEqualEdge:
3967 case SMESHOp::OpFreeFace:
3968 case SMESHOp::OpBareBorderFace:
3969 case SMESHOp::OpOverConstrainedFace:
3970 case SMESHOp::OpLength2D:
3971 case SMESHOp::OpDeflection2D:
3972 case SMESHOp::OpConnection2D:
3973 case SMESHOp::OpArea:
3974 case SMESHOp::OpTaper:
3975 case SMESHOp::OpAspectRatio:
3976 case SMESHOp::OpMinimumAngle:
3977 case SMESHOp::OpWarpingAngle:
3978 case SMESHOp::OpSkew:
3979 case SMESHOp::OpMaxElementLength2D:
3980 case SMESHOp::OpEqualFace:
3981 case SMESHOp::OpAspectRatio3D:
3982 case SMESHOp::OpWarping3D:
3983 case SMESHOp::OpVolume:
3984 case SMESHOp::OpScaledJacobian:
3985 case SMESHOp::OpMaxElementLength3D:
3986 case SMESHOp::OpBareBorderVolume:
3987 case SMESHOp::OpOverConstrainedVolume:
3988 case SMESHOp::OpEqualVolume:
3991 LightApp_SelectionMgr* mgr = selectionMgr();
3992 SALOME_ListIO selected; mgr->selectedObjects( selected );
3994 if( !selected.IsEmpty() ) {
3995 SUIT_OverrideCursor wc;
3996 ::Control( theCommandID );
3999 SUIT_MessageBox::warning(desktop(),
4000 tr( "SMESH_WRN_WARNING" ),
4001 tr( "SMESH_BAD_SELECTION" ) );
4005 SUIT_MessageBox::warning(desktop(),
4006 tr( "SMESH_WRN_WARNING" ),
4007 tr( "NOT_A_VTK_VIEWER" ) );
4010 case SMESHOp::OpOverallMeshQuality:
4011 OverallMeshQuality();
4013 case SMESHOp::OpNumberingNodes:
4015 SUIT_OverrideCursor wc;
4016 LightApp_SelectionMgr* mgr = selectionMgr();
4017 SALOME_ListIO selected; mgr->selectedObjects( selected );
4019 SALOME_ListIteratorOfListIO it(selected);
4020 for( ; it.More(); it.Next()) {
4021 Handle(SALOME_InteractiveObject) anIObject = it.Value();
4022 if(anIObject->hasEntry()) {
4023 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
4024 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
4030 case SMESHOp::OpNumberingElements:
4032 SUIT_OverrideCursor wc;
4033 LightApp_SelectionMgr* mgr = selectionMgr();
4034 SALOME_ListIO selected; mgr->selectedObjects( selected );
4036 SALOME_ListIteratorOfListIO it(selected);
4037 for( ; it.More(); it.Next()) {
4038 Handle(SALOME_InteractiveObject) anIObject = it.Value();
4039 if(anIObject->hasEntry())
4040 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
4041 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
4046 case SMESHOp::OpPropertiesLength:
4047 case SMESHOp::OpPropertiesArea:
4048 case SMESHOp::OpPropertiesVolume:
4049 case SMESHOp::OpMinimumDistance:
4050 case SMESHOp::OpBoundingBox:
4051 case SMESHOp::OpAngle:
4053 int page = SMESHGUI_MeasureDlg::MinDistance;
4054 if ( theCommandID == SMESHOp::OpBoundingBox )
4055 page = SMESHGUI_MeasureDlg::BoundingBox;
4056 else if ( theCommandID == SMESHOp::OpPropertiesLength )
4057 page = SMESHGUI_MeasureDlg::Length;
4058 else if ( theCommandID == SMESHOp::OpPropertiesArea )
4059 page = SMESHGUI_MeasureDlg::Area;
4060 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
4061 page = SMESHGUI_MeasureDlg::Volume;
4062 else if ( theCommandID == SMESHOp::OpAngle )
4063 page = SMESHGUI_MeasureDlg::Angle;
4065 EmitSignalDeactivateDialog();
4066 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
4070 case SMESHOp::OpSortChild:
4073 case SMESHOp::OpBreakLink:
4074 ::breakShaperLink();
4079 anApp->updateActions(); //SRN: To update a Save button in the toolbar
4080 //updateObjBrowser();
4083 QAction* anAction = action( theCommandID );
4084 CAM_Application::logStructuredUserEvent( "Mesh",
4092 //=============================================================================
4096 //=============================================================================
4097 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4102 //=============================================================================
4106 //=============================================================================
4107 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4112 //=============================================================================
4116 //=============================================================================
4117 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4122 //=============================================================================
4123 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
4124 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
4126 //=============================================================================
4127 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
4128 SUIT_ViewWindow* wnd )
4130 if(theIO->hasEntry()){
4131 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
4132 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
4136 //=======================================================================
4137 // function : createSMESHAction
4139 //=======================================================================
4140 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
4141 const int key, const bool toggle, const QString& shortcutAction )
4144 QWidget* parent = application()->desktop();
4145 SUIT_ResourceMgr* resMgr = resourceMgr();
4147 if ( !icon_id.isEmpty() )
4148 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4150 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4151 if ( !pix.isNull() )
4152 icon = QIcon( pix );
4154 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4155 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4156 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4158 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4159 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4162 //=======================================================================
4163 // function : createPopupItem
4165 //=======================================================================
4166 void SMESHGUI::createPopupItem( const int id,
4167 const QString& clients,
4168 const QString& types,
4169 const QString& theRule,
4172 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4173 popupMgr()->insert( action( id ), pId, 0 );
4175 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4176 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4177 QString rule = "(%1) and (%2) and (%3)";
4178 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4179 if( clients.isEmpty() )
4180 rule = rule.arg( QString( "true" ) );
4182 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4183 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4186 bool cont = myRules.contains( id );
4188 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4190 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4191 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4194 //=======================================================================
4195 // function : initialize
4197 //=======================================================================
4198 void SMESHGUI::initialize( CAM_Application* app )
4200 SalomeApp_Module::initialize( app );
4202 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4204 /* Automatic Update flag */
4205 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4207 // ----- create actions --------------
4209 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4210 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4211 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4212 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4214 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4216 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4217 createSMESHAction( SMESHOp::OpImportMESHIO, "IMPORT_MESHIO" );
4218 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4219 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4220 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4222 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4224 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4226 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4227 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4228 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4229 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4231 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4233 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4234 createSMESHAction( SMESHOp::OpExportMESHIO, "EXPORT_MESHIO" );
4235 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4236 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4237 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4238 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4240 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4242 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4243 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4244 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4245 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4246 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4247 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4248 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4249 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4250 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4251 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4252 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4253 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4254 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4255 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4256 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4257 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4258 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4259 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4260 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4261 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4262 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4263 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4264 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4265 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4266 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4267 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4268 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4269 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4270 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4271 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4272 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4273 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4274 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4275 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4276 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4278 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4279 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4280 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4281 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4282 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4283 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4284 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4285 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4286 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4287 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4288 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4289 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4290 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4291 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4292 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4293 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4294 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4295 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4296 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4297 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4298 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4299 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4300 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4301 createSMESHAction( SMESHOp::OpWarping3D, "WARP_3D", "ICON_WARP", 0, true);
4302 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4303 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4304 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4305 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4306 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4307 createSMESHAction( SMESHOp::OpScaledJacobian, "SCALED_JACOBIAN", "ICON_SCALED_JACOBIAN", 0, true );
4308 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4310 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4311 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4312 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4313 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4314 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4315 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4316 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4317 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4318 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4319 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4320 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4321 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4322 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4323 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4324 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4325 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4326 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4327 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4328 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4329 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4330 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4331 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4332 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4333 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4334 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4335 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4337 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4338 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4339 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4340 createSMESHAction( SMESHOp::OpRemoveNodeWithReconn, "REMOVE_NODE_RECON", "ICON_REM_NODE_RECON" );
4341 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4343 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4344 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4346 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4347 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4348 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4349 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4350 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4351 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4352 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4353 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4354 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4355 createSMESHAction( SMESHOp::OpMoveNodeInteractive, "MOVE_NODE_INTRCT","ICON_DLG_MOVE_NODE_INTERACTIVE" );
4356 createSMESHAction( SMESHOp::OpSplitEdgeInteract, "SPLIT_DIAG_INTRC","ICON_SPLIT_DIAG_INTERACTIVE" );
4357 createSMESHAction( SMESHOp::OpSplitFaceInteract, "SPLIT_FACE_INTRC","ICON_SPLIT_FACE_INTERACTIVE" );
4358 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4359 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4360 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4361 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4362 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4363 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4364 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4365 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4366 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4367 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4368 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4369 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4370 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4371 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4372 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4373 createSMESHAction( SMESHOp::OpCreateDualMesh, "CREATE_DUAL_MESH","ICON_CREATE_DUAL_MESH" );
4374 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4375 createSMESHAction( SMESHOp::OpCreate2DElements, "2D_FROM_3D_ELEMENTS","ICON_2D_FROM_3D_ELEMENTS" );
4377 createSMESHAction( SMESHOp::OpReset, "RESET" );
4378 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4379 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4380 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4381 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4382 #ifndef DISABLE_PLOT2DVIEWER
4383 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4385 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4386 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4387 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4388 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4389 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4390 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4391 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4392 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4393 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4394 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4395 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4396 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4397 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4399 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4400 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4402 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4403 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4404 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4405 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4406 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4407 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4408 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4409 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4410 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4412 // Adaptation - begin
4413 #ifndef DISABLE_MG_ADAPT
4414 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4416 #ifndef DISABLE_HOMARD_ADAPT
4417 createSMESHAction( SMESHOp::OpHomardAdapt, "HOMARD_ADAPT", "ICON_HOMARD_ADAPT" );
4421 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4422 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4423 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4424 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4425 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4426 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4428 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4429 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4430 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4432 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4434 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4436 QList<int> aCtrlActions;
4437 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4438 << SMESHOp::OpNodeConnectivityNb // node controls
4439 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4440 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4441 << SMESHOp::OpDeflection2D
4442 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4443 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4444 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4445 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4446 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4447 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume << SMESHOp::OpWarping3D
4448 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4449 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume << SMESHOp::OpScaledJacobian; // volume controls
4450 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4451 aCtrlGroup->setExclusive( true );
4452 for( int i = 0; i < aCtrlActions.size(); i++ )
4453 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4455 // ----- create menu --------------
4456 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4457 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4458 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4459 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4460 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4461 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4462 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4463 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4465 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4466 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4468 createMenu( separator(), fileId );
4470 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4471 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4472 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4473 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4474 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4475 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4476 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4477 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4478 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4479 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4480 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4481 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4482 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4485 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4486 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4487 createMenu( SMESHOp::OpImportMED, importId, -1 );
4488 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4490 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4492 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4493 createMenu( SMESHOp::OpImportMESHIO, importId, -1 ); // formats supported by meshio lib
4496 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4497 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4498 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4499 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4501 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4503 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4504 createMenu( SMESHOp::OpExportMESHIO, exportId, -1 ); // formats supported by meshio lib
4505 createMenu( separator(), fileId, 10 );
4507 createMenu( SMESHOp::OpDelete, editId, -1 );
4509 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4511 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4512 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4513 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4514 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4515 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4516 createMenu( SMESHOp::OpCreateDualMesh, meshId, -1 );
4517 createMenu( separator(), meshId, -1 );
4518 createMenu( SMESHOp::OpCompute, meshId, -1 );
4519 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4520 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4521 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4522 createMenu( separator(), meshId, -1 );
4523 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4524 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4525 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4526 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4527 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4528 createMenu( separator(), meshId, -1 );
4529 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4530 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4531 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4532 createMenu( separator(), meshId, -1 );
4533 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4534 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4535 createMenu( separator(), meshId, -1 );
4536 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4537 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4538 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4539 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4540 createMenu( separator(), meshId, -1 );
4542 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4543 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4544 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4545 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4546 createMenu( SMESHOp::OpLength, edgeId, -1 );
4547 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4548 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4549 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4550 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4551 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4552 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4553 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4554 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4555 createMenu( SMESHOp::OpArea, faceId, -1 );
4556 createMenu( SMESHOp::OpTaper, faceId, -1 );
4557 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4558 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4559 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4560 createMenu( SMESHOp::OpSkew, faceId, -1 );
4561 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4562 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4563 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4564 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4565 createMenu( SMESHOp::OpWarping3D, volumeId, -1 );
4566 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4567 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4568 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4569 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4570 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4571 createMenu( SMESHOp::OpScaledJacobian, volumeId, -1 );
4572 createMenu( separator(), ctrlId, -1 );
4573 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4574 createMenu( separator(), ctrlId, -1 );
4575 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4577 createMenu( SMESHOp::OpNode, addId, -1 );
4578 createMenu( SMESHOp::OpElem0D, addId, -1 );
4579 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4580 createMenu( SMESHOp::OpBall, addId, -1 );
4581 createMenu( SMESHOp::OpEdge, addId, -1 );
4582 createMenu( SMESHOp::OpTriangle, addId, -1 );
4583 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4584 createMenu( SMESHOp::OpPolygon, addId, -1 );
4585 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4586 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4587 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4588 createMenu( SMESHOp::OpPyramid, addId, -1 );
4589 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4590 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4591 createMenu( separator(), addId, -1 );
4592 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4593 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4594 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4595 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4596 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4597 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4598 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4599 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4600 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4601 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4602 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4603 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4604 createMenu( separator(), addId, -1 );
4605 createMenu( SMESHOp::OpSplitEdgeInteract, addId, -1 );
4606 createMenu( SMESHOp::OpSplitFaceInteract, addId, -1 );
4608 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4609 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4610 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4611 createMenu( SMESHOp::OpRemoveNodeWithReconn, removeId, -1 );
4612 createMenu( separator(), removeId, -1 );
4613 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4614 createMenu( separator(), removeId, -1 );
4615 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4617 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4618 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4620 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4621 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4622 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4623 createMenu( SMESHOp::OpRotation, transfId, -1 );
4624 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4625 createMenu( SMESHOp::OpScale, transfId, -1 );
4626 createMenu( SMESHOp::OpOffset, transfId, -1 );
4627 createMenu( SMESHOp::OpSewing, transfId, -1 );
4628 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4630 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4631 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4632 createMenu( SMESHOp::OpCreate2DElements, modifyId, -1 );
4633 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4634 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4635 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4636 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4637 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4638 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4639 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4640 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4641 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4642 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4643 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4644 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4645 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4646 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4648 // Adaptation - begin
4649 #ifndef DISABLE_MG_ADAPT
4650 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4652 #ifndef DISABLE_HOMARD_ADAPT
4653 createMenu( SMESHOp::OpHomardAdapt, adaptId, -1 );
4657 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4658 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4659 createMenu( SMESHOp::OpAngle, measureId, -1 );
4660 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4661 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4662 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4663 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4665 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4666 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4667 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4668 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4670 // ----- create toolbars --------------
4671 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4672 createTool( SMESHOp::OpCreateMesh, meshTb );
4673 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4674 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4675 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4676 createTool( SMESHOp::OpCopyMesh, meshTb );
4677 createTool( separator(), meshTb );
4678 createTool( SMESHOp::OpCompute, meshTb );
4679 createTool( SMESHOp::OpPreCompute, meshTb );
4680 createTool( SMESHOp::OpEvaluate, meshTb );
4681 createTool( SMESHOp::OpMeshOrder, meshTb );
4683 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4684 createTool( SMESHOp::OpMeshInformation, infoTb );
4685 //createTool( SMESHOp::OpStdInfo, meshTb );
4686 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4687 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4689 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4690 createTool( SMESHOp::OpCreateGroup, groupTb );
4691 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4692 createTool( SMESHOp::OpConstructGroup, groupTb );
4693 createTool( SMESHOp::OpEditGroup, groupTb );
4695 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4696 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4697 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4698 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4700 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4701 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4702 createTool( SMESHOp::OpLength, ctrl1dTb );
4703 createTool( SMESHOp::OpConnection, ctrl1dTb );
4704 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4706 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4707 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4708 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4709 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4710 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4711 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4712 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4713 createTool( SMESHOp::OpArea, ctrl2dTb );
4714 createTool( SMESHOp::OpTaper, ctrl2dTb );
4715 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4716 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4717 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4718 createTool( SMESHOp::OpSkew, ctrl2dTb );
4719 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4720 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4721 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4723 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4724 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4725 createTool( SMESHOp::OpWarping3D, ctrl3dTb );
4726 createTool( SMESHOp::OpVolume, ctrl3dTb );
4727 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4728 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4729 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4730 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4731 createTool( SMESHOp::OpScaledJacobian, ctrl3dTb );
4733 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4734 createTool( SMESHOp::OpNode, addElemTb );
4735 createTool( SMESHOp::OpElem0D, addElemTb );
4736 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4737 createTool( SMESHOp::OpBall, addElemTb );
4738 createTool( SMESHOp::OpEdge, addElemTb );
4739 createTool( SMESHOp::OpTriangle, addElemTb );
4740 createTool( SMESHOp::OpQuadrangle, addElemTb );
4741 createTool( SMESHOp::OpPolygon, addElemTb );
4742 createTool( SMESHOp::OpTetrahedron, addElemTb );
4743 createTool( SMESHOp::OpHexahedron, addElemTb );
4744 createTool( SMESHOp::OpPentahedron, addElemTb );
4745 createTool( SMESHOp::OpPyramid, addElemTb );
4746 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4747 createTool( SMESHOp::OpPolyhedron, addElemTb );
4749 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4750 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4751 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4752 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4753 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4754 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4755 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4756 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4757 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4758 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4759 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4760 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4761 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4763 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4764 createTool( SMESHOp::OpRemoveNodes, remTb );
4765 createTool( SMESHOp::OpRemoveElements, remTb );
4766 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4767 createTool( SMESHOp::OpClearMesh, remTb );
4769 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4770 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4771 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4773 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4774 createTool( SMESHOp::OpMergeNodes, transformTb );
4775 createTool( SMESHOp::OpMergeElements, transformTb );
4776 createTool( SMESHOp::OpTranslation, transformTb );
4777 createTool( SMESHOp::OpRotation, transformTb );
4778 createTool( SMESHOp::OpSymmetry, transformTb );
4779 createTool( SMESHOp::OpScale, transformTb );
4780 createTool( SMESHOp::OpOffset, transformTb );
4781 createTool( SMESHOp::OpSewing, transformTb );
4782 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4784 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4785 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4786 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4787 createTool( SMESHOp::OpCreate2DElements, modifyTb );
4788 createTool( SMESHOp::OpExtrusion, modifyTb );
4789 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4790 createTool( SMESHOp::OpRevolution, modifyTb );
4791 createTool( SMESHOp::OpOrientation, modifyTb );
4792 createTool( SMESHOp::OpReorientFaces, modifyTb );
4793 createTool( SMESHOp::OpMoveNode, modifyTb );
4794 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4795 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4796 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4797 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4798 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4799 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4800 createTool( SMESHOp::OpSmoothing, modifyTb );
4801 createTool( SMESHOp::OpPatternMapping, modifyTb );
4803 int interactTb = createTool( tr( "TB_INTERACT" ), QString( "SMESHInteractiveToolbar" ) ) ;
4804 createTool( SMESHOp::OpMoveNodeInteractive, interactTb );
4805 createTool( SMESHOp::OpRemoveNodeWithReconn, interactTb );
4806 createTool( SMESHOp::OpSplitEdgeInteract, interactTb );
4807 createTool( SMESHOp::OpSplitFaceInteract, interactTb );
4809 // Adaptation - begin
4810 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4811 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4813 #ifndef DISABLE_MG_ADAPT
4814 createTool( SMESHOp::OpMGAdapt, adaptTb );
4816 #ifndef DISABLE_HOMARD_ADAPT
4817 createTool( SMESHOp::OpHomardAdapt, adaptTb );
4821 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4822 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4824 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4825 createTool( SMESHOp::OpUpdate, dispModeTb );
4827 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4828 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4832 OB = "'ObjectBrowser'",
4833 View = "'" + SVTK_Viewer::Type() + "'",
4835 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4836 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4837 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4838 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4839 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4840 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4841 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4842 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4843 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4844 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4845 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4846 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4848 mesh_part = mesh + " " + subMesh + " " + group,
4849 mesh_group = mesh + " " + group,
4850 mesh_submesh = mesh + " " + subMesh,
4851 hyp_alg = hypo + " " + algo;
4853 // popup for object browser
4855 isInvisible("not( isVisible )"),
4856 isEmpty("numberOfNodes = 0"),
4857 isNotEmpty("numberOfNodes <> 0"),
4859 // has nodes, edges, etc in VISIBLE! actor
4860 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4861 hasElems("(count( elemTypes ) > 0)"),
4862 hasDifferentElems("(count( elemTypes ) > 1)"),
4863 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4864 hasBalls("({'BallElem'} in elemTypes)"),
4865 hasElems0d("({'Elem0d'} in elemTypes)"),
4866 hasEdges("({'Edge'} in elemTypes)"),
4867 hasFaces("({'Face'} in elemTypes)"),
4868 hasVolumes("({'Volume'} in elemTypes)"),
4869 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4871 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4872 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4873 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4874 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4875 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4876 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4878 popupMgr()->insert( separator(), -1, 0 );
4879 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4880 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4881 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4882 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4883 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4884 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4885 popupMgr()->insert( separator(), -1, 0 );
4886 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4887 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4888 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4889 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4890 popupMgr()->insert( separator(), -1, 0 );
4891 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4892 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4893 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4894 popupMgr()->insert( separator(), -1, 0 );
4895 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4896 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4897 popupMgr()->insert( separator(), -1, 0 );
4898 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4899 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4901 // Adaptation - begin
4902 popupMgr()->insert( separator(), -1, 0 );
4903 #ifndef DISABLE_MG_ADAPT
4904 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4906 #ifndef DISABLE_HOMARD_ADAPT
4907 createPopupItem( SMESHOp::OpHomardAdapt, OB, mesh );
4909 popupMgr()->insert( separator(), -1, 0 );
4912 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4913 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4914 QString only_one_2D = only_one_non_empty + " && dim>1";
4916 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4917 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4918 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4919 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4920 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4922 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4924 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4925 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4926 createPopupItem( SMESHOp::OpExportMESHIO, OB, mesh_group, only_one_non_empty, anId );
4928 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4929 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4930 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4931 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4933 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4935 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4936 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4937 popupMgr()->insert( separator(), -1, 0 );
4939 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4940 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4941 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4944 createPopupItem( SMESHOp::OpEditGroup, View, group );
4945 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4946 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4948 popupMgr()->insert( separator(), -1, 0 );
4949 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4950 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4951 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4952 popupMgr()->insert( separator(), -1, 0 );
4954 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
4955 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4956 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4957 popupMgr()->insert( separator(), -1, 0 );
4959 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4960 QString aType = QString( "%1type in {%2}" ).arg( lc );
4961 aType = aType.arg( mesh_part );
4962 QString aMeshInVTK = aClient + "&&" + aType;
4964 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4965 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4966 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4968 //-------------------------------------------------
4970 //-------------------------------------------------
4971 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4973 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4974 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4975 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4977 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4978 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4979 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4981 popupMgr()->insert( separator(), -1, -1 );
4983 //-------------------------------------------------
4985 //-------------------------------------------------
4986 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4988 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4989 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4990 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4992 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4993 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4994 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4996 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4997 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4998 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
5000 popupMgr()->insert( separator(), anId, -1 );
5002 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
5003 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
5004 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
5006 //-------------------------------------------------
5008 //-------------------------------------------------
5009 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
5011 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
5013 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
5014 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
5015 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
5017 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
5018 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
5019 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
5021 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
5022 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
5023 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
5025 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
5026 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
5027 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
5029 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
5030 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
5031 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
5033 popupMgr()->insert( separator(), anId, -1 );
5035 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
5036 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
5038 popupMgr()->insert( separator(), anId, -1 );
5040 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
5041 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
5044 //-------------------------------------------------
5045 // Representation of the 2D Quadratic elements
5046 //-------------------------------------------------
5047 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
5048 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
5049 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
5050 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
5052 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
5053 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
5054 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
5056 //-------------------------------------------------
5057 // Orientation of faces
5058 //-------------------------------------------------
5059 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
5060 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
5061 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
5063 //-------------------------------------------------
5065 //-------------------------------------------------
5066 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
5067 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
5069 //-------------------------------------------------
5071 //-------------------------------------------------
5072 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
5073 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
5075 //-------------------------------------------------
5077 //-------------------------------------------------
5079 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
5080 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
5081 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
5082 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
5084 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
5086 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
5087 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5089 popupMgr()->insert( separator(), anId, -1 );
5091 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
5093 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
5094 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5095 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
5097 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
5098 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5099 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
5101 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
5102 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5103 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
5105 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
5107 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
5108 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
5109 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
5111 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
5112 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5113 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
5115 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
5116 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5117 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
5118 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
5119 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5120 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
5122 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
5124 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
5125 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5126 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
5128 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
5129 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
5130 QtxPopupMgr::VisibleRule );
5131 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
5133 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
5134 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5135 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
5137 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
5138 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5139 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
5141 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
5142 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5143 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
5145 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
5146 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5147 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
5149 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
5150 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5151 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
5153 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
5154 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5155 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
5157 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
5158 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5159 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
5161 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
5162 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5163 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
5165 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
5166 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5167 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
5169 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
5170 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5171 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
5173 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
5174 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5175 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
5177 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
5178 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5179 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
5181 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
5182 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
5183 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
5185 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
5187 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
5188 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5189 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
5191 popupMgr()->insert ( action( SMESHOp::OpWarping3D ), aSubId, -1 );
5192 popupMgr()->setRule( action( SMESHOp::OpWarping3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5193 popupMgr()->setRule( action( SMESHOp::OpWarping3D), "controlMode = 'eWarping3D'", QtxPopupMgr::ToggleRule );
5195 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
5196 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5197 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
5199 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
5200 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5201 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5203 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5204 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5205 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5207 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5208 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5209 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5211 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5212 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5213 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5215 popupMgr()->insert ( action( SMESHOp::OpScaledJacobian ), aSubId, -1 );
5216 popupMgr()->setRule( action( SMESHOp::OpScaledJacobian ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5217 popupMgr()->setRule( action( SMESHOp::OpScaledJacobian ), "controlMode = 'eScaledJacobian'", QtxPopupMgr::ToggleRule );
5219 popupMgr()->insert( separator(), anId, -1 );
5221 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5222 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5223 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5224 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5225 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5227 popupMgr()->insert( separator(), anId, -1 );
5229 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5231 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5232 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5234 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5235 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5236 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5238 #ifndef DISABLE_PLOT2DVIEWER
5239 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5240 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5243 //-------------------------------------------------
5245 //-------------------------------------------------
5246 popupMgr()->insert( separator(), -1, -1 );
5247 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5248 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5249 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5250 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5252 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5253 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5255 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5256 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5258 popupMgr()->insert( separator(), -1, -1 );
5260 //-------------------------------------------------
5262 //-------------------------------------------------
5263 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5264 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5266 popupMgr()->insert( separator(), -1, -1 );
5268 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5269 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5270 popupMgr()->insert( separator(), -1, -1 );
5272 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5273 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5275 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5276 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5278 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5279 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5282 //================================================================================
5284 * \brief Return true if SMESH or GEOM objects are selected.
5285 * Is called form LightApp_Module::activateModule() which clear selection if
5286 * not isSelectionCompatible()
5288 //================================================================================
5290 bool SMESHGUI::isSelectionCompatible()
5292 bool isCompatible = true;
5293 SALOME_ListIO selected;
5294 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5295 Sel->selectedObjects( selected );
5297 SALOME_ListIteratorOfListIO It( selected );
5298 for ( ; isCompatible && It.More(); It.Next())
5300 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5301 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5302 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5304 return isCompatible;
5308 bool SMESHGUI::reusableOperation( const int id )
5310 // compute, evaluate and precompute are not reusable operations
5311 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5316 QString wrap(const QString& text, const QString& tag)
5317 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5320 bool SMESHGUI::activateModule( SUIT_Study* study )
5322 bool res = SalomeApp_Module::activateModule( study );
5324 setMenuShown( true );
5325 setToolShown( true );
5327 // Fill in Help Panel
5328 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5329 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5331 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5334 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5335 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5336 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5337 lab = lab + tr("INFO_REFINE") + ":";
5338 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5339 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5340 lab = lab + wrap(items.join(""), "ul");
5343 app->infoPanel()->addLabel(lab, gb);
5345 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5346 items << wrap("UNV", "li")
5347 << wrap("MED", "li")
5348 << wrap("STL", "li")
5349 << wrap("CGNS", "li")
5350 << wrap("GMF", "li");
5351 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5354 app->infoPanel()->addLabel(lab, gb);
5356 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5357 lab = tr("INFO_DISPLAY") + "<br/>";
5358 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5359 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5360 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5361 << wrap("...", "li");
5362 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5364 lab = lab + tr("INFO_CLIPPING");
5366 app->infoPanel()->addLabel(lab, gb);
5369 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5370 PyGILState_STATE gstate = PyGILState_Ensure();
5371 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5372 if ( !pluginsmanager ) {
5376 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5381 PyGILState_Release(gstate);
5382 // end of SMESH plugins loading
5384 // Reset actions accelerator keys
5385 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5387 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5388 GetSMESHGen()->UpdateStudy();
5390 // get all view currently opened in the study and connect their signals to
5391 // the corresponding slots of the class.
5392 SUIT_Desktop* aDesk = study->application()->desktop();
5394 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5395 SUIT_ViewWindow* wnd;
5396 foreach ( wnd, wndList )
5400 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5401 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5407 Py_XDECREF(pluginsmanager);
5411 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5413 setMenuShown( false );
5414 setToolShown( false );
5416 EmitSignalCloseAllDialogs();
5418 // Unset actions accelerator keys
5419 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5421 return SalomeApp_Module::deactivateModule( study );
5424 void SMESHGUI::studyClosed( SUIT_Study* s )
5428 SMESH::RemoveVisuData();
5429 SalomeApp_Module::studyClosed( s );
5432 void SMESHGUI::OnGUIEvent()
5434 const QObject* obj = sender();
5435 if ( !obj || !obj->inherits( "QAction" ) )
5437 int id = actionId((QAction*)obj);
5442 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5444 if ( CORBA::is_nil( myComponentSMESH ) )
5446 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5447 return aGUI.myComponentSMESH;
5449 return myComponentSMESH;
5452 QString SMESHGUI::engineIOR() const
5454 CORBA::ORB_var anORB = getApp()->orb();
5455 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5456 return QString( anIOR.in() );
5459 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5461 SalomeApp_Module::contextMenuPopup( client, menu, title );
5463 selectionMgr()->selectedObjects( lst );
5464 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5465 Handle(SALOME_InteractiveObject) io = lst.First();
5466 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5467 _PTR(Study) study = appStudy->studyDS();
5468 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5470 QString aName = SMESH::fromUtf8( obj->GetName());
5471 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5472 aName.remove(( aName.length() - 1 ), 1 );
5478 LightApp_Selection* SMESHGUI::createSelection() const
5480 return new SMESHGUI_Selection();
5483 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5485 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5486 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5487 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5488 #ifndef DISABLE_PYCONSOLE
5489 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5493 void SMESHGUI::viewManagers( QStringList& list ) const
5495 list.append( SVTK_Viewer::Type() );
5498 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5500 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5501 SMESH::UpdateSelectionProp( this );
5503 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5504 for(int i = 0; i < aViews.count() ; i++){
5505 SUIT_ViewWindow *sf = aViews[i];
5508 EmitSignalActivatedViewManager();
5512 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5514 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5515 myClippingPlaneInfoMap.erase( theViewManager );
5518 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5520 theActor->AddObserver( SMESH::DeleteActorEvent,
5521 myEventCallbackCommand.GetPointer(),
5525 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5526 unsigned long theEvent,
5527 void* theClientData,
5528 void* /*theCallData*/ )
5530 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5531 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5532 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5533 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5534 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5535 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5536 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5537 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5538 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5539 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5540 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5541 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5542 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5543 if( anActor == *anIter3 ) {
5544 anActorList.erase( anIter3 );
5555 void SMESHGUI::createPreferences()
5557 // General tab ------------------------------------------------------------------------
5558 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5560 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5561 setPreferenceProperty( autoUpdate, "columns", 2 );
5562 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5563 setPreferenceProperty( lim, "min", 0 );
5564 setPreferenceProperty( lim, "max", 100000000 );
5565 setPreferenceProperty( lim, "step", 1000 );
5566 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5567 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5569 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5570 setPreferenceProperty( dispgroup, "columns", 2 );
5572 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5574 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5576 modes.append( tr("MEN_WIRE") );
5577 modes.append( tr("MEN_SHADE") );
5578 modes.append( tr("MEN_NODES") );
5579 modes.append( tr("MEN_SHRINK") );
5580 QList<QVariant> indices;
5581 indices.append( 0 );
5582 indices.append( 1 );
5583 indices.append( 2 );
5584 indices.append( 3 );
5585 setPreferenceProperty( dispmode, "strings", modes );
5586 setPreferenceProperty( dispmode, "indexes", indices );
5588 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5589 setPreferenceProperty( arcgroup, "columns", 2 );
5590 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5591 QStringList quadraticModes;
5592 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5593 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5595 indices.append( 0 );
5596 indices.append( 1 );
5597 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5598 setPreferenceProperty( quadraticmode, "indexes", indices );
5600 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5601 "SMESH", "max_angle" );
5602 setPreferenceProperty( maxAngle, "min", 1 );
5603 setPreferenceProperty( maxAngle, "max", 90 );
5605 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5606 setPreferenceProperty( qaGroup, "columns", 2 );
5607 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5608 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5609 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5610 setPreferenceProperty( prec, "min", 0 );
5611 setPreferenceProperty( prec, "max", 100 );
5612 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5613 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5614 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5615 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5616 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5619 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5620 setPreferenceProperty( cinc, "min", 0 );
5621 setPreferenceProperty( cinc, "max", 5 );
5624 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5625 setPreferenceProperty( exportgroup, "columns", 2 );
5626 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5627 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5628 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5629 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5630 setPreferenceProperty( zTol, "precision", 10 );
5631 setPreferenceProperty( zTol, "min", 0.0000000001 );
5632 setPreferenceProperty( zTol, "max", 1000000.0 );
5633 setPreferenceProperty( zTol, "step", 1. );
5634 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5636 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5637 setPreferenceProperty( computeGroup, "columns", 2 );
5638 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5640 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5641 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5642 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5644 indices.append( 0 );
5645 indices.append( 1 );
5646 indices.append( 2 );
5647 setPreferenceProperty( notifyMode, "strings", modes );
5648 setPreferenceProperty( notifyMode, "indexes", indices );
5650 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5651 setPreferenceProperty( infoGroup, "columns", 2 );
5652 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5654 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5655 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5657 indices.append( 0 );
5658 indices.append( 1 );
5659 setPreferenceProperty( elemInfo, "strings", modes );
5660 setPreferenceProperty( elemInfo, "indexes", indices );
5661 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5662 setPreferenceProperty( nodesLim, "min", 0 );
5663 setPreferenceProperty( nodesLim, "max", 10000000 );
5664 setPreferenceProperty( nodesLim, "step", 10000 );
5665 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5666 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5667 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5668 setPreferenceProperty( ctrlLim, "min", 0 );
5669 setPreferenceProperty( ctrlLim, "max", 10000000 );
5670 setPreferenceProperty( ctrlLim, "step", 1000 );
5671 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5672 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5673 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5674 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5675 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5677 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5678 setPreferenceProperty( segGroup, "columns", 2 );
5679 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5680 "SMESH", "segmentation" );
5681 setPreferenceProperty( segLen, "min", 1 );
5682 setPreferenceProperty( segLen, "max", 10000000 );
5683 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5684 "SMESH", "nb_segments_per_edge" );
5685 setPreferenceProperty( nbSeg, "min", 1 );
5686 setPreferenceProperty( nbSeg, "max", 10000000 );
5687 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5689 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5690 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5691 "SMESH", "forget_mesh_on_hyp_modif" );
5694 // Quantities with individual precision settings
5695 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5696 setPreferenceProperty( precGroup, "columns", 2 );
5698 const int nbQuantities = 6;
5699 int precs[nbQuantities], ii = 0;
5700 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5701 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5702 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5703 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5704 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5705 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5706 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5707 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5708 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5709 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5710 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5711 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5713 // Set property for precision value for spinboxes
5714 for ( ii = 0; ii < nbQuantities; ii++ ){
5715 setPreferenceProperty( precs[ii], "min", -14 );
5716 setPreferenceProperty( precs[ii], "max", 14 );
5717 setPreferenceProperty( precs[ii], "precision", 2 );
5720 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5721 setPreferenceProperty( previewGroup, "columns", 2 );
5722 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5723 setPreferenceProperty( chunkSize, "min", 1 );
5724 setPreferenceProperty( chunkSize, "max", 1000 );
5725 setPreferenceProperty( chunkSize, "step", 50 );
5727 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5728 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5730 // Mesh tab ------------------------------------------------------------------------
5731 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5732 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5733 setPreferenceProperty( nodeGroup, "columns", 3 );
5735 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5737 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5739 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5740 QList<QVariant> aMarkerTypeIndicesList;
5741 QList<QVariant> aMarkerTypeIconsList;
5742 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5743 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5744 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5745 aMarkerTypeIndicesList << i;
5746 aMarkerTypeIconsList << pixmap;
5748 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5749 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5751 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5753 QList<QVariant> aMarkerScaleIndicesList;
5754 QStringList aMarkerScaleValuesList;
5755 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5756 aMarkerScaleIndicesList << i;
5757 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5758 aMarkerScaleValuesList << QString::number( i );
5760 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5761 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5763 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5764 //setPreferenceProperty( elemGroup, "columns", 2 );
5766 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5767 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5768 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5769 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5770 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5771 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5772 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5773 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5774 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5777 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5778 setPreferenceProperty( grpGroup, "columns", 2 );
5780 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5781 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5783 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5784 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5785 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5786 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5787 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5788 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5789 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5790 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5791 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5792 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5793 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5794 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5795 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5796 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5798 setPreferenceProperty( size0d, "min", 1 );
5799 setPreferenceProperty( size0d, "max", 10 );
5801 // setPreferenceProperty( ballSize, "min", 1 );
5802 // setPreferenceProperty( ballSize, "max", 10 );
5804 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5805 setPreferenceProperty( ballDiameter, "max", 1e9 );
5806 setPreferenceProperty( ballDiameter, "step", 0.1 );
5808 setPreferenceProperty( ballScale, "min", 1e-2 );
5809 setPreferenceProperty( ballScale, "max", 1e7 );
5810 setPreferenceProperty( ballScale, "step", 0.5 );
5812 setPreferenceProperty( elemW, "min", 1 );
5813 setPreferenceProperty( elemW, "max", 5 );
5815 setPreferenceProperty( outW, "min", 1 );
5816 setPreferenceProperty( outW, "max", 5 );
5818 setPreferenceProperty( shrink, "min", 0 );
5819 setPreferenceProperty( shrink, "max", 100 );
5821 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5822 setPreferenceProperty( numGroup, "columns", 2 );
5824 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5825 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5827 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5828 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5830 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5831 setPreferenceProperty( orientGroup, "columns", 1 );
5833 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5834 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5836 setPreferenceProperty( orientScale, "min", 0.05 );
5837 setPreferenceProperty( orientScale, "max", 0.5 );
5838 setPreferenceProperty( orientScale, "step", 0.05 );
5840 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5842 // Selection tab ------------------------------------------------------------------------
5843 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5845 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5846 setPreferenceProperty( selGroup, "columns", 2 );
5848 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5849 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5851 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5852 setPreferenceProperty( preGroup, "columns", 2 );
5854 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5856 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5857 setPreferenceProperty( precSelGroup, "columns", 2 );
5859 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5860 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5861 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5863 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5864 setPreferenceProperty( sinc, "min", 0 );
5865 setPreferenceProperty( sinc, "max", 5 );
5867 // Scalar Bar tab ------------------------------------------------------------------------
5868 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5869 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5870 setPreferenceProperty( fontGr, "columns", 2 );
5872 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5873 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5875 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5876 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5878 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5879 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5881 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5882 setPreferenceProperty( numcol, "min", 2 );
5883 setPreferenceProperty( numcol, "max", 256 );
5885 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5886 setPreferenceProperty( numlab, "min", 2 );
5887 setPreferenceProperty( numlab, "max", 65 );
5889 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5890 setPreferenceProperty( orientGr, "columns", 2 );
5891 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5892 QStringList orients;
5893 orients.append( tr( "SMESH_VERTICAL" ) );
5894 orients.append( tr( "SMESH_HORIZONTAL" ) );
5895 indices.clear(); indices.append( 0 ); indices.append( 1 );
5896 setPreferenceProperty( orient, "strings", orients );
5897 setPreferenceProperty( orient, "indexes", indices );
5899 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5900 setPreferenceProperty( posVSizeGr, "columns", 2 );
5901 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5902 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5903 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5904 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5905 setPreferenceProperty( xv, "step", 0.1 );
5906 setPreferenceProperty( xv, "min", 0.0 );
5907 setPreferenceProperty( xv, "max", 1.0 );
5908 setPreferenceProperty( yv, "step", 0.1 );
5909 setPreferenceProperty( yv, "min", 0.0 );
5910 setPreferenceProperty( yv, "max", 1.0 );
5911 setPreferenceProperty( wv, "step", 0.1 );
5912 setPreferenceProperty( wv, "min", 0.0 );
5913 setPreferenceProperty( wv, "max", 1.0 );
5914 setPreferenceProperty( hv, "min", 0.0 );
5915 setPreferenceProperty( hv, "max", 1.0 );
5916 setPreferenceProperty( hv, "step", 0.1 );
5918 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5919 setPreferenceProperty( posHSizeGr, "columns", 2 );
5920 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5921 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5922 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5923 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5924 setPreferenceProperty( xv, "min", 0.0 );
5925 setPreferenceProperty( xv, "max", 1.0 );
5926 setPreferenceProperty( xv, "step", 0.1 );
5927 setPreferenceProperty( xh, "min", 0.0 );
5928 setPreferenceProperty( xh, "max", 1.0 );
5929 setPreferenceProperty( xh, "step", 0.1 );
5930 setPreferenceProperty( yh, "min", 0.0 );
5931 setPreferenceProperty( yh, "max", 1.0 );
5932 setPreferenceProperty( yh, "step", 0.1 );
5933 setPreferenceProperty( wh, "min", 0.0 );
5934 setPreferenceProperty( wh, "max", 1.0 );
5935 setPreferenceProperty( wh, "step", 0.1 );
5936 setPreferenceProperty( hh, "min", 0.0 );
5937 setPreferenceProperty( hh, "max", 1.0 );
5938 setPreferenceProperty( hh, "step", 0.1 );
5940 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5941 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5942 setPreferenceProperty( distributionGr, "columns", 3 );
5944 types.append( tr( "SMESH_MONOCOLOR" ) );
5945 types.append( tr( "SMESH_MULTICOLOR" ) );
5946 indices.clear(); indices.append( 0 ); indices.append( 1 );
5947 setPreferenceProperty( coloringType, "strings", types );
5948 setPreferenceProperty( coloringType, "indexes", indices );
5949 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5951 // Adaptation - begin
5952 #ifndef DISABLE_MG_ADAPT
5953 // Adaptation tab ------------------------------------------------------------------------
5954 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
5957 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
5958 setPreferenceProperty( bloc, "columns", 1 );
5959 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
5960 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
5961 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
5962 QStringList aListOfSizeMap;
5963 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
5964 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
5965 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
5966 setPreferenceProperty( pref, "strings", aListOfSizeMap );
5967 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
5968 QStringList aListOfTimeStep;
5969 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
5970 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
5971 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
5972 setPreferenceProperty( pref, "strings", aListOfTimeStep );
5977 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5979 if ( sect=="SMESH" ) {
5980 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5981 double aTol = 1.00000009999999;
5982 std::string aWarning;
5983 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5985 if ( name == "selection_object_color" ||
5986 name == "selection_element_color" ||
5987 name == "highlight_color" ||
5988 name == "selection_precision_node" ||
5989 name == "selection_precision_element" ||
5990 name == "selection_precision_object" ||
5991 name == "selection_increment")
5993 SMESH::UpdateSelectionProp( this );
5995 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5997 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5998 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5999 if ( sbX1+sbW > aTol ) {
6000 aWarning = "Origin and Size Vertical: X+Width > 1\n";
6003 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
6004 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
6007 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
6009 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
6010 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
6011 if ( sbY1 + sbH > aTol ) {
6012 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
6013 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
6014 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
6017 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
6019 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
6020 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
6021 if ( sbX1 + sbW > aTol ) {
6022 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
6025 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
6026 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
6029 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
6031 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
6032 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
6033 if ( sbY1 + sbH > aTol ) {
6034 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
6037 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
6038 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
6041 else if ( name == "segmentation" )
6043 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
6044 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
6046 else if ( name == "nb_segments_per_edge" )
6048 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
6049 myComponentSMESH->SetDefaultNbSegments( nbSeg );
6051 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
6053 QString val = aResourceMgr->stringValue( "SMESH", name );
6054 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
6056 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
6058 SMESH::UpdateFontProp( this );
6060 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
6062 SMESH::UpdateFontProp( this );
6065 if ( aWarning.size() != 0 ) {
6066 aWarning += "The default values are applied instead.";
6067 SUIT_MessageBox::warning(SMESHGUI::desktop(),
6068 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
6069 QObject::tr(aWarning.c_str()));
6074 //================================================================================
6076 * \brief Update something in accordance with update flags
6077 * \param theFlags - update flags
6079 * Update viewer or/and object browser etc. in accordance with update flags ( see
6080 * LightApp_UpdateFlags enumeration ).
6082 //================================================================================
6083 void SMESHGUI::update( const int flags )
6085 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
6086 SMESH::UpdateView();
6088 SalomeApp_Module::update( flags );
6091 //================================================================================
6093 * \brief Set default selection mode
6095 * SLOT called when operation committed. Sets default selection mode
6097 //================================================================================
6098 void SMESHGUI::onOperationCommited( SUIT_Operation* )
6100 SVTK_ViewWindow* vtkWnd =
6101 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6103 vtkWnd->SetSelectionMode( ActorSelection );
6106 //================================================================================
6108 * \brief Set default selection mode
6110 * SLOT called when operation aborted. Sets default selection mode
6112 //================================================================================
6113 void SMESHGUI::onOperationAborted( SUIT_Operation* )
6115 SVTK_ViewWindow* vtkWnd =
6116 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6118 vtkWnd->SetSelectionMode( ActorSelection );
6121 //================================================================================
6123 * \brief Creates operation with given identifier
6124 * \param id - identifier of operation to be started
6125 * \return Pointer on created operation or NULL if operation is not created
6127 * Virtual method redefined from the base class creates operation with given id.
6128 * It is called called automatically from startOperation method of base class.
6130 //================================================================================
6131 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
6133 LightApp_Operation* op = 0;
6134 // to do : create operation here
6137 case SMESHOp::OpSplitBiQuadratic:
6138 op = new SMESHGUI_SplitBiQuadOp();
6140 case SMESHOp::OpConvertMeshToQuadratic:
6141 op = new SMESHGUI_ConvToQuadOp();
6143 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
6144 op = new SMESHGUI_Make2DFrom3DOp();
6146 case SMESHOp::OpCreateDualMesh:
6147 op = new SMESHGUI_CreateDualMeshOp();
6149 case SMESHOp::OpCreate2DElements:
6150 op = new SMESHGUI_MakeFull2DFrom3DOp();
6152 case SMESHOp::OpReorientFaces:
6153 op = new SMESHGUI_ReorientFacesOp();
6155 case SMESHOp::OpCreateMesh:
6156 op = new SMESHGUI_MeshOp( true, true );
6158 case SMESHOp::OpCreateSubMesh:
6159 op = new SMESHGUI_MeshOp( true, false );
6161 case SMESHOp::OpEditMeshOrSubMesh:
6162 case SMESHOp::OpEditMesh:
6163 case SMESHOp::OpEditSubMesh:
6164 op = new SMESHGUI_MeshOp( false );
6166 case SMESHOp::OpCompute:
6167 case SMESHOp::OpComputeSubMesh:
6168 op = new SMESHGUI_ComputeOp();
6170 case SMESHOp::OpShowErrors:
6171 op = new SMESHGUI_ShowErrorsOp();
6173 case SMESHOp::OpPreCompute:
6174 op = new SMESHGUI_PrecomputeOp();
6176 case SMESHOp::OpEvaluate:
6177 op = new SMESHGUI_EvaluateOp();
6179 case SMESHOp::OpMeshOrder:
6180 op = new SMESHGUI_MeshOrderOp();
6182 case SMESHOp::OpCreateGeometryGroup:
6183 op = new SMESHGUI_GroupOnShapeOp();
6185 case SMESHOp::OpFindElementByPoint:
6186 op = new SMESHGUI_FindElemByPointOp();
6188 case SMESHOp::OpMoveNode: // Make mesh pass through point
6189 op = new SMESHGUI_MakeNodeAtPointOp();
6191 case SMESHOp::OpMoveNodeInteractive: // Make mesh pass through point / by mouse
6192 op = new SMESHGUI_MakeNodeAtPointOp( 2 );
6194 case SMESHOp::OpRemoveNodeWithReconn:
6195 op = new SMESHGUI_RemoveNodeReconnectionOp();
6197 case SMESHOp::OpSplitEdgeInteract:
6198 op = new SMESHGUI_AddNodeOnSegmentOp();
6200 case SMESHOp::OpSplitFaceInteract:
6201 op = new SMESHGUI_AddNodeOnFaceOp();
6203 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
6204 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
6211 op = SalomeApp_Module::createOperation( id );
6215 //================================================================================
6217 * \brief Stops current operations and starts a given one
6218 * \param id - The id of the operation to start
6220 //================================================================================
6222 void SMESHGUI::switchToOperation(int id)
6224 activeStudy()->abortAllOperations();
6225 startOperation( id );
6228 LightApp_Displayer* SMESHGUI::displayer()
6231 myDisplayer = new SMESHGUI_Displayer( getApp() );
6235 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6238 int aTolerance = 64;
6239 int anIterations = 0;
6245 if( anIterations % aPeriod == 0 )
6248 if( aTolerance < 1 )
6252 aHue = (int)( 360.0 * rand() / RAND_MAX );
6255 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6256 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6257 for( ; it != itEnd; ++it )
6259 SALOMEDS::Color anAutoColor = *it;
6260 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6263 aQColor.getHsv( &h, &s, &v );
6264 if( abs( h - aHue ) < aTolerance )
6276 aColor.setHsv( aHue, 255, 255 );
6278 SALOMEDS::Color aSColor;
6279 aSColor.R = aColor.redF();
6280 aSColor.G = aColor.greenF();
6281 aSColor.B = aColor.blueF();
6286 const char* gSeparator = "_"; // character used to separate parameter names
6287 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6288 const char* gPathSep = "|"; // character used to separate paths
6291 * \brief Store visual parameters
6293 * This method is called just before the study document is saved.
6294 * Store visual parameters in AttributeParameter attribute(s)
6296 void SMESHGUI::storeVisualParameters (int savePoint)
6299 Kernel_Utils::Localizer loc;
6301 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6302 if (!appStudy || !appStudy->studyDS())
6304 _PTR(Study) studyDS = appStudy->studyDS();
6306 // componentName is used for encoding of entries when storing them in IParameters
6307 std::string componentName = myComponentSMESH->ComponentDataType();
6308 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6309 //if (!aSComponent) return;
6312 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6313 componentName.c_str(),
6315 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6317 // store custom markers
6318 if( !myMarkerMap.empty() )
6320 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6321 for( ; anIter != myMarkerMap.end(); anIter++ )
6323 int anId = anIter->first;
6324 VTK::MarkerData aMarkerData = anIter->second;
6325 std::string aMarkerFileName = aMarkerData.first;
6326 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6327 if( aMarkerTexture.size() < 3 )
6328 continue; // should contain at least width, height and the first value
6330 QString aPropertyName( "texture" );
6331 aPropertyName += gSeparator;
6332 aPropertyName += QString::number( anId );
6334 QString aPropertyValue = aMarkerFileName.c_str();
6335 aPropertyValue += gPathSep;
6337 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6338 ushort aWidth = *aTextureIter++;
6339 ushort aHeight = *aTextureIter++;
6340 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6341 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6342 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6343 aPropertyValue += QString::number( *aTextureIter );
6345 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6349 // viewers counters are used for storing view_numbers in IParameters
6352 // main cycle to store parameters of displayed objects
6353 QList<SUIT_ViewManager*> lst;
6354 QList<SUIT_ViewManager*>::Iterator it;
6355 getApp()->viewManagers(lst);
6356 for (it = lst.begin(); it != lst.end(); it++)
6358 SUIT_ViewManager* vman = *it;
6359 QString vType = vman->getType();
6361 // saving VTK actors properties
6362 if (vType == SVTK_Viewer::Type())
6364 // store the clipping planes attached to the view manager
6365 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6366 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6367 if( anIter != myClippingPlaneInfoMap.end() )
6368 aClippingPlaneInfoList = anIter->second;
6370 if( !aClippingPlaneInfoList.empty() ) {
6371 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6372 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6374 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6375 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6377 QString aPropertyName( "ClippingPlane" );
6378 aPropertyName += gSeparator;
6379 aPropertyName += QString::number( vtkViewers );
6380 aPropertyName += gSeparator;
6381 aPropertyName += QString::number( anId );
6383 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6384 aPropertyValue += gDigitsSep;
6385 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6386 aPropertyValue += gDigitsSep;
6387 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6388 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6389 aPropertyValue += gDigitsSep;
6390 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6391 aPropertyValue += gDigitsSep;
6392 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6393 aPropertyValue += gDigitsSep;
6394 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6395 aPropertyValue += gDigitsSep;
6396 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6397 aPropertyValue += gDigitsSep;
6398 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6399 aPropertyValue += gDigitsSep;
6400 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6402 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6403 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6404 aPropertyValue += gDigitsSep;
6405 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6406 aPropertyValue += gDigitsSep;
6407 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6408 aPropertyValue += gDigitsSep;
6409 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6412 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6416 QVector<SUIT_ViewWindow*> views = vman->getViews();
6417 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6419 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6421 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6422 vtkActorCollection* allActors = aCopy.GetActors();
6423 allActors->InitTraversal();
6424 while (vtkActor* actor = allActors->GetNextActor())
6426 if (actor->GetVisibility()) // store only visible actors
6428 SMESH_Actor* aSmeshActor = 0;
6429 if (actor->IsA("SMESH_Actor"))
6430 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6431 if (aSmeshActor && aSmeshActor->hasIO())
6433 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6436 // entry is "encoded" = it does NOT contain component address,
6437 // since it is a subject to change on next component loading
6438 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6440 std::string param, vtkParam = vType.toLatin1().data();
6441 vtkParam += gSeparator;
6442 vtkParam += QString::number(vtkViewers).toLatin1().data();
6443 vtkParam += gSeparator;
6446 param = vtkParam + "Visibility";
6447 ip->setParameter(entry, param, "On");
6450 param = vtkParam + "Representation";
6451 ip->setParameter(entry, param, QString::number
6452 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6455 param = vtkParam + "IsShrunk";
6456 ip->setParameter(entry, param, QString::number
6457 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6459 // Displayed entities
6460 unsigned int aMode = aSmeshActor->GetEntityMode();
6461 bool isE = aMode & SMESH_Actor::eEdges;
6462 bool isF = aMode & SMESH_Actor::eFaces;
6463 bool isV = aMode & SMESH_Actor::eVolumes;
6464 bool is0d = aMode & SMESH_Actor::e0DElements;
6465 bool isB = aMode & SMESH_Actor::eBallElem;
6467 QString modeStr ("e");
6468 modeStr += gDigitsSep; modeStr += QString::number(isE);
6469 modeStr += gDigitsSep; modeStr += "f";
6470 modeStr += gDigitsSep; modeStr += QString::number(isF);
6471 modeStr += gDigitsSep; modeStr += "v";
6472 modeStr += gDigitsSep; modeStr += QString::number(isV);
6473 modeStr += gDigitsSep; modeStr += "0d";
6474 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6475 modeStr += gDigitsSep; modeStr += "b";
6476 modeStr += gDigitsSep; modeStr += QString::number(isB);
6478 param = vtkParam + "Entities";
6479 ip->setParameter(entry, param, modeStr.toLatin1().data());
6485 aSmeshActor->GetSufaceColor(r, g, b, delta);
6486 QStringList colorStr;
6487 colorStr << "surface";
6488 colorStr << QString::number(r);
6489 colorStr << QString::number(g);
6490 colorStr << QString::number(b);
6492 colorStr << "backsurface";
6493 colorStr << QString::number(delta);
6495 aSmeshActor->GetVolumeColor(r, g, b, delta);
6496 colorStr << "volume";
6497 colorStr << QString::number(r);
6498 colorStr << QString::number(g);
6499 colorStr << QString::number(b);
6500 colorStr << QString::number(delta);
6502 aSmeshActor->GetEdgeColor(r, g, b);
6504 colorStr << QString::number(r);
6505 colorStr << QString::number(g);
6506 colorStr << QString::number(b);
6508 aSmeshActor->GetNodeColor(r, g, b);
6510 colorStr << QString::number(r);
6511 colorStr << QString::number(g);
6512 colorStr << QString::number(b);
6514 aSmeshActor->GetOutlineColor(r, g, b);
6515 colorStr << "outline";
6516 colorStr << QString::number(r);
6517 colorStr << QString::number(g);
6518 colorStr << QString::number(b);
6520 aSmeshActor->Get0DColor(r, g, b);
6521 colorStr << "elem0d";
6522 colorStr << QString::number(r);
6523 colorStr << QString::number(g);
6524 colorStr << QString::number(b);
6526 aSmeshActor->GetBallColor(r, g, b);
6528 colorStr << QString::number(r);
6529 colorStr << QString::number(g);
6530 colorStr << QString::number(b);
6532 aSmeshActor->GetFacesOrientationColor(r, g, b);
6533 colorStr << "orientation";
6534 colorStr << QString::number(r);
6535 colorStr << QString::number(g);
6536 colorStr << QString::number(b);
6538 param = vtkParam + "Colors";
6539 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6542 QStringList sizeStr;
6544 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6545 sizeStr << "outline";
6546 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6547 sizeStr << "elem0d";
6548 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6550 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6551 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6552 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6553 sizeStr << "shrink";
6554 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6555 sizeStr << "orientation";
6556 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6557 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6559 param = vtkParam + "Sizes";
6560 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6565 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6566 if( aMarkerType == VTK::MT_USER ) {
6567 markerStr += "custom";
6568 markerStr += gDigitsSep;
6569 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6573 markerStr += gDigitsSep;
6574 markerStr += QString::number( (int)aMarkerType );
6575 markerStr += gDigitsSep;
6576 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6579 param = vtkParam + "PointMarker";
6580 ip->setParameter(entry, param, markerStr.toLatin1().data());
6583 param = vtkParam + "Opacity";
6584 ip->setParameter(entry, param,
6585 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6588 param = vtkParam + "ClippingPlane";
6590 if( !aClippingPlaneInfoList.empty() ) {
6591 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6592 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6594 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6595 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6596 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6597 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6598 if( aSmeshActor == *anIter2 ) {
6599 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6600 QString::number( anId ).toLatin1().constData() );
6607 ip->setParameter( entry, param, "Off" );
6608 } // if (io->hasEntry())
6609 } // SMESH_Actor && hasIO
6611 } // while.. actors traversal
6615 } // if (SVTK view model)
6616 } // for (viewManagers)
6619 // data structures for clipping planes processing
6623 bool isOpenGLClipping;
6624 vtkIdType RelativeOrientation;
6627 int AbsoluteOrientation;
6628 double X, Y, Z, Dx, Dy, Dz;
6630 typedef std::list<TPlaneData> TPlaneDataList;
6631 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6633 typedef std::list<vtkActor*> TActorList;
6636 TActorList ActorList;
6637 SUIT_ViewManager* ViewManager;
6639 typedef std::list<TPlaneInfo> TPlaneInfoList;
6640 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6643 * \brief Restore visual parameters
6645 * This method is called after the study document is opened.
6646 * Restore visual parameters from AttributeParameter attribute(s)
6648 void SMESHGUI::restoreVisualParameters (int savePoint)
6651 Kernel_Utils::Localizer loc;
6653 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6654 if (!appStudy || !appStudy->studyDS())
6656 _PTR(Study) studyDS = appStudy->studyDS();
6658 // componentName is used for encoding of entries when storing them in IParameters
6659 std::string componentName = myComponentSMESH->ComponentDataType();
6662 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6663 componentName.c_str(),
6665 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6667 // restore custom markers and map of clipping planes
6668 TPlaneDataMap aPlaneDataMap;
6670 std::vector<std::string> properties = ip->getProperties();
6671 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6673 std::string property = *propIt;
6674 QString aPropertyName( property.c_str() );
6675 QString aPropertyValue( ip->getProperty( property ).c_str() );
6677 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6678 if( aPropertyNameList.isEmpty() )
6681 QString aPropertyType = aPropertyNameList[0];
6682 if( aPropertyType == "texture" )
6684 if( aPropertyNameList.size() != 2 )
6688 int anId = aPropertyNameList[1].toInt( &ok );
6689 if( !ok || anId < 1 )
6692 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6693 if( aPropertyValueList.size() != 2 )
6696 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6697 QString aMarkerTextureString = aPropertyValueList[1];
6698 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6699 if( aMarkerTextureStringList.size() != 3 )
6703 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6708 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6712 VTK::MarkerTexture aMarkerTexture;
6713 aMarkerTexture.push_back( aWidth );
6714 aMarkerTexture.push_back( aHeight );
6716 QString aMarkerTextureData = aMarkerTextureStringList[2];
6717 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6719 QChar aChar = aMarkerTextureData.at( i );
6720 if( aChar.isDigit() )
6721 aMarkerTexture.push_back( aChar.digitValue() );
6724 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6726 else if( aPropertyType == "ClippingPlane" )
6728 if( aPropertyNameList.size() != 3 )
6732 int aViewId = aPropertyNameList[1].toInt( &ok );
6733 if( !ok || aViewId < 0 )
6737 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6738 if( !ok || aClippingPlaneId < 0 )
6741 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6742 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6745 TPlaneData aPlaneData;
6746 aPlaneData.AbsoluteOrientation = false;
6747 aPlaneData.RelativeOrientation = 0;
6748 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6749 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6750 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6752 aPlaneData.Id = aClippingPlaneId;
6755 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6760 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6764 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6767 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6772 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6777 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6782 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6787 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6792 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6797 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6801 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6803 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6808 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6813 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6818 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6823 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6824 aPlaneDataList.push_back( aPlaneData );
6828 TPlaneInfoMap aPlaneInfoMap;
6830 std::vector<std::string> entries = ip->getEntries();
6832 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6834 // entry is a normal entry - it should be "decoded" (setting base address of component)
6835 QString entry (ip->decodeEntry(*entIt).c_str());
6837 // Check that the entry corresponds to a real object in the Study
6838 // as the object may be deleted or modified after the visual state is saved.
6839 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6840 if (!so) continue; //Skip the not existent entry
6842 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6843 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6845 std::vector<std::string>::iterator namesIt = paramNames.begin();
6846 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6848 // actors are stored in a map after displaying of them for
6849 // quicker access in the future: map < viewID to actor >
6850 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6852 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6854 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6855 // '_' is used as separator and should not be used in viewer type or parameter names.
6856 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6857 if (lst.size() != 3)
6860 QString viewerTypStr = lst[0];
6861 QString viewIndexStr = lst[1];
6862 QString paramNameStr = lst[2];
6865 int viewIndex = viewIndexStr.toUInt(&ok);
6866 if (!ok) // bad conversion of view index to integer
6870 if (viewerTypStr == SVTK_Viewer::Type())
6872 SMESH_Actor* aSmeshActor = 0;
6873 if (vtkActors.IsBound(viewIndex))
6874 aSmeshActor = vtkActors.Find(viewIndex);
6876 QList<SUIT_ViewManager*> lst;
6877 getApp()->viewManagers(viewerTypStr, lst);
6879 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6880 SUIT_ViewManager* vman = NULL;
6881 if (viewIndex >= 0 && viewIndex < lst.count())
6882 vman = lst.at(viewIndex);
6884 if (paramNameStr == "Visibility")
6886 if (!aSmeshActor && displayer() && vman)
6888 SUIT_ViewModel* vmodel = vman->getViewModel();
6889 // SVTK view model can be casted to SALOME_View
6890 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6892 // store displayed actor in a temporary map for quicker
6893 // access later when restoring other parameters
6894 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6895 vtkRenderer* Renderer = vtkView->getRenderer();
6896 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6897 vtkActorCollection* theActors = aCopy.GetActors();
6898 theActors->InitTraversal();
6899 bool isFound = false;
6900 vtkActor *ac = theActors->GetNextActor();
6901 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6902 if (ac->IsA("SMESH_Actor")) {
6903 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6904 if (aGeomAc->hasIO()) {
6905 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6906 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6908 vtkActors.Bind(viewIndex, aGeomAc);
6914 } // if (paramNameStr == "Visibility")
6917 // the rest properties "work" with SMESH_Actor
6920 QString val ((*valuesIt).c_str());
6923 if (paramNameStr == "Representation") {
6924 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6927 else if (paramNameStr == "IsShrunk") {
6929 if (!aSmeshActor->IsShrunk())
6930 aSmeshActor->SetShrink();
6933 if (aSmeshActor->IsShrunk())
6934 aSmeshActor->UnShrink();
6937 // Displayed entities
6938 else if (paramNameStr == "Entities") {
6939 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6940 int aEntityMode = SMESH_Actor::eAllEntity;
6941 for ( int i = 0; i < mode.count(); i+=2 ) {
6942 if ( i < mode.count()-1 ) {
6943 QString type = mode[i];
6944 bool val = mode[i+1].toInt();
6945 if ( type == "e" && !val )
6946 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6947 else if ( type == "f" && !val )
6948 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6949 else if ( type == "v" && !val )
6950 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6951 else if ( type == "0d" && !val )
6952 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6953 else if ( type == "b" && !val )
6954 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6957 aSmeshActor->SetEntityMode( aEntityMode );
6960 else if (paramNameStr == "Colors") {
6961 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6968 QColor outlineColor;
6969 QColor orientationColor;
6975 // below lines are required to get default values for delta coefficients
6976 // of backface color for faces and color of reversed volumes
6977 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6978 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6979 for ( int i = 0; i < colors.count(); i++ ) {
6980 QString type = colors[i];
6981 if ( type == "surface" ) {
6982 // face 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 faceColor.setRgbF( r, g, b );
6993 else if ( type == "backsurface" ) {
6994 // backface color can be defined in several ways
6995 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6996 // - in latest versions, it is set as delta coefficient
6997 bool rgbOk = false, deltaOk;
6998 if ( i+1 >= colors.count() ) break; // format error
6999 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7000 int delta = colors[i+1].toInt( &deltaOk );
7002 if ( i+1 < colors.count() ) // index is shifted to 1
7003 g = colors[i+1].toDouble( &rgbOk );
7004 if ( rgbOk ) i++; // shift index
7005 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
7006 b = colors[i+1].toDouble( &rgbOk );
7008 // - as currently there's no way to set directly backsurface color as it was before,
7009 // we ignore old dump where r,g,b triple was set
7010 // - also we check that delta parameter is set properly
7011 if ( !rgbOk && deltaOk )
7014 else if ( type == "volume" ) {
7015 // volume color is set by 4 values r:g:b:delta, where
7016 // - r,g,b - is a normal volume rgb color components
7017 // - delta - is a reversed volume color delta coefficient
7018 if ( i+1 >= colors.count() ) break; // format error
7019 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7020 if ( i+2 >= colors.count() ) break; // format error
7021 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7022 if ( i+3 >= colors.count() ) break; // format error
7023 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7024 if ( i+4 >= colors.count() ) break; // format error
7025 int delta = colors[i+4].toInt( &bOk );
7026 if ( !bOk ) break; // format error
7027 volumeColor.setRgbF( r, g, b );
7031 else if ( type == "edge" ) {
7032 // edge color is set by 3 values r:g:b, where
7033 // - r,g,b - is rgb color components
7034 if ( i+1 >= colors.count() ) break; // format error
7035 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7036 if ( i+2 >= colors.count() ) break; // format error
7037 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7038 if ( i+3 >= colors.count() ) break; // format error
7039 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7040 edgeColor.setRgbF( r, g, b );
7043 else if ( type == "node" ) {
7044 // node color is set by 3 values r:g:b, where
7045 // - r,g,b - is rgb color components
7046 if ( i+1 >= colors.count() ) break; // format error
7047 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7048 if ( i+2 >= colors.count() ) break; // format error
7049 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7050 if ( i+3 >= colors.count() ) break; // format error
7051 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7052 nodeColor.setRgbF( r, g, b );
7055 else if ( type == "elem0d" ) {
7056 // 0d element color is set by 3 values r:g:b, where
7057 // - r,g,b - is rgb color components
7058 if ( i+1 >= colors.count() ) break; // format error
7059 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7060 if ( i+2 >= colors.count() ) break; // format error
7061 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7062 if ( i+3 >= colors.count() ) break; // format error
7063 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7064 elem0dColor.setRgbF( r, g, b );
7067 else if ( type == "ball" ) {
7068 // ball color is set by 3 values r:g:b, where
7069 // - r,g,b - is rgb color components
7070 if ( i+1 >= colors.count() ) break; // format error
7071 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7072 if ( i+2 >= colors.count() ) break; // format error
7073 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7074 if ( i+3 >= colors.count() ) break; // format error
7075 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7076 ballColor.setRgbF( r, g, b );
7079 else if ( type == "outline" ) {
7080 // outline color is set by 3 values r:g:b, where
7081 // - r,g,b - is rgb color components
7082 if ( i+1 >= colors.count() ) break; // format error
7083 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7084 if ( i+2 >= colors.count() ) break; // format error
7085 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7086 if ( i+3 >= colors.count() ) break; // format error
7087 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7088 outlineColor.setRgbF( r, g, b );
7091 else if ( type == "orientation" ) {
7092 // orientation color is set by 3 values r:g:b, where
7093 // - r,g,b - is rgb color components
7094 if ( i+1 >= colors.count() ) break; // format error
7095 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7096 if ( i+2 >= colors.count() ) break; // format error
7097 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7098 if ( i+3 >= colors.count() ) break; // format error
7099 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7100 orientationColor.setRgbF( r, g, b );
7105 if ( nodeColor.isValid() )
7106 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
7108 if ( edgeColor.isValid() )
7109 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
7111 if ( faceColor.isValid() )
7112 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7114 if ( volumeColor.isValid() )
7115 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
7116 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
7117 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7119 if ( elem0dColor.isValid() )
7120 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
7122 if ( ballColor.isValid() )
7123 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
7125 if ( outlineColor.isValid() )
7126 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
7127 // orientation color
7128 if ( orientationColor.isValid() )
7129 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
7132 else if (paramNameStr == "Sizes") {
7133 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
7136 int outlineWidth = -1;
7137 int elem0dSize = -1;
7138 //int ballSize = -1;
7139 double ballDiameter = -1.0;
7140 double ballScale = -1.0;
7141 double shrinkSize = -1;
7142 double orientationSize = -1;
7143 bool orientation3d = false;
7144 for ( int i = 0; i < sizes.count(); i++ ) {
7145 QString type = sizes[i];
7146 if ( type == "line" ) {
7147 // line (wireframe) width is given as single integer value
7148 if ( i+1 >= sizes.count() ) break; // format error
7149 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7153 if ( type == "outline" ) {
7154 // outline width is given as single integer value
7155 if ( i+1 >= sizes.count() ) break; // format error
7156 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7160 else if ( type == "elem0d" ) {
7161 // 0d element size is given as single integer value
7162 if ( i+1 >= sizes.count() ) break; // format error
7163 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7167 else if ( type == "ball" ) {
7168 // balls are specified by two values: size:scale, where
7169 // - size - is a integer value specifying size
7170 // - scale - is a double value specifying scale factor
7171 if ( i+1 >= sizes.count() ) break; // format error
7172 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7173 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7174 if ( i+2 >= sizes.count() ) break; // format error
7175 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7181 else if ( type == "shrink" ) {
7182 // shrink factor is given as single floating point value
7183 if ( i+1 >= sizes.count() ) break; // format error
7184 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7188 else if ( type == "orientation" ) {
7189 // orientation vectors are specified by two values size:3d, where
7190 // - size - is a floating point value specifying scale factor
7191 // - 3d - is a boolean
7192 if ( i+1 >= sizes.count() ) break; // format error
7193 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7194 if ( i+2 >= sizes.count() ) break; // format error
7195 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
7196 orientationSize = v1;
7197 orientation3d = (bool)v2;
7201 // line (wireframe) width
7202 if ( lineWidth > 0 )
7203 aSmeshActor->SetLineWidth( lineWidth );
7205 if ( outlineWidth > 0 )
7206 aSmeshActor->SetOutlineWidth( outlineWidth );
7207 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
7208 aSmeshActor->SetOutlineWidth( lineWidth );
7210 if ( elem0dSize > 0 )
7211 aSmeshActor->Set0DSize( elem0dSize );
7213 /*if ( ballSize > 0 )
7214 aSmeshActor->SetBallSize( ballSize );*/
7216 if ( ballDiameter > 0 )
7217 aSmeshActor->SetBallSize( ballDiameter );
7219 if ( ballScale > 0.0 )
7220 aSmeshActor->SetBallScale( ballScale );
7222 if ( shrinkSize > 0 )
7223 aSmeshActor->SetShrinkFactor( shrinkSize );
7224 // orientation vectors
7225 if ( orientationSize > 0 ) {
7226 aSmeshActor->SetFacesOrientationScale( orientationSize );
7227 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7231 else if (paramNameStr == "PointMarker") {
7232 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7233 if( data.count() >= 2 ) {
7235 int aParam1 = data[1].toInt( &ok );
7237 if( data[0] == "std" && data.count() == 3 ) {
7238 int aParam2 = data[2].toInt( &ok );
7239 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7241 else if( data[0] == "custom" ) {
7242 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7243 if( markerIt != myMarkerMap.end() ) {
7244 VTK::MarkerData aMarkerData = markerIt->second;
7245 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7252 else if (paramNameStr == "Opacity") {
7253 aSmeshActor->SetOpacity(val.toFloat());
7256 else if (paramNameStr.startsWith("ClippingPlane")) {
7257 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7258 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7259 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7260 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7261 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7262 // new format - val looks like "Off" or "0" (plane id)
7263 // (note: in new format "Off" value is used only for consistency,
7264 // so it is processed together with values in old format)
7265 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7266 if( anIsOldFormat ) {
7267 if (paramNameStr == "ClippingPlane1" || val == "Off")
7268 aSmeshActor->RemoveAllClippingPlanes();
7270 QList<SUIT_ViewManager*> lst;
7271 getApp()->viewManagers(viewerTypStr, lst);
7272 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7273 if (viewIndex >= 0 && viewIndex < lst.count()) {
7274 SUIT_ViewManager* vman = lst.at(viewIndex);
7275 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7277 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7279 SMESH::TActorList anActorList;
7280 anActorList.push_back( aSmeshActor );
7281 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7282 aPlane->myViewWindow = vtkView;
7283 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7284 aPlane->PlaneMode = aMode;
7285 bool isOpenGLClipping = ( bool )vals[1].toInt();
7286 aPlane->IsOpenGLClipping = isOpenGLClipping;
7287 if ( aMode == SMESH::Absolute ) {
7288 aPlane->myAbsoluteOrientation = vals[2].toInt();
7289 aPlane->X = vals[3].toFloat();
7290 aPlane->Y = vals[4].toFloat();
7291 aPlane->Z = vals[5].toFloat();
7292 aPlane->Dx = vals[6].toFloat();
7293 aPlane->Dy = vals[7].toFloat();
7294 aPlane->Dz = vals[8].toFloat();
7296 else if ( aMode == SMESH::Relative ) {
7297 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7298 aPlane->myDistance = vals[3].toFloat();
7299 aPlane->myAngle[0] = vals[4].toFloat();
7300 aPlane->myAngle[1] = vals[5].toFloat();
7304 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7305 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7306 aClippingPlaneInfo.Plane = aPlane;
7307 aClippingPlaneInfo.ActorList = anActorList;
7308 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7316 int aPlaneId = val.toInt( &ok );
7317 if( ok && aPlaneId >= 0 ) {
7318 bool anIsDefinedPlane = false;
7319 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7320 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7321 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7322 TPlaneInfo& aPlaneInfo = *anIter;
7323 if( aPlaneInfo.PlaneId == aPlaneId ) {
7324 aPlaneInfo.ActorList.push_back( aSmeshActor );
7325 anIsDefinedPlane = true;
7329 if( !anIsDefinedPlane ) {
7330 TPlaneInfo aPlaneInfo;
7331 aPlaneInfo.PlaneId = aPlaneId;
7332 aPlaneInfo.ActorList.push_back( aSmeshActor );
7333 aPlaneInfo.ViewManager = vman;
7335 // to make the list sorted by plane id
7336 anIter = aPlaneInfoList.begin();
7337 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7338 const TPlaneInfo& aPlaneInfoRef = *anIter;
7339 if( aPlaneInfoRef.PlaneId > aPlaneId )
7342 aPlaneInfoList.insert( anIter, aPlaneInfo );
7347 } // if (aSmeshActor)
7348 } // other parameters than Visibility
7350 } // for names/parameters iterator
7351 } // for entries iterator
7353 // take into account planes with empty list of actors referred to them
7354 QList<SUIT_ViewManager*> aVMList;
7355 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7357 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7358 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7359 int aViewId = aPlaneDataIter->first;
7360 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7361 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7363 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7365 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7366 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7367 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7368 const TPlaneData& aPlaneData = *anIter2;
7369 int aPlaneId = aPlaneData.Id;
7371 bool anIsFound = false;
7372 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7373 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7374 const TPlaneInfo& aPlaneInfo = *anIter3;
7375 if( aPlaneInfo.PlaneId == aPlaneId ) {
7382 TPlaneInfo aPlaneInfo; // ActorList field is empty
7383 aPlaneInfo.PlaneId = aPlaneId;
7384 aPlaneInfo.ViewManager = aViewManager;
7386 // to make the list sorted by plane id
7387 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7388 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7389 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7390 if( aPlaneInfoRef.PlaneId > aPlaneId )
7393 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7399 // add clipping planes to actors according to the restored parameters
7400 // and update the clipping plane map
7401 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7402 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7403 int aViewId = anIter1->first;
7404 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7406 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7407 if( anIter2 == aPlaneDataMap.end() )
7409 const TPlaneDataList& aPlaneDataList = anIter2->second;
7411 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7412 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7413 const TPlaneInfo& aPlaneInfo = *anIter3;
7414 int aPlaneId = aPlaneInfo.PlaneId;
7415 const TActorList& anActorList = aPlaneInfo.ActorList;
7416 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7420 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7424 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7426 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7427 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7428 const TPlaneData& aPlaneData = *anIter4;
7429 if( aPlaneData.Id == aPlaneId ) {
7430 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7431 aPlane->myViewWindow = aViewWindow;
7432 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7433 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7434 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7435 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7436 aPlane->X = aPlaneData.X;
7437 aPlane->Y = aPlaneData.Y;
7438 aPlane->Z = aPlaneData.Z;
7439 aPlane->Dx = aPlaneData.Dx;
7440 aPlane->Dy = aPlaneData.Dy;
7441 aPlane->Dz = aPlaneData.Dz;
7443 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7444 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7445 aPlane->myDistance = aPlaneData.Distance;
7446 aPlane->myAngle[0] = aPlaneData.Angle[0];
7447 aPlane->myAngle[1] = aPlaneData.Angle[1];
7450 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7451 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7452 aClippingPlaneInfo.Plane = aPlane;
7453 aClippingPlaneInfo.ActorList = anActorList;
7454 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7465 // update all VTK views
7466 QList<SUIT_ViewManager*> lst;
7467 getApp()->viewManagers(lst);
7468 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7469 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7470 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7471 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7472 // set OpenGL clipping planes
7473 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7474 vtkActorCollection* anAllActors = aCopy.GetActors();
7475 anAllActors->InitTraversal();
7476 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7477 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7478 anActor->SetOpenGLClippingPlane();
7480 vtkView->getRenderer()->ResetCameraClippingRange();
7487 \brief Adds preferences for dfont of VTK viewer
7489 \param pIf group identifier
7490 \param param parameter
7491 \return identifier of preferences
7493 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7495 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7497 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7500 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7501 fam.append( tr( "SMESH_FONT_COURIER" ) );
7502 fam.append( tr( "SMESH_FONT_TIMES" ) );
7504 setPreferenceProperty( tfont, "fonts", fam );
7506 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7507 if ( needSize ) f = f | QtxFontEdit::Size;
7508 setPreferenceProperty( tfont, "features", f );
7514 \brief Actions after hypothesis edition
7515 Updates object browser after hypothesis edition
7517 void SMESHGUI::onHypothesisEdit( int result )
7520 SMESHGUI::Modified();
7521 updateObjBrowser( true );
7525 \brief Actions after choosing menu of control modes
7526 Updates control mode actions according to current selection
7528 void SMESHGUI::onUpdateControlActions()
7530 SALOME_ListIO selected;
7531 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7532 aSel->selectedObjects( selected );
7534 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7535 if ( selected.Extent() ) {
7536 if ( selected.First()->hasEntry() ) {
7537 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7538 aControl = anActor->GetControlMode();
7539 SALOME_ListIteratorOfListIO it(selected);
7540 for ( it.Next(); it.More(); it.Next() ) {
7541 Handle(SALOME_InteractiveObject) anIO = it.Value();
7542 if ( anIO->hasEntry() ) {
7543 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7544 if ( aControl != anActor->GetControlMode() ) {
7545 aControl = SMESH_Actor::eNone;
7555 int anAction = ActionToControl( aControl, true );
7557 action( anAction )->setChecked( true );
7559 QMenu* send = (QMenu*)sender();
7560 QList<QAction*> actions = send->actions();
7561 for ( int i = 0; i < actions.size(); i++ )
7562 actions[i]->setChecked( false );
7568 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7569 \param pview view being closed
7571 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7572 #ifndef DISABLE_PLOT2DVIEWER
7573 //Crear all Plot2d Viewers if need.
7574 SMESH::ClearPlot2Viewers(pview);
7576 EmitSignalCloseView();
7579 void SMESHGUI::message( const QString& msg )
7582 QStringList data = msg.split("/");
7583 if ( data.count() > 0 ) {
7584 if ( data.first() == "mesh_loading" ) {
7586 QString entry = data.count() > 1 ? data[1] : QString();
7587 if ( entry.isEmpty() )
7590 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7592 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7595 name = SMESH::fromUtf8(obj->GetName());
7596 if ( name.isEmpty() )
7599 if ( data.last() == "stop" )
7600 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7602 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7603 QApplication::processEvents();
7609 \brief Connects or disconnects signals about activating and cloning view on the module slots
7610 \param pview view which is connected/disconnected
7612 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7616 SUIT_ViewManager* viewMgr = pview->getViewManager();
7618 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7619 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7621 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7622 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7627 \brief Return \c true if object can be renamed
7629 bool SMESHGUI::renameAllowed( const QString& entry) const {
7630 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7634 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7638 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7643 if(appStudy->isComponent(entry) || obj->isReference())
7646 // check type to prevent renaming of inappropriate objects
7647 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7648 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7649 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7650 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7651 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7652 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7659 Rename object by entry.
7660 \param entry entry of the object
7661 \param name new name of the object
7662 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7664 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7666 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7670 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7675 _PTR(Study) aStudy = appStudy->studyDS();
7680 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7682 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7687 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7688 _PTR(GenericAttribute) anAttr;
7689 _PTR(AttributeName) aName;
7691 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7693 // check type to prevent renaming of inappropriate objects
7694 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7695 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7696 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7697 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7698 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7699 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7700 if ( !name.isEmpty() ) {
7701 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7703 // update name of group object and its actor
7704 Handle(SALOME_InteractiveObject) IObject =
7705 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7707 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7708 if( !aGroupObject->_is_nil() ) {
7709 aGroupObject->SetName( qUtf8Printable(name) );
7710 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7711 anActor->setName( qUtf8Printable(name) );
7721 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7723 static QList<QColor> colors;
7725 if ( colors.isEmpty() ) {
7727 for (int s = 0; s < 2 ; s++)
7729 for (int v = 100; v >= 40; v = v - 20)
7731 for (int h = 0; h < 359 ; h = h + 60)
7733 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7738 static int currentColor = randomize( colors.size() );
7740 SALOMEDS::Color color;
7741 color.R = (double)colors[currentColor].red() / 255.0;
7742 color.G = (double)colors[currentColor].green() / 255.0;
7743 color.B = (double)colors[currentColor].blue() / 255.0;
7745 currentColor = (currentColor+1) % colors.count();