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 bool structureCGNS = false;
681 double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. );
683 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
684 QString anInitialPath = "";
685 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
686 anInitialPath = QDir::currentPath();
688 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
690 // Get a file name to write in and additional options
691 if ( isGMF ) // Export w/o options
693 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
694 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
695 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
697 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
698 anInitialPath + QString("/") + aMeshName,
699 aFilter, aTitle, false);
703 const char* theOptionResource = "cgns_group_elems_by_type";
704 bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
706 QStringList checkBoxes;
707 checkBoxes << QObject::tr( "CGNS_EXPORT_ELEMS_BY_TYPE" ) << QObject::tr("STRUCTUREDCGNS");
709 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
711 fd->setWindowTitle( aTitle );
712 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
714 if ( !anInitialPath.isEmpty() )
715 fd->setDirectory( anInitialPath );
716 fd->selectFile( aMeshName );
717 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
718 fd->setValidator( fv );
719 fd->SetChecked( option, 0 );
723 aFilename = fd->selectedFile();
724 structureCGNS = fd->IsChecked( 1 );
727 toOverwrite = fv->isOverwrite( aFilename );
728 option = fd->IsChecked( 0 );
729 SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
730 toCreateGroups = option;
734 else if ( isUNV || isDAT ) // Export to [ UNV | DAT ] - one option
736 const char* theOptionResource = "export_renumber";
737 bool option = resMgr->booleanValue( "SMESH", theOptionResource, false );
739 QStringList checkBoxes;
740 checkBoxes << QObject::tr( "SMESH_RENUMBER" );
742 SalomeApp_CheckFileDlg* fd =
743 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
744 fd->setWindowTitle( aTitle );
746 fd->setNameFilter( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
748 fd->setNameFilter( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
749 if ( !anInitialPath.isEmpty() )
750 fd->setDirectory( anInitialPath );
751 fd->selectFile( aMeshName );
752 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
753 fd->setValidator( fv );
754 fd->SetChecked( option, 0 );
757 aFilename = fd->selectedFile();
758 toOverwrite = fv->isOverwrite( aFilename );
759 option = fd->IsChecked( 0 );
760 SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
765 else if ( isSTL ) // Export to STL
767 QMap<QString, int> aFilterMap;
769 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
770 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
772 QMap<QString, int>::const_iterator it = aFilterMap.begin();
773 for ( ; it != aFilterMap.end(); ++it )
774 filters.push_back( it.key() );
776 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
777 fd->setWindowTitle( aTitle );
778 fd->setNameFilters( filters );
780 if ( !anInitialPath.isEmpty() )
781 fd->setDirectory( anInitialPath );
782 fd->selectFile(aMeshName);
786 aFilename = fd->selectedFile();
788 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
793 else if ( isMED ) // Export to MED
795 int defaultVersion = 0;
796 QMap<QString, int> aFilterMap;
797 //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
798 //QString vmed (aMesh->GetVersionString(-1, 2));
799 SMESH::long_array_var mvok = aMesh->GetMEDVersionsCompatibleForAppend();
800 if ( mvok->length() > 0)
801 defaultVersion = mvok[0]; // the current version to set the default filter on it
802 for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
804 QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
805 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
808 QMap<QString, int>::const_iterator it = aFilterMap.begin();
809 QString aDefaultFilter = it.key();
810 for ( ; it != aFilterMap.end(); ++it ) {
811 filters.push_back( it.key() );
812 if (it.value() == defaultVersion) // explicit default for MED = current MED version
813 aDefaultFilter = it.key();
815 QStringList checkBoxes;
816 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS")
817 << QObject::tr("SMESH_AUTO_DIM")
818 << QObject::tr("SMESH_MED_SAVE_NUMS");
820 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
821 QList< QWidget* > wdgList;
822 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
823 wdgList.append( fieldSelWdg );
825 QWidget* zTolWdg = new QWidget();
826 QCheckBox* zTolCheck = new QCheckBox( QObject::tr( "SMESH_ZTOLERANCE" ), zTolWdg );
827 SMESHGUI_SpinBox* zTolSpin = new SMESHGUI_SpinBox( zTolWdg );
828 QHBoxLayout* zTolLayout = new QHBoxLayout( zTolWdg );
829 zTolLayout->addWidget( zTolCheck );
830 zTolLayout->addWidget( zTolSpin );
831 zTolLayout->setMargin( 0 );
832 zTolSpin->RangeStepAndValidator( 0, 1e+100, 1., "length_precision" );
833 zTolSpin->setValue( zTol );
834 QObject::connect( zTolCheck, SIGNAL( toggled(bool)), zTolSpin, SLOT( setEnabled(bool)));
835 zTolCheck->setChecked( resMgr->booleanValue( "SMESH", "enable_ztolerance", false ));
836 zTolSpin ->setEnabled( zTolCheck->isChecked() );
837 wdgList.append( zTolWdg );
839 SalomeApp_CheckFileDlg* fd =
840 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
841 fd->setWindowTitle( aTitle );
842 fd->setNameFilters( filters );
843 fd->selectNameFilter( aDefaultFilter );
844 fd->SetChecked( toCreateGroups, 0 );
845 fd->SetChecked( toFindOutDim, 1 );
846 fd->SetChecked( saveNumbers, 2 );
847 if ( !anInitialPath.isEmpty() )
848 fd->setDirectory( anInitialPath );
849 fd->selectFile(aMeshName);
852 QListView *lview = fd->findChild<QListView*>("listView");
854 lview->setMinimumHeight(200);
856 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
858 tview->setMinimumHeight(200);
861 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
862 fd->setValidator( fv );
867 //MESSAGE("******* Loop on file dialog ***********");
870 aFilename = fd->selectedFile();
872 aFilename = QString::null;
875 aFormat = aFilterMap[fd->selectedNameFilter()];
876 //MESSAGE("selected version: " << aFormat << " file: " << aFilename.toUtf8().constData());
877 toOverwrite = fv->isOverwrite(aFilename);
878 //MESSAGE("toOverwrite:" << toOverwrite);
880 if ( !aFilename.isEmpty() ) {
882 // append is only possible if the existing file format is compatible
883 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckWriteCompatibility( aFilename.toUtf8().constData() );
884 MESSAGE("Append check, isVersionOk:" << isVersionOk);
885 if ( !isVersionOk ) {
886 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
887 QObject::tr("SMESH_WRN_WARNING"),
888 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
889 QObject::tr("SMESH_BUT_YES"),
890 QObject::tr("SMESH_BUT_NO"), 0, 1);
894 //MESSAGE("incompatible MED file version for add, overwrite accepted");
900 //MESSAGE("incompatible MED file version for add, overwrite refused");
903 QStringList aMeshNamesCollisionList;
904 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
905 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
906 QString anExistingMeshName( aMeshNames[ i ] );
907 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
908 QString anExportMeshName = (*aMeshIter).second;
909 if( anExportMeshName == anExistingMeshName ) {
910 aMeshNamesCollisionList.append( anExportMeshName );
915 if( !aMeshNamesCollisionList.isEmpty() ) {
917 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
918 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
919 QObject::tr("SMESH_WRN_WARNING"),
920 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
921 QObject::tr("SMESH_BUT_YES"),
922 QObject::tr("SMESH_BUT_NO"),
923 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
924 MESSAGE("answer collision name " << aRet);
935 toCreateGroups = fd->IsChecked(0);
936 toFindOutDim = fd->IsChecked(1);
937 saveNumbers = fd->IsChecked(2);
938 zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1;
939 fieldSelWdg->GetSelectedFields();
940 if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() );
942 if ( !fieldSelWdg->parent() )
944 if ( !zTolWdg->parent() )
950 if (SMESHGUI_Meshio::CheckMeshCount(aMeshList))
952 aFilename = SMESHGUI_Meshio::GetFileName(aSelectedFilter);
953 MESSAGE("aSelectedFilter: " << aSelectedFilter.toStdString());
963 if ( !aFilename.isEmpty() ) {
964 // Check whether the file already exists and delete it if yes
965 QFile aFile( aFilename );
966 if ( aFile.exists() && toOverwrite )
968 SUIT_OverrideCursor wc;
971 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
972 // bool Renumber = false;
973 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
975 // Renumber= resMgr->booleanValue("renumbering");
977 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
978 // aMeshEditor->RenumberNodes();
979 // aMeshEditor->RenumberElements();
980 // if ( SMESHGUI::automaticUpdate() )
981 // SMESH::UpdateView();
983 if ( isMED && isOkToWrite )
985 aMeshIter = aMeshList.begin();
986 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
988 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
989 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
990 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
991 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
993 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
994 toCreateGroups, aFormat,
995 toOverwrite && aMeshIndex == 0, toFindOutDim,
996 fields, geoAssFields.toLatin1().data(), zTol, saveNumbers );
1001 if ( aMeshOrGroup->_is_equivalent( aMesh ))
1002 aMesh->ExportDAT( aFilename.toUtf8().data(), toRenumber );
1004 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
1008 if ( aMeshOrGroup->_is_equivalent( aMesh ))
1009 aMesh->ExportUNV( aFilename.toUtf8().data(), toRenumber );
1011 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data(), toRenumber );
1015 if ( aMeshOrGroup->_is_equivalent( aMesh ))
1016 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
1018 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
1022 aMeshIter = aMeshList.begin();
1024 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
1026 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
1027 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
1029 if ( !structureCGNS )
1030 aMeshItem->ExportCGNS( aMeshOrGroup,
1031 aFilename.toUtf8().data(),
1032 toOverwrite && aMeshIndex == 0,
1035 aMeshItem->ExportStructuredCGNS( aMeshOrGroup,
1036 aFilename.toUtf8().data(),
1037 toOverwrite && aMeshIndex == 0 );
1042 toCreateGroups = true;
1043 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
1047 SMESHGUI_Meshio::ExportMesh(aMeshList, aFilename, aSelectedFilter);
1050 catch (const SALOME::SALOME_Exception& S_ex)
1053 const QString exText(S_ex.details.text);
1055 if ( S_ex.details.type == SALOME::COMM && // communicate about too large mesh
1056 strncmp( "format=", S_ex.details.sourceFile.in(), 7 ) == 0 )
1058 SUIT_MessageBox::critical(SMESHGUI::desktop(),
1059 QObject::tr("SMESH_WRN_WARNING"),
1060 QObject::tr(S_ex.details.text.in() ));
1061 else if (exText.startsWith("MESHIO"))
1063 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1064 QObject::tr("SMESH_WRN_WARNING"),
1065 QObject::tr("SMESH_EXPORT_FAILED_SHORT") + "\n\n" + exText);
1069 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1070 QObject::tr("SMESH_WRN_WARNING"),
1071 QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
1074 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1075 QObject::tr("SMESH_WRN_WARNING"),
1076 SalomeApp_Tools::ExceptionToString(S_ex));
1082 inline void InverseEntityMode(unsigned int& theOutputMode,
1083 unsigned int theMode)
1085 bool anIsNotPresent = ~theOutputMode & theMode;
1087 theOutputMode |= theMode;
1089 theOutputMode &= ~theMode;
1092 void SetDisplayEntity(int theCommandID)
1094 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1095 SALOME_ListIO selected;
1097 aSel->selectedObjects( selected );
1099 if ( selected.Extent() >= 1 ) {
1100 SUIT_OverrideCursor wc;
1101 SALOME_ListIteratorOfListIO It( selected );
1102 for( ; It.More(); It.Next()){
1103 Handle(SALOME_InteractiveObject) IObject = It.Value();
1104 if(IObject->hasEntry()){
1105 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1106 unsigned int aMode = anActor->GetEntityMode();
1107 switch(theCommandID){
1108 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1109 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1110 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1111 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1112 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1113 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1116 anActor->SetEntityMode(aMode);
1125 SalomeApp_Application* app =
1126 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1130 LightApp_SelectionMgr* aSel = app->selectionMgr();
1131 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1132 if ( !aSel || !appStudy )
1135 SALOME_ListIO selected;
1136 aSel->selectedObjects( selected );
1137 if ( selected.IsEmpty() )
1140 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1142 _PTR(Study) aStudy = appStudy->studyDS();
1143 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1144 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1145 if ( aMainObject->_is_nil() )
1148 SUIT_OverrideCursor wc;
1150 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1152 QList<SALOMEDS::Color> aReservedColors;
1154 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1155 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1157 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1159 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1160 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1161 #else // old algorithm for auto-colors
1162 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1163 aReservedColors.append( aColor );
1164 #endif // SIMPLE_AUTOCOLOR
1165 aGroupObject->SetColor( aColor );
1167 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1168 if ( aGroupSObject ) {
1171 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1172 switch ( aGroupObject->GetType ()) {
1174 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1176 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1178 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1180 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1182 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1183 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1186 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1187 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1193 SMESH::RepaintCurrentView();
1196 void OverallMeshQuality()
1198 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1199 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1200 SALOME_ListIO selected;
1202 aSel->selectedObjects( selected );
1204 if ( selected.IsEmpty() ) return;
1205 SALOME_ListIteratorOfListIO It( selected );
1206 for ( ; It.More(); It.Next() ) {
1207 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1208 ctrlDlg->showInfo( It.Value() );
1213 QString functorToString( SMESH::Controls::FunctorPtr f )
1215 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1216 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1217 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1218 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1219 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1220 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1221 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1222 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1223 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1224 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1225 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1226 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1227 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1228 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1229 type = QObject::tr( "WARP_ELEMENTS" );
1230 else if (dynamic_cast<SMESH::Controls::Warping3D*>(f.get()))
1231 type = QObject::tr("WARP_3D_ELEMENTS");
1232 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1233 type = QObject::tr( "TAPER_ELEMENTS" );
1234 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1235 type = QObject::tr( "SKEW_ELEMENTS" );
1236 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1237 type = QObject::tr( "AREA_ELEMENTS" );
1238 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1239 type = QObject::tr( "LENGTH_EDGES" );
1240 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1241 type = QObject::tr( "LENGTH2D_EDGES" );
1242 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1243 type = QObject::tr( "DEFLECTION2D_FACES" );
1244 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1245 type = QObject::tr( "MULTI_BORDERS" );
1246 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1247 type = QObject::tr( "MULTI2D_BORDERS" );
1248 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1249 type = QObject::tr( "FREE_NODES" );
1250 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1251 type = QObject::tr( "FREE_EDGES" );
1252 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1253 type = QObject::tr( "FREE_BORDERS" );
1254 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1255 type = QObject::tr( "FREE_FACES" );
1256 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1257 type = QObject::tr( "BARE_BORDER_VOLUME" );
1258 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1259 type = QObject::tr( "BARE_BORDER_FACE" );
1260 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1261 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1262 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1263 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1264 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1265 type = QObject::tr( "EQUAL_NODE" );
1266 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1267 type = QObject::tr( "EQUAL_EDGE" );
1268 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1269 type = QObject::tr( "EQUAL_FACE" );
1270 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1271 type = QObject::tr( "EQUAL_VOLUME" );
1272 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1273 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1274 else if ( dynamic_cast< SMESH::Controls::ScaledJacobian* >( f.get() ) )
1275 type = QObject::tr( "SCALED_JACOBIAN" );
1279 void SaveDistribution()
1281 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1282 SALOME_ListIO selected;
1284 aSel->selectedObjects( selected );
1286 if ( selected.Extent() == 1 ) {
1287 Handle(SALOME_InteractiveObject) anIO = selected.First();
1288 if ( anIO->hasEntry() ) {
1289 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1291 anActor->GetScalarBarActor() &&
1292 anActor->GetControlMode() != SMESH_Actor::eNone )
1294 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1295 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1296 if ( aScalarBarActor && aFunctor ) {
1297 SMESH::Controls::NumericalFunctor* aNumFun =
1298 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1300 std::vector<smIdType> elements;
1301 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1302 if ( mesh->_is_nil() ) {
1303 SMESH::SMESH_IDSource_var idSource =
1304 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1305 if ( !idSource->_is_nil() )
1307 SMESH::smIdType_array_var ids = idSource->GetIDs();
1308 elements.resize( ids->length() );
1309 for ( unsigned i = 0; i < elements.size(); ++i )
1310 elements[i] = ids[i];
1313 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1314 vtkLookupTable* lookupTable =
1315 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1316 double * minmax = lookupTable->GetRange();
1317 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1318 std::vector<int> nbEvents;
1319 std::vector<double> funValues;
1320 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1321 elements, minmax, isLogarithmic );
1322 QString anInitialPath = "";
1323 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1324 anInitialPath = QDir::currentPath();
1325 QString aMeshName = anIO->getName();
1327 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1328 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1329 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1330 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1331 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1334 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1336 if ( !aFilename.isEmpty() ) {
1337 QFile f( aFilename );
1338 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1339 QTextStream out( &f );
1340 out << "# Mesh: " << aMeshName << endl;
1341 out << "# Control: " << functorToString( aFunctor ) << endl;
1343 out.setFieldWidth( 10 );
1344 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1345 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1356 void ShowElement( int theCommandID )
1358 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1359 SALOME_ListIO selected;
1361 aSel->selectedObjects( selected );
1363 if ( selected.Extent() == 1 ) {
1364 Handle(SALOME_InteractiveObject) anIO = selected.First();
1365 if ( anIO->hasEntry() ) {
1366 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1368 anActor->GetScalarBarActor() &&
1369 anActor->GetControlMode() != SMESH_Actor::eNone )
1371 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1372 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1373 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1375 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1376 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1383 #ifndef DISABLE_PLOT2DVIEWER
1384 void PlotDistribution()
1386 SalomeApp_Application* app =
1387 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1391 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1392 SALOME_ListIO selected;
1394 aSel->selectedObjects( selected );
1396 if ( selected.Extent() == 1 ) {
1397 Handle(SALOME_InteractiveObject) anIO = selected.First();
1398 if ( anIO->hasEntry() ) {
1399 //Find Actor by entry before getting Plot2d viewer,
1400 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1401 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1403 SUIT_ViewManager* aViewManager =
1404 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1408 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1412 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1416 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1418 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1419 QString functorName = functorToString( anActor->GetFunctor());
1420 QString aHistogramName("%1 : %2");
1421 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1422 aHistogram->setName(aHistogramName);
1423 aHistogram->setHorTitle(functorName);
1424 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1425 aPlot->displayObject(aHistogram, true);
1430 #endif //DISABLE_PLOT2DVIEWER
1432 void DisableAutoColor()
1434 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1435 SALOME_ListIO selected;
1437 aSel->selectedObjects( selected );
1439 if ( selected.Extent() ) {
1440 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1441 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1442 if ( !aMesh->_is_nil() ) {
1443 aMesh->SetAutoColor( false );
1450 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1451 SALOME_ListIO selected;
1453 aSel->selectedObjects( selected );
1454 if ( selected.Extent() )
1456 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1457 _PTR(Study) aStudy = SMESH::getStudy();
1458 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1460 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1461 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1468 // Break link with Shaper model
1469 void breakShaperLink()
1471 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1472 SALOME_ListIO selected;
1474 aSel->selectedObjects(selected);
1475 if (selected.Extent()) {
1476 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1477 _PTR(Study) aStudy = SMESH::getStudy();
1478 std::string aEntry = anIObject->getEntry();
1479 _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
1481 std::string aName = aSObj->GetName();
1482 QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
1483 QObject::tr("SMESH_WRN_WARNING"),
1484 QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
1485 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
1486 if (aRes == SUIT_MessageBox::Yes) {
1487 SUIT_DataOwnerPtrList aList;
1488 aSel->selected(aList, "ObjectBrowser", true);
1489 SUIT_DataOwner* aOwn = aList.first();
1490 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
1491 QString aREntry = sowner->entry();
1493 static GEOM::GEOM_Gen_var geomGen;
1494 if (CORBA::is_nil(geomGen)) {
1495 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
1496 (SUIT_Session::session()->activeApplication());
1498 SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
1499 Engines::EngineComponent_var comp =
1500 ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
1501 geomGen = GEOM::GEOM_Gen::_narrow(comp);
1504 if (!CORBA::is_nil(geomGen))
1506 geomGen->BreakLink(aREntry.toStdString().c_str());
1507 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1509 // remove actors whose objects are removed by BreakLink()
1510 QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
1511 SUIT_ViewWindow* wnd;
1512 foreach(wnd, wndList)
1513 SMESH::UpdateActorsAfterUpdateStudy(wnd);
1521 //================================================================================
1523 * \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
1524 * which means that the mesh can't be modified. It should be either re-computed
1525 * or breakShaperLink()'ed. Warn the user about it.
1527 //================================================================================
1529 bool warnOnGeomModif()
1531 SALOME_ListIO selected;
1532 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1533 aSel->selectedObjects(selected,"",/*convertReferences=*/false);
1535 SALOME_ListIteratorOfListIO It( selected );
1536 for ( ; It.More(); It.Next() )
1538 Handle(SALOME_InteractiveObject) io = It.Value();
1539 if ( !io->hasEntry() ) continue;
1540 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
1541 SMESH::SMESH_Mesh_var mesh;
1542 while ( mesh->_is_nil() && so && so->GetID() != "0:" )
1544 CORBA::Object_var obj = SMESH::SObjectToObject( so );
1545 SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
1546 if ( isrc->_is_nil() )
1547 so = so->GetFather();
1549 mesh = isrc->GetMesh();
1551 if ( mesh->_is_nil() ) continue;
1552 so = SMESH::FindSObject( mesh );
1553 if ( !so ) continue;
1554 _PTR(GenericAttribute) attr;
1555 so->FindAttribute( attr, "AttributePixMap" );
1556 _PTR(AttributePixMap) pixmap = attr;
1557 if ( !pixmap ) continue;
1559 if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
1561 SUIT_MessageBox::warning(SMESHGUI::desktop(),
1562 QObject::tr("SMESH_WRN_WARNING"),
1563 QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
1570 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1572 SALOME_ListIO selected;
1573 SalomeApp_Application* app =
1574 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1578 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1579 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1580 if ( !aSel || !appStudy )
1583 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1584 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1585 aModule->EmitSignalDeactivateDialog();
1586 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1587 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1592 aSel->selectedObjects( selected );
1594 if ( selected.Extent() >= 1 )
1596 switch ( theCommandID ) {
1597 case SMESHOp::OpTransparency:
1599 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1600 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1603 case SMESHOp::OpProperties:
1606 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1607 QColor orientationColor, outlineColor, volumeColor;
1608 int deltaF = 0, deltaV = 0;
1611 double ballScale = 1.0;
1613 int outlineWidth = 1;
1614 double shrinkCoef = 0.0;
1615 double orientationScale = 0.0;
1616 bool orientation3d = false;
1617 VTK::MarkerType markerType = VTK::MT_NONE;
1618 VTK::MarkerScale markerScale = VTK::MS_NONE;
1620 bool hasNodes = false;
1621 int presentEntities = 0;
1622 bool firstTime = true;
1624 SALOME_ListIteratorOfListIO It( selected );
1625 for ( ; It.More(); It.Next() ) {
1626 Handle(SALOME_InteractiveObject) IObject = It.Value();
1627 if ( !IObject->hasEntry() ) continue;
1628 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1629 if ( !anActor || !anActor->GetObject() ) continue;
1632 // nodes: color, marker
1633 anActor->GetNodeColor( color[0], color[1], color[2] );
1634 nodeColor.setRgbF( color[0], color[1], color[2] );
1635 markerType = anActor->GetMarkerType();
1636 markerScale = anActor->GetMarkerScale();
1637 markerId = anActor->GetMarkerTexture();
1638 // edges: color, width
1639 anActor->GetEdgeColor( color[0], color[1], color[2] );
1640 edgeColor.setRgbF( color[0], color[1], color[2] );
1641 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1642 // faces: front color, back color (delta)
1643 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1644 faceColor.setRgbF( color[0], color[1], color[2] );
1645 // faces: front color, back color (delta)
1646 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1647 volumeColor.setRgbF( color[0], color[1], color[2] );
1648 // 0d elements: color, size
1649 anActor->Get0DColor( color[0], color[1], color[2] );
1650 elem0dColor.setRgbF( color[0], color[1], color[2] );
1651 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1652 // balls: color, size
1653 anActor->GetBallColor( color[0], color[1], color[2] );
1654 ballColor.setRgbF( color[0], color[1], color[2] );
1655 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1656 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1658 anActor->GetOutlineColor( color[0], color[1], color[2] );
1659 outlineColor.setRgbF( color[0], color[1], color[2] );
1660 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1661 // orientation vectors: color, scale, 3d flag
1662 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1663 orientationColor.setRgbF( color[0], color[1], color[2] );
1664 orientationScale = anActor->GetFacesOrientationScale();
1665 orientation3d = anActor->GetFacesOrientation3DVectors();
1667 shrinkCoef = anActor->GetShrinkFactor();
1670 firstTime = false; // we only take properties from first object (for performance reasons)
1673 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1674 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1675 presentEntities = presentEntities | SMESH_Actor::eEdges;
1676 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1677 presentEntities = presentEntities | SMESH_Actor::eFaces;
1678 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1679 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1680 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1681 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1682 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1683 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1685 // as we know that all types of elements are present, we can exit the loop
1686 if ( presentEntities == SMESH_Actor::eAllEntity )
1690 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1691 // nodes: color, marker
1692 dlg.setNodeColor( nodeColor );
1693 if( markerType != VTK::MT_USER )
1694 dlg.setNodeMarker( markerType, markerScale );
1696 dlg.setNodeCustomMarker( markerId );
1697 // edges: color, line width
1698 dlg.setEdgeColor( edgeColor );
1699 dlg.setEdgeWidth( edgeWidth );
1700 // faces: front color, back color
1701 dlg.setFaceColor( faceColor, deltaF );
1702 // volumes: normal color, reversed color
1703 dlg.setVolumeColor( volumeColor, deltaV );
1704 // outlines: color, line width
1705 dlg.setOutlineColor( outlineColor );
1706 dlg.setOutlineWidth( outlineWidth );
1707 // 0d elements: color, size
1708 dlg.setElem0dColor( elem0dColor );
1709 dlg.setElem0dSize( elem0dSize );
1710 // balls: color, size
1711 dlg.setBallColor( ballColor );
1712 //dlg.setBallSize( ballSize );
1713 dlg.setBallScale( ballScale );
1714 // orientation: color, scale, 3d flag
1715 dlg.setOrientationColor( orientationColor );
1716 dlg.setOrientationSize( int( orientationScale * 100. ) );
1717 dlg.setOrientation3d( orientation3d );
1718 // shrink: scale factor
1719 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1720 // hide unused controls
1721 dlg.showControls( presentEntities, hasNodes );
1724 nodeColor = dlg.nodeColor();
1725 markerType = dlg.nodeMarkerType();
1726 markerScale = dlg.nodeMarkerScale();
1727 markerId = dlg.nodeMarkerId();
1728 edgeColor = dlg.edgeColor();
1729 edgeWidth = dlg.edgeWidth();
1730 faceColor = dlg.faceColor();
1731 deltaF = dlg.faceColorDelta();
1732 volumeColor = dlg.volumeColor();
1733 deltaV = dlg.volumeColorDelta();
1734 outlineColor = dlg.outlineColor();
1735 outlineWidth = dlg.outlineWidth();
1736 elem0dColor = dlg.elem0dColor();
1737 elem0dSize = dlg.elem0dSize();
1738 ballColor = dlg.ballColor();
1739 // ballSize = dlg.ballSize();
1740 ballScale = dlg.ballScale();
1741 orientationColor = dlg.orientationColor();
1742 orientationScale = dlg.orientationSize() / 100.;
1743 orientation3d = dlg.orientation3d();
1744 shrinkCoef = dlg.shrinkCoef() / 100.;
1746 // store point markers that might be changed by the user
1747 theMarkerMap = dlg.customMarkers();
1749 // set properties from dialog box to the presentations
1750 SALOME_ListIteratorOfListIO It( selected );
1751 for ( ; It.More(); It.Next() ) {
1752 Handle(SALOME_InteractiveObject) IObject = It.Value();
1753 if ( !IObject->hasEntry() ) continue;
1754 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1755 if ( !anActor ) continue;
1757 // nodes: color, marker
1758 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1759 if ( markerType != VTK::MT_USER ) {
1760 anActor->SetMarkerStd( markerType, markerScale );
1763 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1764 if ( iter != theMarkerMap.end() )
1765 anActor->SetMarkerTexture( markerId, iter->second.second );
1767 // volumes: normal color, reversed color (delta)
1768 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1769 // faces: front color, back color (delta)
1770 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1771 // edges: color, width
1772 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1773 anActor->SetLineWidth( edgeWidth );
1775 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1776 anActor->SetOutlineWidth( outlineWidth );
1777 // 0D elements: color, size
1778 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1779 anActor->Set0DSize( elem0dSize );
1780 // balls: color, size
1781 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1782 // anActor->SetBallSize( ballSize );
1783 anActor->SetBallScale( ballScale );
1784 // orientation: color, scale, 3d flag
1785 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1786 anActor->SetFacesOrientationScale( orientationScale );
1787 anActor->SetFacesOrientation3DVectors( orientation3d );
1789 anActor->SetShrinkFactor( shrinkCoef );
1791 // for groups, set also proper color
1792 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1793 if ( !aGroupObject->_is_nil() ) {
1794 SMESH::ElementType anElementType = aGroupObject->GetType();
1796 switch( anElementType ) {
1798 aColor = nodeColor; break;
1800 aColor = edgeColor; break;
1802 aColor = faceColor; break;
1804 aColor = volumeColor; break;
1806 aColor = elem0dColor; break;
1808 aColor = ballColor; break;
1812 if ( aColor.isValid() ) {
1813 SALOMEDS::Color aGroupColor;
1814 aGroupColor.R = aColor.redF();
1815 aGroupColor.G = aColor.greenF();
1816 aGroupColor.B = aColor.blueF();
1817 aGroupObject->SetColor( aGroupColor );
1819 } // if ( !aGroupObject->_is_nil() )
1820 } // for ( ; It.More(); It.Next() )
1821 SMESH::RepaintCurrentView();
1822 } // if ( dlg.exec() )
1824 } // case SMESHOp::OpProperties:
1825 } // switch(theCommandID)
1826 SUIT_OverrideCursor wc;
1827 SALOME_ListIteratorOfListIO It( selected );
1828 for( ; It.More(); It.Next()){
1829 Handle(SALOME_InteractiveObject) IObject = It.Value();
1830 if(IObject->hasEntry()){
1831 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1832 switch(theCommandID){
1833 case SMESHOp::OpDMWireframe:
1834 anActor->SetRepresentation(SMESH_Actor::eEdge);
1836 case SMESHOp::OpDMShading:
1837 anActor->SetRepresentation(SMESH_Actor::eSurface);
1839 case SMESHOp::OpDMShrink:
1840 if(anActor->IsShrunk())
1841 anActor->UnShrink();
1843 anActor->SetShrink();
1845 case SMESHOp::OpDMNodes:
1846 anActor->SetRepresentation(SMESH_Actor::ePoint);
1848 case SMESHOp::OpRepresentationLines:
1849 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1850 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1852 case SMESHOp::OpRepresentationArcs:
1853 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1854 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1860 SMESH::RepaintCurrentView();
1864 int ActionToControl( int theID, bool theReversed )
1866 NCollection_DoubleMap<int,int> ActionControl;
1867 ActionControl.Bind( 0, SMESH_Actor::eNone );
1868 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1869 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1870 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1871 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1872 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1873 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1874 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1875 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1876 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1877 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1878 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1879 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1880 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1881 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1882 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1883 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1884 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1885 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1886 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1887 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1888 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1889 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1890 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1891 ActionControl.Bind( SMESHOp::OpWarping3D, SMESH_Actor::eWarping3D );
1892 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1893 ActionControl.Bind( SMESHOp::OpScaledJacobian, SMESH_Actor::eScaledJacobian );
1894 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1895 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1896 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1897 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1900 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1901 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1904 void Control( int theCommandID )
1906 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1907 _PTR(Study) aStudy = SMESH::getStudy();
1909 SALOME_ListIO selected;
1910 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1911 aSel->selectedObjects( selected );
1913 if ( !selected.IsEmpty() ) {
1914 SALOME_ListIteratorOfListIO It(selected);
1915 for ( ; It.More(); It.Next())
1917 Handle(SALOME_InteractiveObject) anIO = It.Value();
1918 if ( !anIO.IsNull() ) {
1919 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1921 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1922 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1923 if ( !anIDSrc->_is_nil() ) {
1924 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1925 if (( !anActor && selected.Extent() == 1 ) &&
1926 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1928 anActor->SetControlMode( aControl );
1929 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1930 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1934 if ( anActor->GetControlMode() != aControl )
1935 anActor->SetControlMode( aControl );
1936 QString functorName = functorToString( anActor->GetFunctor() );
1937 smIdType anEntitiesCount = anActor->GetNumberControlEntities();
1938 if (anEntitiesCount >= 0)
1939 functorName = functorName + ": " + QString::number(anEntitiesCount);
1940 anActor->GetScalarBarActor()->SetTitle( functorName.toUtf8().constData() );
1941 SMESH::RepaintCurrentView();
1942 #ifndef DISABLE_PLOT2DVIEWER
1943 if ( anActor->GetPlot2Histogram() ) {
1944 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1945 QString aHistogramName("%1 : %2");
1946 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1947 aHistogram->setName( aHistogramName );
1948 aHistogram->setHorTitle( functorName );
1949 SMESH::ProcessIn2DViewers( anActor );
1961 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1962 SMESH::MeshObjectType theType,
1963 const QString theInTypeName,
1964 QString & theOutTypeName)
1966 SMESH_TypeFilter aTypeFilter( theType );
1968 if ( !theIO.IsNull() )
1970 entry = theIO->getEntry();
1971 LightApp_DataOwner owner( entry );
1972 if ( aTypeFilter.isOk( &owner )) {
1973 theOutTypeName = theInTypeName;
1981 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1983 _PTR(Study) aStudy = SMESH::getStudy();
1984 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1986 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1987 CORBA::String_var anID = aSComp->GetID().c_str();
1988 if ( !strcmp(anID.in(),theIO->getEntry()) )
1994 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1995 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1996 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1997 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1998 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
2006 // QString CheckHomogeneousSelection()
2008 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2009 // SALOME_ListIO selected;
2011 // aSel->selectedObjects( selected );
2013 // QString RefType = CheckTypeObject(selected.First());
2014 // SALOME_ListIteratorOfListIO It(selected);
2015 // for ( ; It.More(); It.Next())
2017 // Handle(SALOME_InteractiveObject) IObject = It.Value();
2018 // QString Type = CheckTypeObject(IObject);
2019 // if ( Type.compare(RefType) != 0 )
2020 // return "Heterogeneous Selection";
2026 uint randomize( uint size )
2028 static bool initialized = false;
2029 if ( !initialized ) {
2030 qsrand( QDateTime::currentDateTime().toTime_t() );
2034 v = uint( (double)( v ) / RAND_MAX * size );
2035 v = qMax( uint(0), qMin ( v, size-1 ) );
2041 void SMESHGUI::OnEditDelete()
2043 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
2044 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
2045 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
2047 _PTR(Study) aStudy = SMESH::getStudy();
2048 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
2049 _PTR(GenericAttribute) anAttr;
2050 _PTR(AttributeIOR) anIOR;
2052 const int objectCountLimit = 30; // PAL23599
2053 int objectCount = 0;
2055 QString aParentComponent = QString::null;
2057 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
2059 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
2060 if ( anIO.IsNull() ) continue;
2062 QString father = "unknown", name;
2064 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
2066 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
2067 // check if object is reference
2068 _PTR(SObject) aRefSObj;
2069 if ( aSO->ReferencedObject( aRefSObj ) ) {
2070 name = QString::fromStdString ( aRefSObj->GetName() );
2071 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
2074 name = anIO->getName();
2077 if ( objectCount < objectCountLimit ) { // avoid occupying the whole screen
2078 aNameList.append("\n - ");
2079 aNameList.append( name );
2082 if( aParentComponent.isNull() )
2083 aParentComponent = father;
2084 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
2085 aParentComponent = "";
2087 if ( objectCount >= objectCountLimit )
2088 aNameList.append("\n - ...");
2090 if ( objectCount == 0 )
2091 return; // No Valid Objects Selected
2093 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
2094 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2095 QObject::tr("ERR_ERROR"),
2096 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
2099 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
2100 if (SUIT_MessageBox::warning
2101 (SMESHGUI::desktop(),
2102 QObject::tr("SMESH_WRN_WARNING"),
2103 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
2104 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
2105 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
2108 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2110 // Put one level of sub-objects of the selected SO's into a list
2111 // in order to get objects inside folders like "Assigned Algorithms"
2112 std::list< _PTR(SObject) > listSO;
2113 SALOME_ListIteratorOfListIO It(selected);
2114 for( ; It.More(); It.Next()) // loop on selected IO's
2116 Handle(SALOME_InteractiveObject) IObject = It.Value();
2117 if(IObject->hasEntry()) {
2118 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
2120 // disable removal of "SMESH" component object
2121 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
2123 if ( engineIOR() == anIOR->Value().c_str() )
2126 //Check the referenced object
2127 _PTR(SObject) aRefSObject;
2128 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
2129 aSO = aRefSObject; // Delete main Object instead of reference
2131 listSO.push_back( aSO );
2133 _PTR(ChildIterator) it = aStudy->NewChildIterator( aSO );
2134 for (it->InitEx(false); it->More(); it->Next())
2135 listSO.push_back( it->Value() );
2138 // Check if none of objects to delete is referred from outside
2139 std::list< _PTR(SObject) >::reverse_iterator ritSO;
2140 std::vector< _PTR(SObject) > subSO;
2141 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2143 _PTR(SObject) SO = *ritSO;
2144 if ( !SO ) continue;
2146 int nbChildren = SO->GetLastChildTag();
2148 subSO.reserve( 1 + nbChildren );
2149 subSO.push_back( SO );
2150 if ( nbChildren > 0 )
2152 _PTR(ChildIterator) it = aStudy->NewChildIterator( SO );
2153 for ( it->InitEx( true ); it->More(); it->Next() )
2154 subSO.push_back( it->Value() );
2156 for ( size_t i = 0; i < subSO.size(); ++i )
2158 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( subSO[i] );
2159 for ( size_t j = 0; j < aReferences.size(); j++ ) {
2160 _PTR(SComponent) aComponent = aReferences[j]->GetFatherComponent();
2161 std::string type = aComponent->ComponentDataType();
2162 if ( type != "SMESH" )
2164 SUIT_MessageBox::warning( anApp->desktop(),
2165 QObject::tr("WRN_WARNING"),
2166 QObject::tr("DEP_OBJECT") );
2167 return; // outside SMESH, there is an object depending on a SMESH object
2173 // Treat SO's in the list starting from the back
2174 aStudyBuilder->NewCommand(); // There is a transaction
2175 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
2177 _PTR(SObject) SO = *ritSO;
2178 if ( !SO ) continue;
2179 std::string anEntry = SO->GetID();
2181 /** Erase graphical object and remove all its data **/
2182 if ( SO->FindAttribute( anAttr, "AttributeIOR" )) {
2183 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
2185 /** Remove an object from data structures **/
2186 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
2187 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
2188 if ( !aGroup->_is_nil() ) { // DELETE GROUP
2189 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
2190 aMesh->RemoveGroup( aGroup );
2192 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
2193 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2194 aMesh->RemoveSubMesh( aSubMesh );
2197 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
2198 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
2199 QString objType = CheckTypeObject(IObject);
2200 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
2201 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2202 aStudyBuilder->RemoveObjectWithChildren( SO );
2204 else {// default action: remove SObject from the study
2205 // Find Sub-Meshes and Group and delete corresopning visual objects and actors
2206 _PTR(ChildIterator) it1 = aStudy->NewChildIterator(SO);
2207 for (it1->InitEx(false); it1->More(); it1->Next()) {
2208 _PTR(SObject) SObj = it1->Value();
2209 if (!SObj) continue;
2210 if (SObj->FindAttribute(anAttr, "AttributeIOR")) {
2211 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(SMESH::SObjectToObject(SObj));
2212 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(SMESH::SObjectToObject(SObj));
2213 if (!aGroup->_is_nil() || !aSubMesh->_is_nil()) {
2214 SMESH::RemoveVisualObjectWithActors(SObj->GetID().c_str(), true);
2218 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2219 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2221 aStudyBuilder->RemoveObjectWithChildren( SO );
2225 } /* listSO back loop */
2227 aStudyBuilder->CommitCommand();
2229 /* Clear any previous selection */
2231 aSel->setSelectedObjects( l1 );
2233 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2237 SMESHGUI_EXPORT CAM_Module* createModule()
2239 return new SMESHGUI();
2242 SMESHGUI_EXPORT char* getModuleVersion() {
2243 return (char*)SMESH_VERSION_STR;
2247 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2249 //=============================================================================
2253 //=============================================================================
2254 SMESHGUI::SMESHGUI() : SalomeApp_Module( "SMESH" )
2256 if ( CORBA::is_nil( myComponentSMESH ) )
2258 CORBA::Boolean anIsEmbeddedMode;
2259 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2261 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2263 // 0019923: EDF 765 SMESH : default values of hypothesis
2264 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2265 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2266 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2267 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2268 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2270 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2271 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2272 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2274 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2275 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2279 myActiveDialogBox = 0;
2280 myFilterLibraryDlg = 0;
2284 myEventCallbackCommand = vtkCallbackCommand::New();
2285 myEventCallbackCommand->Delete();
2286 myEventCallbackCommand->SetClientData( this );
2287 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2290 /* load resources for all available meshers */
2291 SMESH::InitAvailableHypotheses();
2294 //=============================================================================
2298 //=============================================================================
2299 SMESHGUI::~SMESHGUI()
2303 //=============================================================================
2307 //=============================================================================
2308 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2310 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2312 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2317 //=============================================================================
2321 //=============================================================================
2322 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2324 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2328 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2329 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2330 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2331 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2332 return autoUpdate && !exceeded;
2335 //=============================================================================
2339 //=============================================================================
2340 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2341 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2343 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2347 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2348 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2349 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2351 SMESH::smIdType_array_var info = theMesh->GetMeshInfo();
2352 long nbOdElems = info[SMDSEntity_0D];
2353 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2354 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2355 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2356 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2357 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2358 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2359 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2360 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2361 info[SMDSEntity_Polyhedra] +
2362 info[SMDSEntity_Hexagonal_Prism];
2363 long nbBalls = info[SMDSEntity_Ball];
2365 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2366 *nbElements = requestedSize;
2368 *entities = SMESH_Actor::eAllEntity;
2371 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2373 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2375 if ( incrementalLimit ) {
2378 if ( nbOdElems > 0 ) {
2379 if ( total + nbOdElems > updateLimit ) {
2380 *entities = *entities & ~SMESH_Actor::e0DElements;
2381 *hidden = *hidden | SMESH_Actor::e0DElements;
2388 if ( nbEdges > 0 ) {
2389 if ( total + nbEdges > updateLimit ) {
2390 *entities = *entities & ~SMESH_Actor::eEdges;
2391 *hidden = *hidden | SMESH_Actor::eEdges;
2398 if ( nbFaces > 0 ) {
2399 if ( total + nbFaces > updateLimit ) {
2400 *entities = *entities & ~SMESH_Actor::eFaces;
2401 *hidden = *hidden | SMESH_Actor::eFaces;
2408 if ( nbVolumes > 0 ) {
2409 if ( total + nbVolumes > updateLimit ) {
2410 *entities = *entities & ~SMESH_Actor::eVolumes;
2411 *hidden = *hidden | SMESH_Actor::eVolumes;
2418 if ( nbBalls > 0 ) {
2419 if ( total + nbBalls > updateLimit ) {
2420 *entities = *entities & ~SMESH_Actor::eBallElem;
2421 *hidden = *hidden | SMESH_Actor::eBallElem;
2429 return autoUpdate && !exceeded;
2432 //=============================================================================
2436 //=============================================================================
2437 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2439 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2442 //=============================================================================
2446 //=============================================================================
2447 SMESHGUI* SMESHGUI::GetSMESHGUI()
2449 SMESHGUI* smeshMod = 0;
2450 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2453 CAM_Module* module = app->module( "Mesh" );
2454 smeshMod = dynamic_cast<SMESHGUI*>( module );
2462 Standard_EXPORT SMESHGUI* GetComponentGUI()
2464 return SMESHGUI::GetSMESHGUI();
2468 //=============================================================================
2472 //=============================================================================
2473 void SMESHGUI::SetState(int aState)
2478 //=============================================================================
2482 //=============================================================================
2483 void SMESHGUI::ResetState()
2488 //=============================================================================
2492 //=============================================================================
2493 void SMESHGUI::EmitSignalDeactivateDialog()
2495 emit SignalDeactivateActiveDialog();
2498 //=============================================================================
2502 //=============================================================================
2503 void SMESHGUI::EmitSignalStudyFrameChanged()
2505 emit SignalStudyFrameChanged();
2508 //=============================================================================
2512 //=============================================================================
2513 void SMESHGUI::EmitSignalCloseAllDialogs()
2515 emit SignalCloseAllDialogs();
2518 //=============================================================================
2522 //=============================================================================
2523 void SMESHGUI::EmitSignalVisibilityChanged()
2525 emit SignalVisibilityChanged();
2528 //=============================================================================
2532 //=============================================================================
2533 void SMESHGUI::EmitSignalCloseView()
2535 emit SignalCloseView();
2538 //=============================================================================
2542 //=============================================================================
2543 void SMESHGUI::EmitSignalActivatedViewManager()
2545 emit SignalActivatedViewManager();
2548 //=============================================================================
2552 //=============================================================================
2553 QDialog *SMESHGUI::GetActiveDialogBox()
2555 return myActiveDialogBox;
2558 //=============================================================================
2562 //=============================================================================
2563 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2565 myActiveDialogBox = (QDialog *) aDlg;
2569 //=============================================================================
2573 //=============================================================================
2574 SUIT_Desktop* SMESHGUI::desktop()
2576 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2578 return app->desktop();
2583 //=============================================================================
2587 //=============================================================================
2588 SalomeApp_Study* SMESHGUI::activeStudy()
2590 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2592 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2597 //=============================================================================
2601 //=============================================================================
2602 void SMESHGUI::Modified( bool theIsUpdateActions )
2604 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2605 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2606 appStudy->Modified();
2607 if( theIsUpdateActions )
2608 app->updateActions();
2613 //=============================================================================
2617 //=============================================================================
2618 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2620 /* Here the position is on the bottom right corner - 10 */
2621 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2623 SUIT_Desktop *PP = desktop();
2624 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2625 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2630 * \brief Verifies whether study of operation is locked
2631 * \param theMess - specifies whether message box must be shown if study is locked
2632 * \return State of study.
2634 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2635 * is locked when corresponding message box appears
2637 bool SMESHGUI::isStudyLocked( bool theMessage )
2639 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2642 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2643 QObject::tr( "WRN_WARNING" ),
2644 QObject::tr( "WRN_STUDY_LOCKED" ) );
2650 //=============================================================================
2654 //=============================================================================
2655 bool SMESHGUI::OnGUIEvent( int theCommandID )
2657 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2661 SUIT_ResourceMgr* mgr = resourceMgr();
2665 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2666 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2668 //QAction* act = action( theCommandID );
2669 bool logAction(false);
2671 switch (theCommandID) {
2672 case SMESHOp::OpDelete:
2673 if(isStudyLocked()) break;
2676 case SMESHOp::OpImportDAT:
2677 case SMESHOp::OpImportUNV:
2678 case SMESHOp::OpImportMED:
2679 case SMESHOp::OpImportSTL:
2680 case SMESHOp::OpImportCGNS:
2681 case SMESHOp::OpImportGMF:
2682 case SMESHOp::OpImportMESHIO:
2683 case SMESHOp::OpPopupImportDAT:
2684 case SMESHOp::OpPopupImportUNV:
2685 case SMESHOp::OpPopupImportMED:
2686 case SMESHOp::OpPopupImportSTL:
2687 case SMESHOp::OpPopupImportCGNS:
2688 case SMESHOp::OpPopupImportGMF:
2690 if(isStudyLocked()) break;
2691 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2695 case SMESHOp::OpFileInformation:
2697 SALOME_ListIO selected;
2698 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2700 aSel->selectedObjects( selected );
2701 if( selected.Extent() )
2703 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2704 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2705 if ( !aMesh->_is_nil() )
2707 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2713 case SMESHOp::OpExportDAT:
2714 case SMESHOp::OpExportMED:
2715 case SMESHOp::OpExportUNV:
2716 case SMESHOp::OpExportSTL:
2717 case SMESHOp::OpExportCGNS:
2718 case SMESHOp::OpExportGMF:
2719 case SMESHOp::OpExportMESHIO:
2720 case SMESHOp::OpPopupExportDAT:
2721 case SMESHOp::OpPopupExportMED:
2722 case SMESHOp::OpPopupExportUNV:
2723 case SMESHOp::OpPopupExportSTL:
2724 case SMESHOp::OpPopupExportCGNS:
2725 case SMESHOp::OpPopupExportGMF:
2727 ::ExportMeshToFile(theCommandID);
2731 case SMESHOp::OpReset: // SCALAR BAR
2733 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2734 SALOME_ListIO selected;
2736 aSel->selectedObjects( selected );
2738 SALOME_ListIteratorOfListIO it(selected);
2739 for( ; it.More(); it.Next()) {
2740 Handle(SALOME_InteractiveObject) anIO = it.Value();
2741 if( anIO->hasEntry() ) {
2742 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2743 anActor->SetControlMode( SMESH_Actor::eNone );
2744 #ifndef DISABLE_PLOT2DVIEWER
2745 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2747 anActor->UpdateFilter();
2751 SMESH::UpdateView();
2754 case SMESHOp::OpScalarBarProperties:
2756 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2759 case SMESHOp::OpShowScalarBar:
2761 // show/hide scalar bar
2762 ::ShowElement(theCommandID);
2765 case SMESHOp::OpSaveDistribution:
2767 // dump control distribution data to the text file
2768 ::SaveDistribution();
2772 case SMESHOp::OpShowDistribution:
2774 // show/hide distribution
2775 ::ShowElement(theCommandID);
2779 #ifndef DISABLE_PLOT2DVIEWER
2780 case SMESHOp::OpPlotDistribution:
2782 // plot distribution
2783 ::PlotDistribution();
2789 case SMESHOp::OpAutoColor:
2793 case SMESHOp::OpDisableAutoColor:
2794 ::DisableAutoColor();
2797 case SMESHOp::OpClipping:
2798 case SMESHOp::OpTransparency:
2799 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2802 case SMESHOp::OpDMWireframe:
2803 case SMESHOp::OpDMShading:
2804 case SMESHOp::OpDMNodes:
2805 case SMESHOp::OpDMShrink:
2806 ::SetDisplayMode(theCommandID, myMarkerMap);
2809 //2D quadratic representation
2810 case SMESHOp::OpRepresentationLines:
2811 case SMESHOp::OpRepresentationArcs:
2812 ::SetDisplayMode(theCommandID, myMarkerMap);
2816 case SMESHOp::OpDE0DElements:
2817 case SMESHOp::OpDEEdges:
2818 case SMESHOp::OpDEFaces:
2819 case SMESHOp::OpDEVolumes:
2820 case SMESHOp::OpDEBalls:
2821 case SMESHOp::OpDEAllEntity:
2822 ::SetDisplayEntity(theCommandID);
2825 // Choose entities to be displayed
2826 case SMESHOp::OpDEChoose:
2828 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2832 case SMESHOp::OpOrientationOnFaces:
2834 SUIT_OverrideCursor wc;
2835 LightApp_SelectionMgr* mgr = selectionMgr();
2836 SALOME_ListIO selected; mgr->selectedObjects( selected );
2838 SALOME_ListIteratorOfListIO it(selected);
2839 for( ; it.More(); it.Next()) {
2840 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2841 if(anIObject->hasEntry()) {
2842 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2843 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2850 case SMESHOp::OpUpdate:
2852 if(isStudyLocked()) break;
2853 SUIT_OverrideCursor wc;
2856 SMESH::UpdateView();
2858 catch (std::bad_alloc&) { // PAL16774 (Crash after display of many groups)
2859 SMESH::OnVisuException();
2861 catch (...) { // PAL16774 (Crash after display of many groups)
2862 SMESH::OnVisuException();
2866 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2867 aSel->selectedObjects( l );
2868 aSel->setSelectedObjects( l );
2872 case SMESHOp::OpHide:
2873 case SMESHOp::OpShow:
2874 case SMESHOp::OpShowOnly:
2876 SUIT_OverrideCursor wc;
2877 SMESH::EDisplaing anAction;
2878 switch (theCommandID) {
2879 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2880 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2881 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2884 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2885 SALOME_ListIO sel_objects, to_process;
2887 aSel->selectedObjects( sel_objects );
2889 if ( theCommandID==SMESHOp::OpShowOnly )
2891 //MESSAGE("anAction = SMESH::eDisplayOnly");
2892 startOperation( myEraseAll );
2895 extractContainers( sel_objects, to_process );
2900 SALOME_ListIteratorOfListIO It( to_process );
2901 for ( ; It.More(); It.Next())
2903 Handle(SALOME_InteractiveObject) IOS = It.Value();
2904 if ( IOS->hasEntry() )
2906 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2907 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2908 break; // PAL16774 (Crash after display of many groups)
2910 if (anAction == SMESH::eDisplayOnly)
2911 anAction = SMESH::eDisplay;
2916 // PAL13338 + PAL15161 -->
2917 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2918 SMESH::UpdateView();
2919 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2921 // PAL13338 + PAL15161 <--
2923 catch (...) { // PAL16774 (Crash after display of many groups)
2924 SMESH::OnVisuException();
2927 if (anAction == SMESH::eErase) {
2929 aSel->setSelectedObjects( l1 );
2932 aSel->setSelectedObjects( to_process );
2934 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2935 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2936 vtkwnd->GetRenderer()->AdjustActors();
2941 case SMESHOp::OpNode:
2943 if(isStudyLocked()) break;
2946 EmitSignalDeactivateDialog();
2948 ( new SMESHGUI_NodesDlg( this ) )->show();
2951 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2956 case SMESHOp::OpEditMeshOrSubMesh:
2957 case SMESHOp::OpEditMesh:
2958 case SMESHOp::OpEditSubMesh:
2959 case SMESHOp::OpMeshOrder:
2960 case SMESHOp::OpCreateSubMesh:
2961 if ( warnOnGeomModif() )
2962 break; // action forbidden as geometry modified
2964 case SMESHOp::OpCreateMesh:
2965 case SMESHOp::OpCompute:
2966 case SMESHOp::OpComputeSubMesh:
2967 case SMESHOp::OpPreCompute:
2968 case SMESHOp::OpEvaluate:
2969 case SMESHOp::OpShowErrors:
2970 startOperation( theCommandID );
2972 case SMESHOp::OpRecompute:
2974 if ( isStudyLocked() )
2976 SALOME_ListIO selected;
2977 if ( LightApp_SelectionMgr *sel = selectionMgr() )
2978 sel->selectedObjects( selected );
2979 if ( selected.Extent() == 1 ) {
2980 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( selected.First() );
2981 if ( !aMesh->_is_nil() )
2983 startOperation( SMESHOp::OpCompute );
2987 case SMESHOp::OpCopyMesh:
2990 if (isStudyLocked()) break;
2991 EmitSignalDeactivateDialog();
2992 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2995 case SMESHOp::OpBuildCompoundMesh:
2997 if (isStudyLocked()) break;
2998 EmitSignalDeactivateDialog();
2999 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
3003 case SMESHOp::OpDiagonalInversion:
3004 case SMESHOp::OpUnionOfTwoTriangle:
3008 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
3012 if ( isStudyLocked() )
3014 if ( warnOnGeomModif() )
3015 break; // action forbidden as geometry modified
3017 /*Standard_Boolean aRes;
3018 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
3019 if ( aMesh->_is_nil() )
3021 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
3022 tr( "SMESH_BAD_SELECTION" ) );
3026 EmitSignalDeactivateDialog();
3027 if ( theCommandID == SMESHOp::OpDiagonalInversion )
3028 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
3030 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
3033 case SMESHOp::OpOrientation:
3034 case SMESHOp::OpUnionOfTriangles:
3035 case SMESHOp::OpCuttingOfQuadrangles:
3036 case SMESHOp::OpSplitVolumes:
3040 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
3044 if ( isStudyLocked() )
3046 if ( warnOnGeomModif() )
3047 break; // action forbidden as geometry modified
3049 EmitSignalDeactivateDialog();
3050 SMESHGUI_MultiEditDlg* aDlg = NULL;
3051 if ( theCommandID == SMESHOp::OpOrientation )
3052 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
3053 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
3054 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
3055 else if ( theCommandID == SMESHOp::OpSplitVolumes )
3056 aDlg = new SMESHGUI_SplitVolumesDlg(this);
3058 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
3063 case SMESHOp::OpSmoothing:
3065 if(isStudyLocked()) break;
3066 if ( warnOnGeomModif() )
3067 break; // action forbidden as geometry modified
3069 EmitSignalDeactivateDialog();
3070 ( new SMESHGUI_SmoothingDlg( this ) )->show();
3073 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3077 case SMESHOp::OpExtrusion:
3079 if (isStudyLocked()) break;
3080 if ( warnOnGeomModif() )
3081 break; // action forbidden as geometry modified
3083 EmitSignalDeactivateDialog();
3084 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
3086 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3090 case SMESHOp::OpExtrusionAlongAPath:
3092 if (isStudyLocked()) break;
3093 if ( warnOnGeomModif() )
3094 break; // action forbidden as geometry modified
3096 EmitSignalDeactivateDialog();
3097 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
3099 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3103 case SMESHOp::OpRevolution:
3105 if(isStudyLocked()) break;
3106 if ( warnOnGeomModif() )
3107 break; // action forbidden as geometry modified
3109 EmitSignalDeactivateDialog();
3110 ( new SMESHGUI_RevolutionDlg( this ) )->show();
3113 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3117 case SMESHOp::OpPatternMapping:
3119 if ( isStudyLocked() )
3121 if ( warnOnGeomModif() )
3122 break; // action forbidden as geometry modified
3125 EmitSignalDeactivateDialog();
3126 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
3129 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3133 // Adaptation - begin
3134 #ifndef DISABLE_MG_ADAPT
3135 case SMESHOp::OpMGAdapt:
3137 if ( isStudyLocked() )
3139 EmitSignalDeactivateDialog();
3141 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model = GetSMESHGen()->CreateMG_ADAPT();
3142 bool isCreation = false;
3143 ( new SMESHGUI_MG_ADAPTDRIVER( this, model, isCreation ))->show();
3147 #ifndef DISABLE_HOMARD_ADAPT
3148 case SMESHOp::OpHomardAdapt:
3150 if ( isStudyLocked() )
3152 EmitSignalDeactivateDialog();
3154 SALOME::GenericObj_wrap< SMESHHOMARD::HOMARD_Gen > homardGen;
3156 homardGen = GetSMESHGen()->CreateHOMARD_ADAPT();
3158 catch ( const SALOME::SALOME_Exception& S_ex ) {
3159 SUIT_MessageBox::critical(SMESHGUI::desktop(),
3160 QObject::tr("SMESH_ERROR"),
3161 QObject::tr(S_ex.details.text.in()));
3163 if (!homardGen->_is_nil()) {
3164 SMESHGUI_HomardAdaptDlg *aDlg = new SMESHGUI_HomardAdaptDlg(homardGen);
3171 case SMESHOp::OpSplitBiQuadratic:
3172 case SMESHOp::OpConvertMeshToQuadratic:
3173 case SMESHOp::OpCreateDualMesh:
3174 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
3175 case SMESHOp::OpCreate2DElements: // create full 2D mesh from 3D
3176 case SMESHOp::OpReorientFaces:
3177 case SMESHOp::OpCreateGeometryGroup:
3179 if ( warnOnGeomModif() )
3180 break; // action forbidden as geometry modified
3181 startOperation( theCommandID );
3184 case SMESHOp::OpCreateGroup:
3188 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3192 if(isStudyLocked()) break;
3193 if ( warnOnGeomModif() )
3194 break; // action forbidden as geometry modified
3195 EmitSignalDeactivateDialog();
3196 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
3198 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3199 SALOME_ListIO selected;
3201 aSel->selectedObjects( selected );
3203 int nbSel = selected.Extent();
3205 // check if mesh is selected
3206 aMesh = SMESH::GetMeshByIO( selected.First() );
3208 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
3213 case SMESHOp::OpConstructGroup:
3217 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3221 if(isStudyLocked()) break;
3222 if ( warnOnGeomModif() )
3223 break; // action forbidden as geometry modified
3224 EmitSignalDeactivateDialog();
3226 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3227 SALOME_ListIO selected;
3229 aSel->selectedObjects( selected );
3231 int nbSel = selected.Extent();
3233 // check if submesh is selected
3234 Handle(SALOME_InteractiveObject) IObject = selected.First();
3235 if (IObject->hasEntry()) {
3236 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
3238 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
3239 if (!aSubMesh->_is_nil()) {
3241 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
3242 // get submesh elements list by types
3243 SMESH::smIdType_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
3244 SMESH::smIdType_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
3245 SMESH::smIdType_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
3246 SMESH::smIdType_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
3247 // create group for each type o elements
3248 QString aName = IObject->getName();
3249 QStringList anEntryList;
3250 if (aNodes->length() > 0) {
3251 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
3252 aGroup->Add(aNodes.inout());
3253 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3254 anEntryList.append( aSObject->GetID().c_str() );
3256 if (aEdges->length() > 0) {
3257 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
3258 aGroup->Add(aEdges.inout());
3259 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3260 anEntryList.append( aSObject->GetID().c_str() );
3262 if (aFaces->length() > 0) {
3263 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
3264 aGroup->Add(aFaces.inout());
3265 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3266 anEntryList.append( aSObject->GetID().c_str() );
3268 if (aVolumes->length() > 0) {
3269 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
3270 aGroup->Add(aVolumes.inout());
3271 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
3272 anEntryList.append( aSObject->GetID().c_str() );
3275 anApp->browseObjects( anEntryList );
3277 catch(const SALOME::SALOME_Exception & S_ex){
3278 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3285 SUIT_MessageBox::warning(desktop(),
3286 tr("SMESH_WRN_WARNING"),
3287 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3292 case SMESHOp::OpEditGroup:
3296 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3300 if(isStudyLocked()) break;
3301 if ( warnOnGeomModif() )
3302 break; // action forbidden as geometry modified
3303 EmitSignalDeactivateDialog();
3305 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3306 SALOME_ListIO selected;
3308 aSel->selectedObjects( selected );
3310 SALOME_ListIteratorOfListIO It (selected);
3311 int nbSelectedGroups = 0;
3312 for ( ; It.More(); It.Next() )
3314 SMESH::SMESH_GroupBase_var aGroup =
3315 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3316 if (!aGroup->_is_nil()) {
3318 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3322 if (nbSelectedGroups == 0)
3324 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3330 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3332 if(isStudyLocked()) break;
3333 if (myState == 800) {
3334 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3335 if (aDlg) aDlg->onAdd();
3340 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3342 if(isStudyLocked()) break;
3343 if (myState == 800) {
3344 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3345 if (aDlg) aDlg->onRemove();
3350 case SMESHOp::OpEditGeomGroupAsGroup:
3354 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3358 if(isStudyLocked()) break;
3359 EmitSignalDeactivateDialog();
3361 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3362 SALOME_ListIO selected;
3364 aSel->selectedObjects( selected );
3366 SALOME_ListIteratorOfListIO It (selected);
3367 for ( ; It.More(); It.Next() )
3369 SMESH::SMESH_GroupOnGeom_var aGroup =
3370 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3371 if (!aGroup->_is_nil()) {
3372 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3377 SMESH::SMESH_GroupOnFilter_var aGroup =
3378 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3379 if (!aGroup->_is_nil()) {
3380 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3388 case SMESHOp::OpUnionGroups:
3389 case SMESHOp::OpIntersectGroups:
3390 case SMESHOp::OpCutGroups:
3394 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3398 if ( isStudyLocked() )
3400 if ( warnOnGeomModif() )
3401 break; // action forbidden as geometry modified
3403 EmitSignalDeactivateDialog();
3405 SMESHGUI_GroupOpDlg* aDlg = 0;
3406 if ( theCommandID == SMESHOp::OpUnionGroups )
3407 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3408 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3409 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3411 aDlg = new SMESHGUI_CutGroupsDlg( this );
3418 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3420 if ( isStudyLocked() )
3422 if ( warnOnGeomModif() )
3423 break; // action forbidden as geometry modified
3425 EmitSignalDeactivateDialog();
3426 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3432 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3434 if ( isStudyLocked() )
3436 if ( warnOnGeomModif() )
3437 break; // action forbidden as geometry modified
3439 EmitSignalDeactivateDialog();
3440 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3446 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3450 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3454 if ( isStudyLocked() )
3457 EmitSignalDeactivateDialog();
3459 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3463 case SMESHOp::OpMeshInformation:
3464 case SMESHOp::OpWhatIs:
3466 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3467 EmitSignalDeactivateDialog();
3468 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3469 SALOME_ListIO selected;
3471 aSel->selectedObjects( selected );
3473 if ( selected.Extent() > 1 ) { // a dlg for each IO
3474 SALOME_ListIteratorOfListIO It( selected );
3475 for ( ; It.More(); It.Next() ) {
3476 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3477 dlg->showInfo( It.Value() );
3482 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3488 case SMESHOp::OpFindElementByPoint:
3490 startOperation( theCommandID );
3494 case SMESHOp::OpEditHypothesis:
3496 if(isStudyLocked()) break;
3497 if ( warnOnGeomModif() )
3498 break; // action forbidden as geometry modified
3500 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3501 SALOME_ListIO selected;
3503 aSel->selectedObjects( selected );
3505 int nbSel = selected.Extent();
3508 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3509 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3511 if ( !aHypothesis->_is_nil() )
3513 SMESHGUI_GenericHypothesisCreator* aCreator =
3514 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3517 // set geometry of mesh and sub-mesh to aCreator
3518 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3519 if ( selected.Extent() == 1 )
3521 QString subGeomID, meshGeomID;
3522 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3523 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3525 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3526 aCreator->setShapeEntry( subGeomID );
3527 aCreator->setMainShapeEntry( meshGeomID );
3531 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3541 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3543 if(isStudyLocked()) break;
3544 if ( warnOnGeomModif() )
3545 break; // action forbidden as geometry modified
3546 SUIT_OverrideCursor wc;
3548 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3549 SALOME_ListIO selected;
3551 aSel->selectedObjects( selected, QString::null, false );
3553 SALOME_ListIteratorOfListIO It(selected);
3554 for (int i = 0; It.More(); It.Next(), i++) {
3555 Handle(SALOME_InteractiveObject) IObject = It.Value();
3556 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3559 aSel->setSelectedObjects( l1 );
3564 case SMESHOp::OpElem0D:
3565 case SMESHOp::OpBall:
3566 case SMESHOp::OpEdge:
3567 case SMESHOp::OpTriangle:
3568 case SMESHOp::OpQuadrangle:
3569 case SMESHOp::OpPolygon:
3570 case SMESHOp::OpTetrahedron:
3571 case SMESHOp::OpHexahedron:
3572 case SMESHOp::OpPentahedron:
3573 case SMESHOp::OpPyramid:
3574 case SMESHOp::OpHexagonalPrism:
3576 if(isStudyLocked()) break;
3577 if ( warnOnGeomModif() )
3578 break; // action forbidden as geometry modified
3580 EmitSignalDeactivateDialog();
3581 SMDSAbs_EntityType type = SMDSEntity_Edge;
3582 switch (theCommandID) {
3583 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3584 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3585 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3586 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3587 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3588 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3589 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3590 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3591 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3592 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3595 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3598 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3602 case SMESHOp::OpPolyhedron:
3604 if(isStudyLocked()) break;
3605 if ( warnOnGeomModif() )
3606 break; // action forbidden as geometry modified
3608 EmitSignalDeactivateDialog();
3609 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3612 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3616 case SMESHOp::OpQuadraticEdge:
3617 case SMESHOp::OpQuadraticTriangle:
3618 case SMESHOp::OpBiQuadraticTriangle:
3619 case SMESHOp::OpQuadraticQuadrangle:
3620 case SMESHOp::OpBiQuadraticQuadrangle:
3621 case SMESHOp::OpQuadraticPolygon:
3622 case SMESHOp::OpQuadraticTetrahedron:
3623 case SMESHOp::OpQuadraticPyramid:
3624 case SMESHOp::OpQuadraticPentahedron:
3625 case SMESHOp::OpBiQuadraticPentahedron:
3626 case SMESHOp::OpQuadraticHexahedron:
3627 case SMESHOp::OpTriQuadraticHexahedron:
3629 if(isStudyLocked()) break;
3630 if ( warnOnGeomModif() )
3631 break; // action forbidden as geometry modified
3633 EmitSignalDeactivateDialog();
3634 SMDSAbs_EntityType type = SMDSEntity_Last;
3636 switch (theCommandID) {
3637 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3638 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3639 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3640 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3641 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3642 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3643 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3644 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3645 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3646 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3647 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3648 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3651 if ( type != SMDSEntity_Last )
3652 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3655 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3656 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3660 case SMESHOp::OpRemoveNodes:
3662 if(isStudyLocked()) break;
3663 if ( warnOnGeomModif() )
3664 break; // action forbidden as geometry modified
3666 EmitSignalDeactivateDialog();
3667 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3670 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3671 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3675 case SMESHOp::OpRemoveNodeWithReconn:
3677 if(isStudyLocked()) break;
3678 if ( warnOnGeomModif() )
3679 break; // action forbidden as geometry modified
3680 startOperation( SMESHOp::OpRemoveNodeWithReconn );
3683 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3685 if(isStudyLocked()) break;
3686 if ( warnOnGeomModif() )
3687 break; // action forbidden as geometry modified
3689 EmitSignalDeactivateDialog();
3690 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3694 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3695 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3699 case SMESHOp::OpClearMesh: {
3701 if(isStudyLocked()) break;
3702 if ( warnOnGeomModif() )
3703 break; // action forbidden as geometry modified
3705 SALOME_ListIO selected;
3706 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3707 aSel->selectedObjects( selected );
3709 SUIT_OverrideCursor wc;
3710 SALOME_ListIteratorOfListIO It (selected);
3711 for ( ; It.More(); It.Next() )
3713 Handle(SALOME_InteractiveObject) IOS = It.Value();
3714 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3715 if ( aMesh->_is_nil()) continue;
3718 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3719 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3720 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3721 // hide groups and submeshes
3722 _PTR(ChildIterator) anIter =
3723 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3724 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3726 _PTR(SObject) so = anIter->Value();
3727 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3730 catch (const SALOME::SALOME_Exception& S_ex){
3732 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3736 SMESH::UpdateView();
3740 case SMESHOp::OpRemoveOrphanNodes:
3742 if(isStudyLocked()) break;
3743 if ( warnOnGeomModif() )
3744 break; // action forbidden as geometry modified
3745 SALOME_ListIO selected;
3746 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3747 aSel->selectedObjects( selected );
3748 if ( selected.Extent() == 1 ) {
3749 Handle(SALOME_InteractiveObject) anIO = selected.First();
3750 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3751 if ( !aMesh->_is_nil() ) {
3752 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3753 tr( "SMESH_WARNING" ),
3754 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3755 SUIT_MessageBox::Yes |
3756 SUIT_MessageBox::No,
3757 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3760 SUIT_OverrideCursor wc;
3761 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3762 smIdType removed = aMeshEditor->RemoveOrphanNodes();
3763 SUIT_MessageBox::information(SMESHGUI::desktop(),
3764 tr("SMESH_INFORMATION"),
3765 tr("NB_NODES_REMOVED").arg(removed));
3766 if ( removed > 0 ) {
3767 SMESH::UpdateView();
3768 SMESHGUI::Modified();
3771 catch (const SALOME::SALOME_Exception& S_ex) {
3772 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3781 case SMESHOp::OpRenumberingNodes:
3783 if(isStudyLocked()) break;
3784 if ( warnOnGeomModif() )
3785 break; // action forbidden as geometry modified
3787 EmitSignalDeactivateDialog();
3788 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3792 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3793 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3797 case SMESHOp::OpRenumberingElements:
3799 if(isStudyLocked()) break;
3800 if ( warnOnGeomModif() )
3801 break; // action forbidden as geometry modified
3803 EmitSignalDeactivateDialog();
3804 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3808 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3809 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3813 case SMESHOp::OpTranslation:
3816 if(isStudyLocked()) break;
3817 if ( warnOnGeomModif() )
3818 break; // action forbidden as geometry modified
3820 EmitSignalDeactivateDialog();
3821 ( new SMESHGUI_TranslationDlg( this ) )->show();
3824 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3825 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3829 case SMESHOp::OpRotation:
3832 if(isStudyLocked()) break;
3833 if ( warnOnGeomModif() )
3834 break; // action forbidden as geometry modified
3836 EmitSignalDeactivateDialog();
3837 ( new SMESHGUI_RotationDlg( this ) )->show();
3840 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3841 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3845 case SMESHOp::OpSymmetry:
3848 if(isStudyLocked()) break;
3849 if ( warnOnGeomModif() )
3850 break; // action forbidden as geometry modified
3852 EmitSignalDeactivateDialog();
3853 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3856 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3857 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3861 case SMESHOp::OpScale:
3864 if(isStudyLocked()) break;
3865 if ( warnOnGeomModif() )
3866 break; // action forbidden as geometry modified
3868 EmitSignalDeactivateDialog();
3869 ( new SMESHGUI_ScaleDlg( this ) )->show();
3872 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3873 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3878 case SMESHOp::OpOffset:
3881 if(isStudyLocked()) break;
3882 if ( warnOnGeomModif() )
3883 break; // action forbidden as geometry modified
3885 EmitSignalDeactivateDialog();
3886 ( new SMESHGUI_OffsetDlg( this ) )->show();
3889 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3890 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3895 case SMESHOp::OpSewing:
3898 if(isStudyLocked()) break;
3899 if ( warnOnGeomModif() )
3900 break; // action forbidden as geometry modified
3902 EmitSignalDeactivateDialog();
3903 ( new SMESHGUI_SewingDlg( this ) )->show();
3906 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3907 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3911 case SMESHOp::OpMergeNodes:
3913 if(isStudyLocked()) break;
3914 if ( warnOnGeomModif() )
3915 break; // action forbidden as geometry modified
3917 EmitSignalDeactivateDialog();
3918 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3921 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3922 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3926 case SMESHOp::OpMergeElements:
3928 if (isStudyLocked()) break;
3929 if ( warnOnGeomModif() )
3930 break; // action forbidden as geometry modified
3932 EmitSignalDeactivateDialog();
3933 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3935 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3936 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3941 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3942 if ( warnOnGeomModif() )
3943 break; // action forbidden as geometry modified
3944 startOperation( SMESHOp::OpMoveNode );
3947 case SMESHOp::OpMoveNodeInteractive:
3948 if ( warnOnGeomModif() )
3949 break; // action forbidden as geometry modified
3950 startOperation( SMESHOp::OpMoveNodeInteractive );
3953 case SMESHOp::OpSplitEdgeInteract:
3954 if ( warnOnGeomModif() )
3955 break; // action forbidden as geometry modified
3956 startOperation( SMESHOp::OpSplitEdgeInteract );
3959 case SMESHOp::OpSplitFaceInteract:
3960 if ( warnOnGeomModif() )
3961 break; // action forbidden as geometry modified
3962 startOperation( SMESHOp::OpSplitFaceInteract );
3965 case SMESHOp::OpDuplicateNodes:
3967 if(isStudyLocked()) break;
3968 if ( warnOnGeomModif() )
3969 break; // action forbidden as geometry modified
3971 EmitSignalDeactivateDialog();
3972 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3975 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3976 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3981 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3982 if ( warnOnGeomModif() )
3983 break; // action forbidden as geometry modified
3984 startOperation( SMESHOp::OpElem0DOnElemNodes );
3987 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3989 static QList<int> aTypes;
3990 if ( aTypes.isEmpty() )
3992 aTypes.append( SMESH::NODE );
3993 aTypes.append( SMESH::EDGE );
3994 aTypes.append( SMESH::FACE );
3995 aTypes.append( SMESH::VOLUME );
3997 if (!myFilterLibraryDlg)
3998 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3999 else if (myFilterLibraryDlg->isHidden())
4000 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
4001 myFilterLibraryDlg->raise();
4005 case SMESHOp::OpFreeNode:
4006 case SMESHOp::OpEqualNode:
4007 case SMESHOp::OpNodeConnectivityNb:
4008 case SMESHOp::OpFreeEdge:
4009 case SMESHOp::OpFreeBorder:
4010 case SMESHOp::OpLength:
4011 case SMESHOp::OpConnection:
4012 case SMESHOp::OpEqualEdge:
4013 case SMESHOp::OpFreeFace:
4014 case SMESHOp::OpBareBorderFace:
4015 case SMESHOp::OpOverConstrainedFace:
4016 case SMESHOp::OpLength2D:
4017 case SMESHOp::OpDeflection2D:
4018 case SMESHOp::OpConnection2D:
4019 case SMESHOp::OpArea:
4020 case SMESHOp::OpTaper:
4021 case SMESHOp::OpAspectRatio:
4022 case SMESHOp::OpMinimumAngle:
4023 case SMESHOp::OpWarpingAngle:
4024 case SMESHOp::OpSkew:
4025 case SMESHOp::OpMaxElementLength2D:
4026 case SMESHOp::OpEqualFace:
4027 case SMESHOp::OpAspectRatio3D:
4028 case SMESHOp::OpWarping3D:
4029 case SMESHOp::OpVolume:
4030 case SMESHOp::OpScaledJacobian:
4031 case SMESHOp::OpMaxElementLength3D:
4032 case SMESHOp::OpBareBorderVolume:
4033 case SMESHOp::OpOverConstrainedVolume:
4034 case SMESHOp::OpEqualVolume:
4037 LightApp_SelectionMgr* mgr = selectionMgr();
4038 SALOME_ListIO selected; mgr->selectedObjects( selected );
4040 if( !selected.IsEmpty() ) {
4041 SUIT_OverrideCursor wc;
4042 ::Control( theCommandID );
4045 SUIT_MessageBox::warning(desktop(),
4046 tr( "SMESH_WRN_WARNING" ),
4047 tr( "SMESH_BAD_SELECTION" ) );
4051 SUIT_MessageBox::warning(desktop(),
4052 tr( "SMESH_WRN_WARNING" ),
4053 tr( "NOT_A_VTK_VIEWER" ) );
4056 case SMESHOp::OpOverallMeshQuality:
4057 OverallMeshQuality();
4059 case SMESHOp::OpNumberingNodes:
4061 SUIT_OverrideCursor wc;
4062 LightApp_SelectionMgr* mgr = selectionMgr();
4063 SALOME_ListIO selected; mgr->selectedObjects( selected );
4065 SALOME_ListIteratorOfListIO it(selected);
4066 for( ; it.More(); it.Next()) {
4067 Handle(SALOME_InteractiveObject) anIObject = it.Value();
4068 if(anIObject->hasEntry()) {
4069 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
4070 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
4076 case SMESHOp::OpNumberingElements:
4078 SUIT_OverrideCursor wc;
4079 LightApp_SelectionMgr* mgr = selectionMgr();
4080 SALOME_ListIO selected; mgr->selectedObjects( selected );
4082 SALOME_ListIteratorOfListIO it(selected);
4083 for( ; it.More(); it.Next()) {
4084 Handle(SALOME_InteractiveObject) anIObject = it.Value();
4085 if(anIObject->hasEntry())
4086 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
4087 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
4092 case SMESHOp::OpPropertiesLength:
4093 case SMESHOp::OpPropertiesArea:
4094 case SMESHOp::OpPropertiesVolume:
4095 case SMESHOp::OpMinimumDistance:
4096 case SMESHOp::OpBoundingBox:
4097 case SMESHOp::OpAngle:
4099 int page = SMESHGUI_MeasureDlg::MinDistance;
4100 if ( theCommandID == SMESHOp::OpBoundingBox )
4101 page = SMESHGUI_MeasureDlg::BoundingBox;
4102 else if ( theCommandID == SMESHOp::OpPropertiesLength )
4103 page = SMESHGUI_MeasureDlg::Length;
4104 else if ( theCommandID == SMESHOp::OpPropertiesArea )
4105 page = SMESHGUI_MeasureDlg::Area;
4106 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
4107 page = SMESHGUI_MeasureDlg::Volume;
4108 else if ( theCommandID == SMESHOp::OpAngle )
4109 page = SMESHGUI_MeasureDlg::Angle;
4111 EmitSignalDeactivateDialog();
4112 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
4116 case SMESHOp::OpSortChild:
4119 case SMESHOp::OpBreakLink:
4120 ::breakShaperLink();
4125 anApp->updateActions(); //SRN: To update a Save button in the toolbar
4126 //updateObjBrowser();
4129 QAction* anAction = action( theCommandID );
4130 CAM_Application::logStructuredUserEvent( "Mesh",
4138 //=============================================================================
4142 //=============================================================================
4143 bool SMESHGUI::OnMousePress( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4148 //=============================================================================
4152 //=============================================================================
4153 bool SMESHGUI::OnMouseMove( QMouseEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4158 //=============================================================================
4162 //=============================================================================
4163 bool SMESHGUI::OnKeyPress( QKeyEvent * /*pe*/, SUIT_ViewWindow * /*wnd*/ )
4168 //=============================================================================
4169 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
4170 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
4172 //=============================================================================
4173 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
4174 SUIT_ViewWindow* wnd )
4176 if(theIO->hasEntry()){
4177 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
4178 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
4182 //=======================================================================
4183 // function : createSMESHAction
4185 //=======================================================================
4186 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
4187 const int key, const bool toggle, const QString& shortcutAction )
4190 QWidget* parent = application()->desktop();
4191 SUIT_ResourceMgr* resMgr = resourceMgr();
4193 if ( !icon_id.isEmpty() )
4194 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
4196 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
4197 if ( !pix.isNull() )
4198 icon = QIcon( pix );
4200 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
4201 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
4202 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
4204 createAction( id, tooltip, icon, menu, status_bar, key, parent,
4205 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
4208 //=======================================================================
4209 // function : createPopupItem
4211 //=======================================================================
4212 void SMESHGUI::createPopupItem( const int id,
4213 const QString& clients,
4214 const QString& types,
4215 const QString& theRule,
4218 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
4219 popupMgr()->insert( action( id ), pId, 0 );
4221 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4222 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4223 QString rule = "(%1) and (%2) and (%3)";
4224 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
4225 if( clients.isEmpty() )
4226 rule = rule.arg( QString( "true" ) );
4228 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
4229 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
4232 bool cont = myRules.contains( id );
4234 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
4236 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
4237 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
4240 //=======================================================================
4241 // function : initialize
4243 //=======================================================================
4244 void SMESHGUI::initialize( CAM_Application* app )
4246 SalomeApp_Module::initialize( app );
4248 // SUIT_ResourceMgr* mgr = app->resourceMgr();
4250 /* Automatic Update flag */
4251 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
4253 // ----- create actions --------------
4255 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
4256 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
4257 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
4258 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
4260 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
4262 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
4263 createSMESHAction( SMESHOp::OpImportMESHIO, "IMPORT_MESHIO" );
4264 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
4265 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
4266 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
4268 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
4270 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
4272 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
4273 createSMESHAction( SMESHOp::OpExportMED, "MED" );
4274 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
4275 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
4277 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
4279 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
4280 createSMESHAction( SMESHOp::OpExportMESHIO, "EXPORT_MESHIO" );
4281 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
4282 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
4283 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
4284 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
4286 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
4288 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
4289 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
4290 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
4291 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
4292 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
4293 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
4294 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
4295 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
4296 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
4297 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
4298 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
4299 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
4300 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
4301 createSMESHAction( SMESHOp::OpRecompute, "RE_COMPUTE", "ICON_COMPUTE" );
4302 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
4303 createSMESHAction( SMESHOp::OpShowErrors, "SHOW_ERRORS", "ICON_SHOW_ERRORS" );
4304 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
4305 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
4306 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
4307 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
4308 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
4309 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
4310 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
4311 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
4312 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
4313 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
4314 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
4315 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
4316 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
4317 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
4318 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
4319 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
4320 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
4321 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4322 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
4324 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
4325 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
4326 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
4327 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
4328 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
4329 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
4330 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
4331 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
4332 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
4333 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
4334 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
4335 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
4336 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
4337 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
4338 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
4339 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
4340 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
4341 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
4342 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
4343 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
4344 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
4345 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
4346 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
4347 createSMESHAction( SMESHOp::OpWarping3D, "WARP_3D", "ICON_WARP", 0, true);
4348 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
4349 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
4350 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
4351 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
4352 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
4353 createSMESHAction( SMESHOp::OpScaledJacobian, "SCALED_JACOBIAN", "ICON_SCALED_JACOBIAN", 0, true );
4354 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
4356 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
4357 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
4358 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
4359 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
4360 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
4361 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
4362 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
4363 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
4364 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
4365 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
4366 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
4367 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
4368 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
4369 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
4370 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
4371 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
4372 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
4373 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
4374 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
4375 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
4376 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
4377 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
4378 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
4379 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
4380 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
4381 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4383 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4384 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4385 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4386 createSMESHAction( SMESHOp::OpRemoveNodeWithReconn, "REMOVE_NODE_RECON", "ICON_REM_NODE_RECON" );
4387 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4389 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4390 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4392 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4393 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4394 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4395 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4396 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4397 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4398 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4399 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4400 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4401 createSMESHAction( SMESHOp::OpMoveNodeInteractive, "MOVE_NODE_INTRCT","ICON_DLG_MOVE_NODE_INTERACTIVE" );
4402 createSMESHAction( SMESHOp::OpSplitEdgeInteract, "SPLIT_DIAG_INTRC","ICON_SPLIT_DIAG_INTERACTIVE" );
4403 createSMESHAction( SMESHOp::OpSplitFaceInteract, "SPLIT_FACE_INTRC","ICON_SPLIT_FACE_INTERACTIVE" );
4404 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4405 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4406 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4407 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4408 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4409 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4410 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4411 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4412 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4413 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4414 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4415 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4416 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4417 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4418 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4419 createSMESHAction( SMESHOp::OpCreateDualMesh, "CREATE_DUAL_MESH","ICON_CREATE_DUAL_MESH" );
4420 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4421 createSMESHAction( SMESHOp::OpCreate2DElements, "2D_FROM_3D_ELEMENTS","ICON_2D_FROM_3D_ELEMENTS" );
4423 createSMESHAction( SMESHOp::OpReset, "RESET" );
4424 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4425 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4426 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4427 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4428 #ifndef DISABLE_PLOT2DVIEWER
4429 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4431 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4432 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4433 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4434 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4435 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4436 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4437 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4438 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4439 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4440 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4441 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4442 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4443 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4445 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4446 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4448 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4449 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4450 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4451 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4452 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4453 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4454 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4455 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4456 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4458 // Adaptation - begin
4459 #ifndef DISABLE_MG_ADAPT
4460 createSMESHAction( SMESHOp::OpMGAdapt, "MG_ADAPT", "ICON_MG_ADAPT" );
4462 #ifndef DISABLE_HOMARD_ADAPT
4463 createSMESHAction( SMESHOp::OpHomardAdapt, "HOMARD_ADAPT", "ICON_HOMARD_ADAPT" );
4467 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4468 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4469 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4470 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4471 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4472 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4474 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4475 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4476 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4478 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4480 createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
4482 QList<int> aCtrlActions;
4483 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4484 << SMESHOp::OpNodeConnectivityNb // node controls
4485 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4486 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4487 << SMESHOp::OpDeflection2D
4488 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4489 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4490 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4491 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4492 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4493 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume << SMESHOp::OpWarping3D
4494 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4495 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume << SMESHOp::OpScaledJacobian; // volume controls
4496 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4497 aCtrlGroup->setExclusive( true );
4498 for( int i = 0; i < aCtrlActions.size(); i++ )
4499 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4501 // ----- create menu --------------
4502 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4503 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4504 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4505 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4506 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4507 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4508 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4509 adaptId = createMenu( tr( "MEN_ADAPT" ), -1, 80, 10 ),
4511 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4512 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4514 createMenu( separator(), fileId );
4516 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4517 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4518 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4519 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4520 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4521 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4522 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4523 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4524 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4525 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4526 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4527 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4528 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4531 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4532 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4533 createMenu( SMESHOp::OpImportMED, importId, -1 );
4534 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4536 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4538 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4539 createMenu( SMESHOp::OpImportMESHIO, importId, -1 ); // formats supported by meshio lib
4542 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4543 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4544 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4545 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4547 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4549 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4550 createMenu( SMESHOp::OpExportMESHIO, exportId, -1 ); // formats supported by meshio lib
4551 createMenu( separator(), fileId, 10 );
4553 createMenu( SMESHOp::OpDelete, editId, -1 );
4555 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4557 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4558 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4559 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4560 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4561 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4562 createMenu( SMESHOp::OpCreateDualMesh, meshId, -1 );
4563 createMenu( separator(), meshId, -1 );
4564 createMenu( SMESHOp::OpCompute, meshId, -1 );
4565 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4566 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4567 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4568 createMenu( separator(), meshId, -1 );
4569 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4570 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4571 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4572 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4573 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4574 createMenu( separator(), meshId, -1 );
4575 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4576 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4577 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4578 createMenu( separator(), meshId, -1 );
4579 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4580 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4581 createMenu( separator(), meshId, -1 );
4582 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4583 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4584 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4585 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4586 createMenu( separator(), meshId, -1 );
4588 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4589 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4590 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4591 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4592 createMenu( SMESHOp::OpLength, edgeId, -1 );
4593 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4594 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4595 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4596 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4597 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4598 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4599 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4600 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4601 createMenu( SMESHOp::OpArea, faceId, -1 );
4602 createMenu( SMESHOp::OpTaper, faceId, -1 );
4603 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4604 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4605 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4606 createMenu( SMESHOp::OpSkew, faceId, -1 );
4607 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4608 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4609 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4610 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4611 createMenu( SMESHOp::OpWarping3D, volumeId, -1 );
4612 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4613 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4614 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4615 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4616 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4617 createMenu( SMESHOp::OpScaledJacobian, volumeId, -1 );
4618 createMenu( separator(), ctrlId, -1 );
4619 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4620 createMenu( separator(), ctrlId, -1 );
4621 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4623 createMenu( SMESHOp::OpNode, addId, -1 );
4624 createMenu( SMESHOp::OpElem0D, addId, -1 );
4625 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4626 createMenu( SMESHOp::OpBall, addId, -1 );
4627 createMenu( SMESHOp::OpEdge, addId, -1 );
4628 createMenu( SMESHOp::OpTriangle, addId, -1 );
4629 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4630 createMenu( SMESHOp::OpPolygon, addId, -1 );
4631 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4632 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4633 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4634 createMenu( SMESHOp::OpPyramid, addId, -1 );
4635 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4636 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4637 createMenu( separator(), addId, -1 );
4638 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4639 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4640 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4641 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4642 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4643 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4644 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4645 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4646 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4647 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4648 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4649 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4650 createMenu( separator(), addId, -1 );
4651 createMenu( SMESHOp::OpSplitEdgeInteract, addId, -1 );
4652 createMenu( SMESHOp::OpSplitFaceInteract, addId, -1 );
4654 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4655 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4656 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4657 createMenu( SMESHOp::OpRemoveNodeWithReconn, removeId, -1 );
4658 createMenu( separator(), removeId, -1 );
4659 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4660 createMenu( separator(), removeId, -1 );
4661 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4663 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4664 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4666 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4667 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4668 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4669 createMenu( SMESHOp::OpRotation, transfId, -1 );
4670 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4671 createMenu( SMESHOp::OpScale, transfId, -1 );
4672 createMenu( SMESHOp::OpOffset, transfId, -1 );
4673 createMenu( SMESHOp::OpSewing, transfId, -1 );
4674 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4676 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4677 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4678 createMenu( SMESHOp::OpCreate2DElements, modifyId, -1 );
4679 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4680 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4681 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4682 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4683 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4684 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4685 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4686 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4687 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4688 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4689 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4690 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4691 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4692 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4694 // Adaptation - begin
4695 #ifndef DISABLE_MG_ADAPT
4696 createMenu( SMESHOp::OpMGAdapt, adaptId, -1 );
4698 #ifndef DISABLE_HOMARD_ADAPT
4699 createMenu( SMESHOp::OpHomardAdapt, adaptId, -1 );
4703 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4704 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4705 createMenu( SMESHOp::OpAngle, measureId, -1 );
4706 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4707 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4708 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4709 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4711 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4712 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4713 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4714 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4716 // ----- create toolbars --------------
4717 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ) ;
4718 createTool( SMESHOp::OpCreateMesh, meshTb );
4719 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4720 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4721 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4722 createTool( SMESHOp::OpCopyMesh, meshTb );
4723 createTool( separator(), meshTb );
4724 createTool( SMESHOp::OpCompute, meshTb );
4725 createTool( SMESHOp::OpPreCompute, meshTb );
4726 createTool( SMESHOp::OpEvaluate, meshTb );
4727 createTool( SMESHOp::OpMeshOrder, meshTb );
4729 int infoTb = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ) ;
4730 createTool( SMESHOp::OpMeshInformation, infoTb );
4731 //createTool( SMESHOp::OpStdInfo, meshTb );
4732 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4733 createTool( SMESHOp::OpFindElementByPoint, infoTb );
4735 int groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ) ;
4736 createTool( SMESHOp::OpCreateGroup, groupTb );
4737 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4738 createTool( SMESHOp::OpConstructGroup, groupTb );
4739 createTool( SMESHOp::OpEditGroup, groupTb );
4741 int ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ) ;
4742 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4743 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4744 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4746 int ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ) ;
4747 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4748 createTool( SMESHOp::OpLength, ctrl1dTb );
4749 createTool( SMESHOp::OpConnection, ctrl1dTb );
4750 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4752 int ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ) ;
4753 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4754 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4755 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4756 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4757 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4758 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4759 createTool( SMESHOp::OpArea, ctrl2dTb );
4760 createTool( SMESHOp::OpTaper, ctrl2dTb );
4761 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4762 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4763 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4764 createTool( SMESHOp::OpSkew, ctrl2dTb );
4765 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4766 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4767 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4769 int ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ) ;
4770 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4771 createTool( SMESHOp::OpWarping3D, ctrl3dTb );
4772 createTool( SMESHOp::OpVolume, ctrl3dTb );
4773 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4774 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4775 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4776 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4777 createTool( SMESHOp::OpScaledJacobian, ctrl3dTb );
4779 int addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ) ;
4780 createTool( SMESHOp::OpNode, addElemTb );
4781 createTool( SMESHOp::OpElem0D, addElemTb );
4782 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4783 createTool( SMESHOp::OpBall, addElemTb );
4784 createTool( SMESHOp::OpEdge, addElemTb );
4785 createTool( SMESHOp::OpTriangle, addElemTb );
4786 createTool( SMESHOp::OpQuadrangle, addElemTb );
4787 createTool( SMESHOp::OpPolygon, addElemTb );
4788 createTool( SMESHOp::OpTetrahedron, addElemTb );
4789 createTool( SMESHOp::OpHexahedron, addElemTb );
4790 createTool( SMESHOp::OpPentahedron, addElemTb );
4791 createTool( SMESHOp::OpPyramid, addElemTb );
4792 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4793 createTool( SMESHOp::OpPolyhedron, addElemTb );
4795 int addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ) ;
4796 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4797 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4798 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4799 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4800 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4801 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4802 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4803 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4804 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4805 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4806 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4807 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4809 int remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ) ;
4810 createTool( SMESHOp::OpRemoveNodes, remTb );
4811 createTool( SMESHOp::OpRemoveElements, remTb );
4812 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4813 createTool( SMESHOp::OpClearMesh, remTb );
4815 // int renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ) ;
4816 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4817 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4819 int transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ) ;
4820 createTool( SMESHOp::OpMergeNodes, transformTb );
4821 createTool( SMESHOp::OpMergeElements, transformTb );
4822 createTool( SMESHOp::OpTranslation, transformTb );
4823 createTool( SMESHOp::OpRotation, transformTb );
4824 createTool( SMESHOp::OpSymmetry, transformTb );
4825 createTool( SMESHOp::OpScale, transformTb );
4826 createTool( SMESHOp::OpOffset, transformTb );
4827 createTool( SMESHOp::OpSewing, transformTb );
4828 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4830 int modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ) ;
4831 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4832 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4833 createTool( SMESHOp::OpCreate2DElements, modifyTb );
4834 createTool( SMESHOp::OpExtrusion, modifyTb );
4835 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4836 createTool( SMESHOp::OpRevolution, modifyTb );
4837 createTool( SMESHOp::OpOrientation, modifyTb );
4838 createTool( SMESHOp::OpReorientFaces, modifyTb );
4839 createTool( SMESHOp::OpMoveNode, modifyTb );
4840 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4841 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4842 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4843 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4844 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4845 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4846 createTool( SMESHOp::OpSmoothing, modifyTb );
4847 createTool( SMESHOp::OpPatternMapping, modifyTb );
4849 int interactTb = createTool( tr( "TB_INTERACT" ), QString( "SMESHInteractiveToolbar" ) ) ;
4850 createTool( SMESHOp::OpMoveNodeInteractive, interactTb );
4851 createTool( SMESHOp::OpRemoveNodeWithReconn, interactTb );
4852 createTool( SMESHOp::OpSplitEdgeInteract, interactTb );
4853 createTool( SMESHOp::OpSplitFaceInteract, interactTb );
4855 // Adaptation - begin
4856 #if !defined(DISABLE_MG_ADAPT) || !defined(DISABLE_HOMARD_ADAPT)
4857 int adaptTb = createTool( tr( "TB_ADAPTATION" ), QString( "SMESHAdaptationToolbar" ) ) ;
4859 #ifndef DISABLE_MG_ADAPT
4860 createTool( SMESHOp::OpMGAdapt, adaptTb );
4862 #ifndef DISABLE_HOMARD_ADAPT
4863 createTool( SMESHOp::OpHomardAdapt, adaptTb );
4867 int measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ) ;
4868 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4870 int dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4871 createTool( SMESHOp::OpUpdate, dispModeTb );
4873 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4874 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4878 OB = "'ObjectBrowser'",
4879 View = "'" + SVTK_Viewer::Type() + "'",
4881 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4882 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4883 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4884 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4885 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4886 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4887 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4888 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4889 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4890 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4891 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4892 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4894 mesh_part = mesh + " " + subMesh + " " + group,
4895 mesh_group = mesh + " " + group,
4896 mesh_submesh = mesh + " " + subMesh,
4897 hyp_alg = hypo + " " + algo;
4899 // popup for object browser
4901 isInvisible("not( isVisible )"),
4902 isEmpty("numberOfNodes = 0"),
4903 isNotEmpty("numberOfNodes <> 0"),
4905 // has nodes, edges, etc in VISIBLE! actor
4906 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4907 hasElems("(count( elemTypes ) > 0)"),
4908 hasDifferentElems("(count( elemTypes ) > 1)"),
4909 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4910 hasBalls("({'BallElem'} in elemTypes)"),
4911 hasElems0d("({'Elem0d'} in elemTypes)"),
4912 hasEdges("({'Edge'} in elemTypes)"),
4913 hasFaces("({'Face'} in elemTypes)"),
4914 hasVolumes("({'Volume'} in elemTypes)"),
4915 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4917 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4918 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4919 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && hasAlgo && hasGeomReference" );
4920 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4921 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4922 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4924 popupMgr()->insert( separator(), -1, 0 );
4925 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4926 createPopupItem( SMESHOp::OpRecompute, OB, mesh, "&& selcount=1 && hasAlgo && (" + isNotEmpty + " || hasErrors )");
4927 createPopupItem( SMESHOp::OpShowErrors, OB, mesh, "&& selcount=1 && hasErrors" );
4928 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && hasAlgo && isComputable" );
4929 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && hasAlgo && isPreComputable" );
4930 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && hasAlgo && isComputable" );
4931 popupMgr()->insert( separator(), -1, 0 );
4932 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4933 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4934 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1 && " + hasElems );
4935 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4936 popupMgr()->insert( separator(), -1, 0 );
4937 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4938 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4939 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4940 popupMgr()->insert( separator(), -1, 0 );
4941 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4942 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4943 popupMgr()->insert( separator(), -1, 0 );
4944 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems );
4945 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4947 // Adaptation - begin
4948 popupMgr()->insert( separator(), -1, 0 );
4949 #ifndef DISABLE_MG_ADAPT
4950 createPopupItem( SMESHOp::OpMGAdapt, OB, mesh );
4952 #ifndef DISABLE_HOMARD_ADAPT
4953 createPopupItem( SMESHOp::OpHomardAdapt, OB, mesh );
4955 popupMgr()->insert( separator(), -1, 0 );
4958 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4959 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4960 QString only_one_2D = only_one_non_empty + " && dim>1";
4962 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4963 popupMgr()->findMenu( anId )->menuAction()->setIcon( resourceMgr()->loadPixmap( "SMESH", tr( "ICON_EXPORT" )));
4964 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4965 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4966 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4968 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4970 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4971 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4972 createPopupItem( SMESHOp::OpExportMESHIO, OB, mesh_group, only_one_non_empty, anId );
4974 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4975 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4976 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4977 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4979 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4981 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4982 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4983 popupMgr()->insert( separator(), -1, 0 );
4985 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4986 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4987 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4990 createPopupItem( SMESHOp::OpEditGroup, View, group );
4991 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4992 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4994 popupMgr()->insert( separator(), -1, 0 );
4995 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4996 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4997 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh, "&& " + hasElems);
4998 popupMgr()->insert( separator(), -1, 0 );
5000 createPopupItem( SMESHOp::OpUpdate, OB + " " + View, mesh_part );
5001 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
5002 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
5003 popupMgr()->insert( separator(), -1, 0 );
5005 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
5006 QString aType = QString( "%1type in {%2}" ).arg( lc );
5007 aType = aType.arg( mesh_part );
5008 QString aMeshInVTK = aClient + "&&" + aType;
5010 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
5011 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
5012 QString aSelCount = QString( "%1 > 0" ).arg( dc );
5014 //-------------------------------------------------
5016 //-------------------------------------------------
5017 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
5019 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
5020 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
5021 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
5023 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
5024 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
5025 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
5027 popupMgr()->insert( separator(), -1, -1 );
5029 //-------------------------------------------------
5031 //-------------------------------------------------
5032 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
5034 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
5035 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
5036 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
5038 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
5039 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
5040 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
5042 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
5043 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
5044 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
5046 popupMgr()->insert( separator(), anId, -1 );
5048 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
5049 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
5050 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
5052 //-------------------------------------------------
5054 //-------------------------------------------------
5055 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
5057 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
5059 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
5060 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
5061 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
5063 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
5064 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
5065 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
5067 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
5068 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
5069 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
5071 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
5072 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
5073 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
5075 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
5076 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
5077 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
5079 popupMgr()->insert( separator(), anId, -1 );
5081 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
5082 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
5084 popupMgr()->insert( separator(), anId, -1 );
5086 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
5087 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
5090 //-------------------------------------------------
5091 // Representation of the 2D Quadratic elements
5092 //-------------------------------------------------
5093 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
5094 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
5095 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
5096 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
5098 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
5099 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
5100 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
5102 //-------------------------------------------------
5103 // Orientation of faces
5104 //-------------------------------------------------
5105 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
5106 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
5107 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
5109 //-------------------------------------------------
5111 //-------------------------------------------------
5112 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
5113 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
5115 //-------------------------------------------------
5117 //-------------------------------------------------
5118 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
5119 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
5121 //-------------------------------------------------
5123 //-------------------------------------------------
5125 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
5126 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
5127 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
5128 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
5130 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
5132 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
5133 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5135 popupMgr()->insert( separator(), anId, -1 );
5137 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
5139 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
5140 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5141 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
5143 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
5144 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5145 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
5147 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
5148 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
5149 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
5151 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
5153 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
5154 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
5155 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
5157 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
5158 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5159 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
5161 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
5162 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5163 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
5164 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
5165 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
5166 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
5168 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
5170 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
5171 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5172 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
5174 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
5175 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
5176 QtxPopupMgr::VisibleRule );
5177 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
5179 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
5180 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5181 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
5183 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
5184 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5185 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
5187 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
5188 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5189 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
5191 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
5192 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5193 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
5195 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
5196 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5197 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
5199 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
5200 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5201 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
5203 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
5204 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5205 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
5207 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
5208 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5209 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
5211 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
5212 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5213 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
5215 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
5216 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5217 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
5219 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
5220 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5221 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
5223 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
5224 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
5225 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
5227 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
5228 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
5229 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
5231 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
5233 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
5234 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5235 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
5237 popupMgr()->insert ( action( SMESHOp::OpWarping3D ), aSubId, -1 );
5238 popupMgr()->setRule( action( SMESHOp::OpWarping3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5239 popupMgr()->setRule( action( SMESHOp::OpWarping3D), "controlMode = 'eWarping3D'", QtxPopupMgr::ToggleRule );
5241 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
5242 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5243 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
5245 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
5246 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5247 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
5249 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
5250 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5251 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
5253 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
5254 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5255 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
5257 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
5258 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5259 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
5261 popupMgr()->insert ( action( SMESHOp::OpScaledJacobian ), aSubId, -1 );
5262 popupMgr()->setRule( action( SMESHOp::OpScaledJacobian ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
5263 popupMgr()->setRule( action( SMESHOp::OpScaledJacobian ), "controlMode = 'eScaledJacobian'", QtxPopupMgr::ToggleRule );
5265 popupMgr()->insert( separator(), anId, -1 );
5267 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
5268 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5269 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
5270 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
5271 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
5273 popupMgr()->insert( separator(), anId, -1 );
5275 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
5277 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
5278 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5280 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
5281 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5282 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
5284 #ifndef DISABLE_PLOT2DVIEWER
5285 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
5286 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
5289 //-------------------------------------------------
5291 //-------------------------------------------------
5292 popupMgr()->insert( separator(), -1, -1 );
5293 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
5294 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
5295 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
5296 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
5298 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
5299 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
5301 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
5302 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
5304 popupMgr()->insert( separator(), -1, -1 );
5306 //-------------------------------------------------
5308 //-------------------------------------------------
5309 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
5310 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
5312 popupMgr()->insert( separator(), -1, -1 );
5314 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
5315 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
5316 popupMgr()->insert( separator(), -1, -1 );
5318 popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
5319 popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
5321 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
5322 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
5324 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
5325 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
5328 //================================================================================
5330 * \brief Return true if SMESH or GEOM objects are selected.
5331 * Is called form LightApp_Module::activateModule() which clear selection if
5332 * not isSelectionCompatible()
5334 //================================================================================
5336 bool SMESHGUI::isSelectionCompatible()
5338 bool isCompatible = true;
5339 SALOME_ListIO selected;
5340 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
5341 Sel->selectedObjects( selected );
5343 SALOME_ListIteratorOfListIO It( selected );
5344 for ( ; isCompatible && It.More(); It.Next())
5346 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
5347 ( strcmp("SHAPERSTUDY", It.Value()->getComponentDataType()) == 0 ) ||
5348 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
5350 return isCompatible;
5354 bool SMESHGUI::reusableOperation( const int id )
5356 // compute, evaluate and precompute are not reusable operations
5357 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate || id == SMESHOp::OpRecompute ) ? false : SalomeApp_Module::reusableOperation( id );
5362 QString wrap(const QString& text, const QString& tag)
5363 { return QString("<%1>%2</%3>").arg(tag).arg(text).arg(tag);}
5366 bool SMESHGUI::activateModule( SUIT_Study* study )
5368 bool res = SalomeApp_Module::activateModule( study );
5370 setMenuShown( true );
5371 setToolShown( true );
5373 // Fill in Help Panel
5374 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
5375 app->infoPanel()->setTitle(tr("INFO_WELCOME_TO_SMESH"));
5377 int gb = app->infoPanel()->addGroup(tr("INFO_GRP_CREATE_MESH"));
5380 lab = tr("INFO_DEFINE_ALGOS") + "<br/>";
5381 lab = lab + tr("INFO_DEFINE_HYPOS") + "<br/>";
5382 lab = lab + tr("INFO_COMPUTE") + "<br/>";
5383 lab = lab + tr("INFO_REFINE") + ":";
5384 items << wrap(tr("INFO_REFINE_LOCAL_SIZE"), "li")
5385 << wrap(tr("INFO_REFINE_SUBMESH"), "li");
5386 lab = lab + wrap(items.join(""), "ul");
5389 app->infoPanel()->addLabel(lab, gb);
5391 gb = app->infoPanel()->addGroup(tr("INFO_GRP_IMPORT_MESH"));
5392 items << wrap("UNV", "li")
5393 << wrap("MED", "li")
5394 << wrap("STL", "li")
5395 << wrap("CGNS", "li")
5396 << wrap("GMF", "li");
5397 lab = tr("INFO_AVAILABLE_FORMATS") + ":" + wrap(items.join(""), "ul");
5400 app->infoPanel()->addLabel(lab, gb);
5402 gb = app->infoPanel()->addGroup(tr("INFO_GRP_CHECK_MESH"));
5403 lab = tr("INFO_DISPLAY") + "<br/>";
5404 items << wrap(tr("INFO_QUALITY_AREA"), "li")
5405 << wrap(tr("INFO_QUALITY_VOLUME"), "li")
5406 << wrap(tr("INFO_QUALITY_ASPECT_RATION"), "li")
5407 << wrap("...", "li");
5408 lab = lab + tr("INFO_QUALITY_INFO") + ":" + wrap(items.join(""), "ul");
5410 lab = lab + tr("INFO_CLIPPING");
5412 app->infoPanel()->addLabel(lab, gb);
5415 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
5416 PyGILState_STATE gstate = PyGILState_Ensure();
5417 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
5418 if ( !pluginsmanager ) {
5422 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
5427 PyGILState_Release(gstate);
5428 // end of SMESH plugins loading
5430 // Reset actions accelerator keys
5431 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
5433 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
5434 GetSMESHGen()->UpdateStudy();
5436 // get all view currently opened in the study and connect their signals to
5437 // the corresponding slots of the class.
5438 SUIT_Desktop* aDesk = study->application()->desktop();
5440 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
5441 SUIT_ViewWindow* wnd;
5442 foreach ( wnd, wndList )
5446 // remove actors whose objects are removed in GetSMESHGen()->UpdateStudy()
5447 SMESH::UpdateActorsAfterUpdateStudy(wnd);
5453 Py_XDECREF(pluginsmanager);
5457 bool SMESHGUI::deactivateModule( SUIT_Study* study )
5459 setMenuShown( false );
5460 setToolShown( false );
5462 EmitSignalCloseAllDialogs();
5464 // Unset actions accelerator keys
5465 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
5467 return SalomeApp_Module::deactivateModule( study );
5470 void SMESHGUI::studyClosed( SUIT_Study* s )
5474 SMESH::RemoveVisuData();
5475 SalomeApp_Module::studyClosed( s );
5478 void SMESHGUI::OnGUIEvent()
5480 const QObject* obj = sender();
5481 if ( !obj || !obj->inherits( "QAction" ) )
5483 int id = actionId((QAction*)obj);
5488 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
5490 if ( CORBA::is_nil( myComponentSMESH ) )
5492 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
5493 return aGUI.myComponentSMESH;
5495 return myComponentSMESH;
5498 QString SMESHGUI::engineIOR() const
5500 CORBA::ORB_var anORB = getApp()->orb();
5501 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
5502 return QString( anIOR.in() );
5505 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
5507 SalomeApp_Module::contextMenuPopup( client, menu, title );
5509 selectionMgr()->selectedObjects( lst );
5510 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
5511 Handle(SALOME_InteractiveObject) io = lst.First();
5512 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
5513 _PTR(Study) study = appStudy->studyDS();
5514 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
5516 QString aName = SMESH::fromUtf8( obj->GetName());
5517 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
5518 aName.remove(( aName.length() - 1 ), 1 );
5524 LightApp_Selection* SMESHGUI::createSelection() const
5526 return new SMESHGUI_Selection();
5529 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5531 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5532 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5533 aMap.insert( SalomeApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
5534 #ifndef DISABLE_PYCONSOLE
5535 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5539 void SMESHGUI::viewManagers( QStringList& list ) const
5541 list.append( SVTK_Viewer::Type() );
5544 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5546 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5547 SMESH::UpdateSelectionProp( this );
5549 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5550 for(int i = 0; i < aViews.count() ; i++){
5551 SUIT_ViewWindow *sf = aViews[i];
5554 EmitSignalActivatedViewManager();
5558 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5560 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5561 myClippingPlaneInfoMap.erase( theViewManager );
5564 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5566 theActor->AddObserver( SMESH::DeleteActorEvent,
5567 myEventCallbackCommand.GetPointer(),
5571 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5572 unsigned long theEvent,
5573 void* theClientData,
5574 void* /*theCallData*/ )
5576 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5577 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5578 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5579 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5580 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5581 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5582 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5583 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5584 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5585 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5586 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5587 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5588 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5589 if( anActor == *anIter3 ) {
5590 anActorList.erase( anIter3 );
5601 void SMESHGUI::createPreferences()
5603 // General tab ------------------------------------------------------------------------
5604 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5606 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5607 setPreferenceProperty( autoUpdate, "columns", 2 );
5608 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5609 setPreferenceProperty( lim, "min", 0 );
5610 setPreferenceProperty( lim, "max", 100000000 );
5611 setPreferenceProperty( lim, "step", 1000 );
5612 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5613 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5615 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5616 setPreferenceProperty( dispgroup, "columns", 2 );
5618 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5620 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5622 modes.append( tr("MEN_WIRE") );
5623 modes.append( tr("MEN_SHADE") );
5624 modes.append( tr("MEN_NODES") );
5625 modes.append( tr("MEN_SHRINK") );
5626 QList<QVariant> indices;
5627 indices.append( 0 );
5628 indices.append( 1 );
5629 indices.append( 2 );
5630 indices.append( 3 );
5631 setPreferenceProperty( dispmode, "strings", modes );
5632 setPreferenceProperty( dispmode, "indexes", indices );
5634 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5635 setPreferenceProperty( arcgroup, "columns", 2 );
5636 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5637 QStringList quadraticModes;
5638 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5639 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5641 indices.append( 0 );
5642 indices.append( 1 );
5643 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5644 setPreferenceProperty( quadraticmode, "indexes", indices );
5646 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5647 "SMESH", "max_angle" );
5648 setPreferenceProperty( maxAngle, "min", 1 );
5649 setPreferenceProperty( maxAngle, "max", 90 );
5651 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5652 setPreferenceProperty( qaGroup, "columns", 2 );
5653 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5654 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5655 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5656 setPreferenceProperty( prec, "min", 0 );
5657 setPreferenceProperty( prec, "max", 100 );
5658 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5659 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5660 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5661 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5662 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5665 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5666 setPreferenceProperty( cinc, "min", 0 );
5667 setPreferenceProperty( cinc, "max", 5 );
5670 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5671 setPreferenceProperty( exportgroup, "columns", 2 );
5672 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5673 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5674 addPreference( tr( "PREF_MED_SAVE_NUMS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "med_save_numbers" );
5675 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5676 setPreferenceProperty( zTol, "precision", 10 );
5677 setPreferenceProperty( zTol, "min", 0.0000000001 );
5678 setPreferenceProperty( zTol, "max", 1000000.0 );
5679 setPreferenceProperty( zTol, "step", 1. );
5680 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5682 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5683 setPreferenceProperty( computeGroup, "columns", 2 );
5684 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5686 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5687 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5688 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5690 indices.append( 0 );
5691 indices.append( 1 );
5692 indices.append( 2 );
5693 setPreferenceProperty( notifyMode, "strings", modes );
5694 setPreferenceProperty( notifyMode, "indexes", indices );
5696 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5697 setPreferenceProperty( infoGroup, "columns", 2 );
5698 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5700 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5701 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5703 indices.append( 0 );
5704 indices.append( 1 );
5705 setPreferenceProperty( elemInfo, "strings", modes );
5706 setPreferenceProperty( elemInfo, "indexes", indices );
5707 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5708 setPreferenceProperty( nodesLim, "min", 0 );
5709 setPreferenceProperty( nodesLim, "max", 10000000 );
5710 setPreferenceProperty( nodesLim, "step", 10000 );
5711 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5712 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5713 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5714 setPreferenceProperty( ctrlLim, "min", 0 );
5715 setPreferenceProperty( ctrlLim, "max", 10000000 );
5716 setPreferenceProperty( ctrlLim, "step", 1000 );
5717 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5718 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5719 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5720 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5721 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5723 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5724 setPreferenceProperty( segGroup, "columns", 2 );
5725 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5726 "SMESH", "segmentation" );
5727 setPreferenceProperty( segLen, "min", 1 );
5728 setPreferenceProperty( segLen, "max", 10000000 );
5729 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5730 "SMESH", "nb_segments_per_edge" );
5731 setPreferenceProperty( nbSeg, "min", 1 );
5732 setPreferenceProperty( nbSeg, "max", 10000000 );
5733 addPreference( tr( "PREF_USE_MESHGEMS_HYPOSET" ), segGroup, LightApp_Preferences::Bool, "SMESH", "use-meshgems-hypo-sets" );
5735 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5736 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5737 "SMESH", "forget_mesh_on_hyp_modif" );
5740 // Quantities with individual precision settings
5741 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5742 setPreferenceProperty( precGroup, "columns", 2 );
5744 const int nbQuantities = 6;
5745 int precs[nbQuantities], ii = 0;
5746 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5747 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5748 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5749 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5750 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5751 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5752 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5753 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5754 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5755 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5756 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5757 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5759 // Set property for precision value for spinboxes
5760 for ( ii = 0; ii < nbQuantities; ii++ ){
5761 setPreferenceProperty( precs[ii], "min", -14 );
5762 setPreferenceProperty( precs[ii], "max", 14 );
5763 setPreferenceProperty( precs[ii], "precision", 2 );
5766 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5767 setPreferenceProperty( previewGroup, "columns", 2 );
5768 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5769 setPreferenceProperty( chunkSize, "min", 1 );
5770 setPreferenceProperty( chunkSize, "max", 1000 );
5771 setPreferenceProperty( chunkSize, "step", 50 );
5773 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5774 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5776 // Mesh tab ------------------------------------------------------------------------
5777 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5778 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5779 setPreferenceProperty( nodeGroup, "columns", 3 );
5781 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5783 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5785 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5786 QList<QVariant> aMarkerTypeIndicesList;
5787 QList<QVariant> aMarkerTypeIconsList;
5788 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5789 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5790 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5791 aMarkerTypeIndicesList << i;
5792 aMarkerTypeIconsList << pixmap;
5794 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5795 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5797 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5799 QList<QVariant> aMarkerScaleIndicesList;
5800 QStringList aMarkerScaleValuesList;
5801 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5802 aMarkerScaleIndicesList << i;
5803 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5804 aMarkerScaleValuesList << QString::number( i );
5806 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5807 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5809 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5810 //setPreferenceProperty( elemGroup, "columns", 2 );
5812 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5813 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5814 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5815 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5816 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5817 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5818 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5819 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5820 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5823 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5824 setPreferenceProperty( grpGroup, "columns", 2 );
5826 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5827 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5829 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5830 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5831 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5832 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5833 int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5834 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5835 int ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5836 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5837 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5838 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5839 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5840 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5841 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5842 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5844 setPreferenceProperty( size0d, "min", 1 );
5845 setPreferenceProperty( size0d, "max", 10 );
5847 // setPreferenceProperty( ballSize, "min", 1 );
5848 // setPreferenceProperty( ballSize, "max", 10 );
5850 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5851 setPreferenceProperty( ballDiameter, "max", 1e9 );
5852 setPreferenceProperty( ballDiameter, "step", 0.1 );
5854 setPreferenceProperty( ballScale, "min", 1e-2 );
5855 setPreferenceProperty( ballScale, "max", 1e7 );
5856 setPreferenceProperty( ballScale, "step", 0.5 );
5858 setPreferenceProperty( elemW, "min", 1 );
5859 setPreferenceProperty( elemW, "max", 5 );
5861 setPreferenceProperty( outW, "min", 1 );
5862 setPreferenceProperty( outW, "max", 5 );
5864 setPreferenceProperty( shrink, "min", 0 );
5865 setPreferenceProperty( shrink, "max", 100 );
5867 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5868 setPreferenceProperty( numGroup, "columns", 2 );
5870 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5871 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5873 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5874 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5876 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5877 setPreferenceProperty( orientGroup, "columns", 1 );
5879 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5880 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5882 setPreferenceProperty( orientScale, "min", 0.05 );
5883 setPreferenceProperty( orientScale, "max", 0.5 );
5884 setPreferenceProperty( orientScale, "step", 0.05 );
5886 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5888 // Selection tab ------------------------------------------------------------------------
5889 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5891 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5892 setPreferenceProperty( selGroup, "columns", 2 );
5894 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5895 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5897 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5898 setPreferenceProperty( preGroup, "columns", 2 );
5900 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5902 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5903 setPreferenceProperty( precSelGroup, "columns", 2 );
5905 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5906 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5907 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5909 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5910 setPreferenceProperty( sinc, "min", 0 );
5911 setPreferenceProperty( sinc, "max", 5 );
5913 // Scalar Bar tab ------------------------------------------------------------------------
5914 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5915 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5916 setPreferenceProperty( fontGr, "columns", 2 );
5918 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5919 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5921 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5922 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5924 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5925 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5927 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5928 setPreferenceProperty( numcol, "min", 2 );
5929 setPreferenceProperty( numcol, "max", 256 );
5931 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5932 setPreferenceProperty( numlab, "min", 2 );
5933 setPreferenceProperty( numlab, "max", 65 );
5935 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5936 setPreferenceProperty( orientGr, "columns", 2 );
5937 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5938 QStringList orients;
5939 orients.append( tr( "SMESH_VERTICAL" ) );
5940 orients.append( tr( "SMESH_HORIZONTAL" ) );
5941 indices.clear(); indices.append( 0 ); indices.append( 1 );
5942 setPreferenceProperty( orient, "strings", orients );
5943 setPreferenceProperty( orient, "indexes", indices );
5945 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5946 setPreferenceProperty( posVSizeGr, "columns", 2 );
5947 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5948 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5949 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5950 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5951 setPreferenceProperty( xv, "step", 0.1 );
5952 setPreferenceProperty( xv, "min", 0.0 );
5953 setPreferenceProperty( xv, "max", 1.0 );
5954 setPreferenceProperty( yv, "step", 0.1 );
5955 setPreferenceProperty( yv, "min", 0.0 );
5956 setPreferenceProperty( yv, "max", 1.0 );
5957 setPreferenceProperty( wv, "step", 0.1 );
5958 setPreferenceProperty( wv, "min", 0.0 );
5959 setPreferenceProperty( wv, "max", 1.0 );
5960 setPreferenceProperty( hv, "min", 0.0 );
5961 setPreferenceProperty( hv, "max", 1.0 );
5962 setPreferenceProperty( hv, "step", 0.1 );
5964 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5965 setPreferenceProperty( posHSizeGr, "columns", 2 );
5966 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5967 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5968 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5969 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5970 setPreferenceProperty( xv, "min", 0.0 );
5971 setPreferenceProperty( xv, "max", 1.0 );
5972 setPreferenceProperty( xv, "step", 0.1 );
5973 setPreferenceProperty( xh, "min", 0.0 );
5974 setPreferenceProperty( xh, "max", 1.0 );
5975 setPreferenceProperty( xh, "step", 0.1 );
5976 setPreferenceProperty( yh, "min", 0.0 );
5977 setPreferenceProperty( yh, "max", 1.0 );
5978 setPreferenceProperty( yh, "step", 0.1 );
5979 setPreferenceProperty( wh, "min", 0.0 );
5980 setPreferenceProperty( wh, "max", 1.0 );
5981 setPreferenceProperty( wh, "step", 0.1 );
5982 setPreferenceProperty( hh, "min", 0.0 );
5983 setPreferenceProperty( hh, "max", 1.0 );
5984 setPreferenceProperty( hh, "step", 0.1 );
5986 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5987 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5988 setPreferenceProperty( distributionGr, "columns", 3 );
5990 types.append( tr( "SMESH_MONOCOLOR" ) );
5991 types.append( tr( "SMESH_MULTICOLOR" ) );
5992 indices.clear(); indices.append( 0 ); indices.append( 1 );
5993 setPreferenceProperty( coloringType, "strings", types );
5994 setPreferenceProperty( coloringType, "indexes", indices );
5995 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5997 // Adaptation - begin
5998 #ifndef DISABLE_MG_ADAPT
5999 // Adaptation tab ------------------------------------------------------------------------
6000 int adaptTab = addPreference( tr( "ADAPT_PREF_TAB_GENERAL" ) );
6003 bloc = addPreference( tr( "ADAPT_PREF_MG_ADAPT" ), adaptTab );
6004 setPreferenceProperty( bloc, "columns", 1 );
6005 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_FILE_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_file_mesh_out" );
6006 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_PUBLICATION_MAILLAGE_OUT" ), bloc, LightApp_Preferences::Bool, "HOMARD", "mg_adapt_publish_mesh_out" );
6007 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_size_map" );
6008 QStringList aListOfSizeMap;
6009 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_LOCAL" );
6010 aListOfSizeMap << tr( "ADAPT_PREF_MG_ADAPT_SIZE_MAP_BACKGROUND" );
6011 aListOfSizeMap << tr( "ADAPT_PREF_NONE" );;
6012 setPreferenceProperty( pref, "strings", aListOfSizeMap );
6013 pref = addPreference( tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP" ), bloc, LightApp_Preferences::Selector, "HOMARD", "mg_adapt_time_step" );
6014 QStringList aListOfTimeStep;
6015 aListOfTimeStep << tr( "ADAPT_PREF_NONE" );
6016 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_LAST" );
6017 aListOfTimeStep << tr( "ADAPT_PREF_MG_ADAPT_TIME_STEP_C" );;
6018 setPreferenceProperty( pref, "strings", aListOfTimeStep );
6023 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
6025 if ( sect=="SMESH" ) {
6026 double sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
6027 double aTol = 1.00000009999999;
6028 std::string aWarning;
6029 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
6031 if ( name == "selection_object_color" ||
6032 name == "selection_element_color" ||
6033 name == "highlight_color" ||
6034 name == "selection_precision_node" ||
6035 name == "selection_precision_element" ||
6036 name == "selection_precision_object" ||
6037 name == "selection_increment")
6039 SMESH::UpdateSelectionProp( this );
6041 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
6043 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
6044 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
6045 if ( sbX1+sbW > aTol ) {
6046 aWarning = "Origin and Size Vertical: X+Width > 1\n";
6049 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
6050 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
6053 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
6055 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
6056 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
6057 if ( sbY1 + sbH > aTol ) {
6058 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
6059 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
6060 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
6063 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
6065 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
6066 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
6067 if ( sbX1 + sbW > aTol ) {
6068 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
6071 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
6072 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
6075 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
6077 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
6078 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
6079 if ( sbY1 + sbH > aTol ) {
6080 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
6083 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
6084 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
6087 else if ( name == "segmentation" )
6089 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
6090 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
6092 else if ( name == "nb_segments_per_edge" )
6094 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
6095 myComponentSMESH->SetDefaultNbSegments( nbSeg );
6097 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
6099 QString val = aResourceMgr->stringValue( "SMESH", name );
6100 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
6102 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
6104 SMESH::UpdateFontProp( this );
6106 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
6108 SMESH::UpdateFontProp( this );
6111 if ( aWarning.size() != 0 ) {
6112 aWarning += "The default values are applied instead.";
6113 SUIT_MessageBox::warning(SMESHGUI::desktop(),
6114 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
6115 QObject::tr(aWarning.c_str()));
6120 //================================================================================
6122 * \brief Update something in accordance with update flags
6123 * \param theFlags - update flags
6125 * Update viewer or/and object browser etc. in accordance with update flags ( see
6126 * LightApp_UpdateFlags enumeration ).
6128 //================================================================================
6129 void SMESHGUI::update( const int flags )
6131 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
6132 SMESH::UpdateView();
6134 SalomeApp_Module::update( flags );
6137 //================================================================================
6139 * \brief Set default selection mode
6141 * SLOT called when operation committed. Sets default selection mode
6143 //================================================================================
6144 void SMESHGUI::onOperationCommited( SUIT_Operation* )
6146 SVTK_ViewWindow* vtkWnd =
6147 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6149 vtkWnd->SetSelectionMode( ActorSelection );
6152 //================================================================================
6154 * \brief Set default selection mode
6156 * SLOT called when operation aborted. Sets default selection mode
6158 //================================================================================
6159 void SMESHGUI::onOperationAborted( SUIT_Operation* )
6161 SVTK_ViewWindow* vtkWnd =
6162 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
6164 vtkWnd->SetSelectionMode( ActorSelection );
6167 //================================================================================
6169 * \brief Creates operation with given identifier
6170 * \param id - identifier of operation to be started
6171 * \return Pointer on created operation or NULL if operation is not created
6173 * Virtual method redefined from the base class creates operation with given id.
6174 * It is called called automatically from startOperation method of base class.
6176 //================================================================================
6177 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
6179 LightApp_Operation* op = 0;
6180 // to do : create operation here
6183 case SMESHOp::OpSplitBiQuadratic:
6184 op = new SMESHGUI_SplitBiQuadOp();
6186 case SMESHOp::OpConvertMeshToQuadratic:
6187 op = new SMESHGUI_ConvToQuadOp();
6189 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
6190 op = new SMESHGUI_Make2DFrom3DOp();
6192 case SMESHOp::OpCreateDualMesh:
6193 op = new SMESHGUI_CreateDualMeshOp();
6195 case SMESHOp::OpCreate2DElements:
6196 op = new SMESHGUI_MakeFull2DFrom3DOp();
6198 case SMESHOp::OpReorientFaces:
6199 op = new SMESHGUI_ReorientFacesOp();
6201 case SMESHOp::OpCreateMesh:
6202 op = new SMESHGUI_MeshOp( true, true );
6204 case SMESHOp::OpCreateSubMesh:
6205 op = new SMESHGUI_MeshOp( true, false );
6207 case SMESHOp::OpEditMeshOrSubMesh:
6208 case SMESHOp::OpEditMesh:
6209 case SMESHOp::OpEditSubMesh:
6210 op = new SMESHGUI_MeshOp( false );
6212 case SMESHOp::OpCompute:
6213 case SMESHOp::OpComputeSubMesh:
6214 op = new SMESHGUI_ComputeOp();
6216 case SMESHOp::OpShowErrors:
6217 op = new SMESHGUI_ShowErrorsOp();
6219 case SMESHOp::OpPreCompute:
6220 op = new SMESHGUI_PrecomputeOp();
6222 case SMESHOp::OpEvaluate:
6223 op = new SMESHGUI_EvaluateOp();
6225 case SMESHOp::OpMeshOrder:
6226 op = new SMESHGUI_MeshOrderOp();
6228 case SMESHOp::OpCreateGeometryGroup:
6229 op = new SMESHGUI_GroupOnShapeOp();
6231 case SMESHOp::OpFindElementByPoint:
6232 op = new SMESHGUI_FindElemByPointOp();
6234 case SMESHOp::OpMoveNode: // Make mesh pass through point
6235 op = new SMESHGUI_MakeNodeAtPointOp();
6237 case SMESHOp::OpMoveNodeInteractive: // Make mesh pass through point / by mouse
6238 op = new SMESHGUI_MakeNodeAtPointOp( 2 );
6240 case SMESHOp::OpRemoveNodeWithReconn:
6241 op = new SMESHGUI_RemoveNodeReconnectionOp();
6243 case SMESHOp::OpSplitEdgeInteract:
6244 op = new SMESHGUI_AddNodeOnSegmentOp();
6246 case SMESHOp::OpSplitFaceInteract:
6247 op = new SMESHGUI_AddNodeOnFaceOp();
6249 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
6250 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
6257 op = SalomeApp_Module::createOperation( id );
6261 //================================================================================
6263 * \brief Stops current operations and starts a given one
6264 * \param id - The id of the operation to start
6266 //================================================================================
6268 void SMESHGUI::switchToOperation(int id)
6270 activeStudy()->abortAllOperations();
6271 startOperation( id );
6274 LightApp_Displayer* SMESHGUI::displayer()
6277 myDisplayer = new SMESHGUI_Displayer( getApp() );
6281 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
6284 int aTolerance = 64;
6285 int anIterations = 0;
6291 if( anIterations % aPeriod == 0 )
6294 if( aTolerance < 1 )
6298 aHue = (int)( 360.0 * rand() / RAND_MAX );
6301 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
6302 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
6303 for( ; it != itEnd; ++it )
6305 SALOMEDS::Color anAutoColor = *it;
6306 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
6309 aQColor.getHsv( &h, &s, &v );
6310 if( abs( h - aHue ) < aTolerance )
6322 aColor.setHsv( aHue, 255, 255 );
6324 SALOMEDS::Color aSColor;
6325 aSColor.R = aColor.redF();
6326 aSColor.G = aColor.greenF();
6327 aSColor.B = aColor.blueF();
6332 const char* gSeparator = "_"; // character used to separate parameter names
6333 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
6334 const char* gPathSep = "|"; // character used to separate paths
6337 * \brief Store visual parameters
6339 * This method is called just before the study document is saved.
6340 * Store visual parameters in AttributeParameter attribute(s)
6342 void SMESHGUI::storeVisualParameters (int savePoint)
6345 Kernel_Utils::Localizer loc;
6347 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6348 if (!appStudy || !appStudy->studyDS())
6350 _PTR(Study) studyDS = appStudy->studyDS();
6352 // componentName is used for encoding of entries when storing them in IParameters
6353 std::string componentName = myComponentSMESH->ComponentDataType();
6354 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
6355 //if (!aSComponent) return;
6358 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6359 componentName.c_str(),
6361 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6363 // store custom markers
6364 if( !myMarkerMap.empty() )
6366 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
6367 for( ; anIter != myMarkerMap.end(); anIter++ )
6369 int anId = anIter->first;
6370 VTK::MarkerData aMarkerData = anIter->second;
6371 std::string aMarkerFileName = aMarkerData.first;
6372 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
6373 if( aMarkerTexture.size() < 3 )
6374 continue; // should contain at least width, height and the first value
6376 QString aPropertyName( "texture" );
6377 aPropertyName += gSeparator;
6378 aPropertyName += QString::number( anId );
6380 QString aPropertyValue = aMarkerFileName.c_str();
6381 aPropertyValue += gPathSep;
6383 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
6384 ushort aWidth = *aTextureIter++;
6385 ushort aHeight = *aTextureIter++;
6386 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
6387 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
6388 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
6389 aPropertyValue += QString::number( *aTextureIter );
6391 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6395 // viewers counters are used for storing view_numbers in IParameters
6398 // main cycle to store parameters of displayed objects
6399 QList<SUIT_ViewManager*> lst;
6400 QList<SUIT_ViewManager*>::Iterator it;
6401 getApp()->viewManagers(lst);
6402 for (it = lst.begin(); it != lst.end(); it++)
6404 SUIT_ViewManager* vman = *it;
6405 QString vType = vman->getType();
6407 // saving VTK actors properties
6408 if (vType == SVTK_Viewer::Type())
6410 // store the clipping planes attached to the view manager
6411 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
6412 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
6413 if( anIter != myClippingPlaneInfoMap.end() )
6414 aClippingPlaneInfoList = anIter->second;
6416 if( !aClippingPlaneInfoList.empty() ) {
6417 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
6418 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
6420 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
6421 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
6423 QString aPropertyName( "ClippingPlane" );
6424 aPropertyName += gSeparator;
6425 aPropertyName += QString::number( vtkViewers );
6426 aPropertyName += gSeparator;
6427 aPropertyName += QString::number( anId );
6429 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
6430 aPropertyValue += gDigitsSep;
6431 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
6432 aPropertyValue += gDigitsSep;
6433 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6434 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
6435 aPropertyValue += gDigitsSep;
6436 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
6437 aPropertyValue += gDigitsSep;
6438 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
6439 aPropertyValue += gDigitsSep;
6440 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
6441 aPropertyValue += gDigitsSep;
6442 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
6443 aPropertyValue += gDigitsSep;
6444 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
6445 aPropertyValue += gDigitsSep;
6446 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
6448 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6449 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
6450 aPropertyValue += gDigitsSep;
6451 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
6452 aPropertyValue += gDigitsSep;
6453 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
6454 aPropertyValue += gDigitsSep;
6455 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
6458 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
6462 QVector<SUIT_ViewWindow*> views = vman->getViews();
6463 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
6465 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
6467 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
6468 vtkActorCollection* allActors = aCopy.GetActors();
6469 allActors->InitTraversal();
6470 while (vtkActor* actor = allActors->GetNextActor())
6472 if (actor->GetVisibility()) // store only visible actors
6474 SMESH_Actor* aSmeshActor = 0;
6475 if (actor->IsA("SMESH_Actor"))
6476 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
6477 if (aSmeshActor && aSmeshActor->hasIO())
6479 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
6482 // entry is "encoded" = it does NOT contain component address,
6483 // since it is a subject to change on next component loading
6484 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
6486 std::string param, vtkParam = vType.toLatin1().data();
6487 vtkParam += gSeparator;
6488 vtkParam += QString::number(vtkViewers).toLatin1().data();
6489 vtkParam += gSeparator;
6492 param = vtkParam + "Visibility";
6493 ip->setParameter(entry, param, "On");
6496 param = vtkParam + "Representation";
6497 ip->setParameter(entry, param, QString::number
6498 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
6501 param = vtkParam + "IsShrunk";
6502 ip->setParameter(entry, param, QString::number
6503 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
6505 // Displayed entities
6506 unsigned int aMode = aSmeshActor->GetEntityMode();
6507 bool isE = aMode & SMESH_Actor::eEdges;
6508 bool isF = aMode & SMESH_Actor::eFaces;
6509 bool isV = aMode & SMESH_Actor::eVolumes;
6510 bool is0d = aMode & SMESH_Actor::e0DElements;
6511 bool isB = aMode & SMESH_Actor::eBallElem;
6513 QString modeStr ("e");
6514 modeStr += gDigitsSep; modeStr += QString::number(isE);
6515 modeStr += gDigitsSep; modeStr += "f";
6516 modeStr += gDigitsSep; modeStr += QString::number(isF);
6517 modeStr += gDigitsSep; modeStr += "v";
6518 modeStr += gDigitsSep; modeStr += QString::number(isV);
6519 modeStr += gDigitsSep; modeStr += "0d";
6520 modeStr += gDigitsSep; modeStr += QString::number(is0d);
6521 modeStr += gDigitsSep; modeStr += "b";
6522 modeStr += gDigitsSep; modeStr += QString::number(isB);
6524 param = vtkParam + "Entities";
6525 ip->setParameter(entry, param, modeStr.toLatin1().data());
6531 aSmeshActor->GetSufaceColor(r, g, b, delta);
6532 QStringList colorStr;
6533 colorStr << "surface";
6534 colorStr << QString::number(r);
6535 colorStr << QString::number(g);
6536 colorStr << QString::number(b);
6538 colorStr << "backsurface";
6539 colorStr << QString::number(delta);
6541 aSmeshActor->GetVolumeColor(r, g, b, delta);
6542 colorStr << "volume";
6543 colorStr << QString::number(r);
6544 colorStr << QString::number(g);
6545 colorStr << QString::number(b);
6546 colorStr << QString::number(delta);
6548 aSmeshActor->GetEdgeColor(r, g, b);
6550 colorStr << QString::number(r);
6551 colorStr << QString::number(g);
6552 colorStr << QString::number(b);
6554 aSmeshActor->GetNodeColor(r, g, b);
6556 colorStr << QString::number(r);
6557 colorStr << QString::number(g);
6558 colorStr << QString::number(b);
6560 aSmeshActor->GetOutlineColor(r, g, b);
6561 colorStr << "outline";
6562 colorStr << QString::number(r);
6563 colorStr << QString::number(g);
6564 colorStr << QString::number(b);
6566 aSmeshActor->Get0DColor(r, g, b);
6567 colorStr << "elem0d";
6568 colorStr << QString::number(r);
6569 colorStr << QString::number(g);
6570 colorStr << QString::number(b);
6572 aSmeshActor->GetBallColor(r, g, b);
6574 colorStr << QString::number(r);
6575 colorStr << QString::number(g);
6576 colorStr << QString::number(b);
6578 aSmeshActor->GetFacesOrientationColor(r, g, b);
6579 colorStr << "orientation";
6580 colorStr << QString::number(r);
6581 colorStr << QString::number(g);
6582 colorStr << QString::number(b);
6584 param = vtkParam + "Colors";
6585 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6588 QStringList sizeStr;
6590 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6591 sizeStr << "outline";
6592 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6593 sizeStr << "elem0d";
6594 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6596 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6597 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6598 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6599 sizeStr << "shrink";
6600 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6601 sizeStr << "orientation";
6602 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6603 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6605 param = vtkParam + "Sizes";
6606 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6611 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6612 if( aMarkerType == VTK::MT_USER ) {
6613 markerStr += "custom";
6614 markerStr += gDigitsSep;
6615 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6619 markerStr += gDigitsSep;
6620 markerStr += QString::number( (int)aMarkerType );
6621 markerStr += gDigitsSep;
6622 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6625 param = vtkParam + "PointMarker";
6626 ip->setParameter(entry, param, markerStr.toLatin1().data());
6629 param = vtkParam + "Opacity";
6630 ip->setParameter(entry, param,
6631 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6634 param = vtkParam + "ClippingPlane";
6636 if( !aClippingPlaneInfoList.empty() ) {
6637 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6638 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6640 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6641 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6642 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6643 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6644 if( aSmeshActor == *anIter2 ) {
6645 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6646 QString::number( anId ).toLatin1().constData() );
6653 ip->setParameter( entry, param, "Off" );
6654 } // if (io->hasEntry())
6655 } // SMESH_Actor && hasIO
6657 } // while.. actors traversal
6661 } // if (SVTK view model)
6662 } // for (viewManagers)
6665 // data structures for clipping planes processing
6669 bool isOpenGLClipping;
6670 vtkIdType RelativeOrientation;
6673 int AbsoluteOrientation;
6674 double X, Y, Z, Dx, Dy, Dz;
6676 typedef std::list<TPlaneData> TPlaneDataList;
6677 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6679 typedef std::list<vtkActor*> TActorList;
6682 TActorList ActorList;
6683 SUIT_ViewManager* ViewManager;
6685 typedef std::list<TPlaneInfo> TPlaneInfoList;
6686 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6689 * \brief Restore visual parameters
6691 * This method is called after the study document is opened.
6692 * Restore visual parameters from AttributeParameter attribute(s)
6694 void SMESHGUI::restoreVisualParameters (int savePoint)
6697 Kernel_Utils::Localizer loc;
6699 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6700 if (!appStudy || !appStudy->studyDS())
6702 _PTR(Study) studyDS = appStudy->studyDS();
6704 // componentName is used for encoding of entries when storing them in IParameters
6705 std::string componentName = myComponentSMESH->ComponentDataType();
6708 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6709 componentName.c_str(),
6711 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6713 // restore custom markers and map of clipping planes
6714 TPlaneDataMap aPlaneDataMap;
6716 std::vector<std::string> properties = ip->getProperties();
6717 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6719 std::string property = *propIt;
6720 QString aPropertyName( property.c_str() );
6721 QString aPropertyValue( ip->getProperty( property ).c_str() );
6723 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6724 if( aPropertyNameList.isEmpty() )
6727 QString aPropertyType = aPropertyNameList[0];
6728 if( aPropertyType == "texture" )
6730 if( aPropertyNameList.size() != 2 )
6734 int anId = aPropertyNameList[1].toInt( &ok );
6735 if( !ok || anId < 1 )
6738 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6739 if( aPropertyValueList.size() != 2 )
6742 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6743 QString aMarkerTextureString = aPropertyValueList[1];
6744 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6745 if( aMarkerTextureStringList.size() != 3 )
6749 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6754 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6758 VTK::MarkerTexture aMarkerTexture;
6759 aMarkerTexture.push_back( aWidth );
6760 aMarkerTexture.push_back( aHeight );
6762 QString aMarkerTextureData = aMarkerTextureStringList[2];
6763 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6765 QChar aChar = aMarkerTextureData.at( i );
6766 if( aChar.isDigit() )
6767 aMarkerTexture.push_back( aChar.digitValue() );
6770 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6772 else if( aPropertyType == "ClippingPlane" )
6774 if( aPropertyNameList.size() != 3 )
6778 int aViewId = aPropertyNameList[1].toInt( &ok );
6779 if( !ok || aViewId < 0 )
6783 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6784 if( !ok || aClippingPlaneId < 0 )
6787 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6788 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6791 TPlaneData aPlaneData;
6792 aPlaneData.AbsoluteOrientation = false;
6793 aPlaneData.RelativeOrientation = 0;
6794 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6795 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6796 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6798 aPlaneData.Id = aClippingPlaneId;
6801 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6806 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6810 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6813 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6818 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6823 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6828 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6833 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6838 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6843 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6847 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6849 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6854 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6859 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6864 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6869 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6870 aPlaneDataList.push_back( aPlaneData );
6874 TPlaneInfoMap aPlaneInfoMap;
6876 std::vector<std::string> entries = ip->getEntries();
6878 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6880 // entry is a normal entry - it should be "decoded" (setting base address of component)
6881 QString entry (ip->decodeEntry(*entIt).c_str());
6883 // Check that the entry corresponds to a real object in the Study
6884 // as the object may be deleted or modified after the visual state is saved.
6885 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6886 if (!so) continue; //Skip the not existent entry
6888 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6889 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6891 std::vector<std::string>::iterator namesIt = paramNames.begin();
6892 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6894 // actors are stored in a map after displaying of them for
6895 // quicker access in the future: map < viewID to actor >
6896 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6898 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6900 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6901 // '_' is used as separator and should not be used in viewer type or parameter names.
6902 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6903 if (lst.size() != 3)
6906 QString viewerTypStr = lst[0];
6907 QString viewIndexStr = lst[1];
6908 QString paramNameStr = lst[2];
6911 int viewIndex = viewIndexStr.toUInt(&ok);
6912 if (!ok) // bad conversion of view index to integer
6916 if (viewerTypStr == SVTK_Viewer::Type())
6918 SMESH_Actor* aSmeshActor = 0;
6919 if (vtkActors.IsBound(viewIndex))
6920 aSmeshActor = vtkActors.Find(viewIndex);
6922 QList<SUIT_ViewManager*> lst;
6923 getApp()->viewManagers(viewerTypStr, lst);
6925 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6926 SUIT_ViewManager* vman = NULL;
6927 if (viewIndex >= 0 && viewIndex < lst.count())
6928 vman = lst.at(viewIndex);
6930 if (paramNameStr == "Visibility")
6932 if (!aSmeshActor && displayer() && vman)
6934 SUIT_ViewModel* vmodel = vman->getViewModel();
6935 // SVTK view model can be casted to SALOME_View
6936 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6938 // store displayed actor in a temporary map for quicker
6939 // access later when restoring other parameters
6940 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6941 vtkRenderer* Renderer = vtkView->getRenderer();
6942 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6943 vtkActorCollection* theActors = aCopy.GetActors();
6944 theActors->InitTraversal();
6945 bool isFound = false;
6946 vtkActor *ac = theActors->GetNextActor();
6947 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6948 if (ac->IsA("SMESH_Actor")) {
6949 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6950 if (aGeomAc->hasIO()) {
6951 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6952 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6954 vtkActors.Bind(viewIndex, aGeomAc);
6960 } // if (paramNameStr == "Visibility")
6963 // the rest properties "work" with SMESH_Actor
6966 QString val ((*valuesIt).c_str());
6969 if (paramNameStr == "Representation") {
6970 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6973 else if (paramNameStr == "IsShrunk") {
6975 if (!aSmeshActor->IsShrunk())
6976 aSmeshActor->SetShrink();
6979 if (aSmeshActor->IsShrunk())
6980 aSmeshActor->UnShrink();
6983 // Displayed entities
6984 else if (paramNameStr == "Entities") {
6985 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6986 int aEntityMode = SMESH_Actor::eAllEntity;
6987 for ( int i = 0; i < mode.count(); i+=2 ) {
6988 if ( i < mode.count()-1 ) {
6989 QString type = mode[i];
6990 bool val = mode[i+1].toInt();
6991 if ( type == "e" && !val )
6992 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6993 else if ( type == "f" && !val )
6994 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6995 else if ( type == "v" && !val )
6996 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6997 else if ( type == "0d" && !val )
6998 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6999 else if ( type == "b" && !val )
7000 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
7003 aSmeshActor->SetEntityMode( aEntityMode );
7006 else if (paramNameStr == "Colors") {
7007 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
7014 QColor outlineColor;
7015 QColor orientationColor;
7021 // below lines are required to get default values for delta coefficients
7022 // of backface color for faces and color of reversed volumes
7023 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
7024 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
7025 for ( int i = 0; i < colors.count(); i++ ) {
7026 QString type = colors[i];
7027 if ( type == "surface" ) {
7028 // face color is set by 3 values r:g:b, where
7029 // - r,g,b - is rgb color components
7030 if ( i+1 >= colors.count() ) break; // format error
7031 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7032 if ( i+2 >= colors.count() ) break; // format error
7033 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7034 if ( i+3 >= colors.count() ) break; // format error
7035 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7036 faceColor.setRgbF( r, g, b );
7039 else if ( type == "backsurface" ) {
7040 // backface color can be defined in several ways
7041 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
7042 // - in latest versions, it is set as delta coefficient
7043 bool rgbOk = false, deltaOk;
7044 if ( i+1 >= colors.count() ) break; // format error
7045 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7046 int delta = colors[i+1].toInt( &deltaOk );
7048 if ( i+1 < colors.count() ) // index is shifted to 1
7049 g = colors[i+1].toDouble( &rgbOk );
7050 if ( rgbOk ) i++; // shift index
7051 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
7052 b = colors[i+1].toDouble( &rgbOk );
7054 // - as currently there's no way to set directly backsurface color as it was before,
7055 // we ignore old dump where r,g,b triple was set
7056 // - also we check that delta parameter is set properly
7057 if ( !rgbOk && deltaOk )
7060 else if ( type == "volume" ) {
7061 // volume color is set by 4 values r:g:b:delta, where
7062 // - r,g,b - is a normal volume rgb color components
7063 // - delta - is a reversed volume color delta coefficient
7064 if ( i+1 >= colors.count() ) break; // format error
7065 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7066 if ( i+2 >= colors.count() ) break; // format error
7067 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7068 if ( i+3 >= colors.count() ) break; // format error
7069 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7070 if ( i+4 >= colors.count() ) break; // format error
7071 int delta = colors[i+4].toInt( &bOk );
7072 if ( !bOk ) break; // format error
7073 volumeColor.setRgbF( r, g, b );
7077 else if ( type == "edge" ) {
7078 // edge color is set by 3 values r:g:b, where
7079 // - r,g,b - is rgb color components
7080 if ( i+1 >= colors.count() ) break; // format error
7081 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7082 if ( i+2 >= colors.count() ) break; // format error
7083 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7084 if ( i+3 >= colors.count() ) break; // format error
7085 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7086 edgeColor.setRgbF( r, g, b );
7089 else if ( type == "node" ) {
7090 // node color is set by 3 values r:g:b, where
7091 // - r,g,b - is rgb color components
7092 if ( i+1 >= colors.count() ) break; // format error
7093 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7094 if ( i+2 >= colors.count() ) break; // format error
7095 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7096 if ( i+3 >= colors.count() ) break; // format error
7097 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7098 nodeColor.setRgbF( r, g, b );
7101 else if ( type == "elem0d" ) {
7102 // 0d element color is set by 3 values r:g:b, where
7103 // - r,g,b - is rgb color components
7104 if ( i+1 >= colors.count() ) break; // format error
7105 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7106 if ( i+2 >= colors.count() ) break; // format error
7107 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7108 if ( i+3 >= colors.count() ) break; // format error
7109 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7110 elem0dColor.setRgbF( r, g, b );
7113 else if ( type == "ball" ) {
7114 // ball color is set by 3 values r:g:b, where
7115 // - r,g,b - is rgb color components
7116 if ( i+1 >= colors.count() ) break; // format error
7117 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7118 if ( i+2 >= colors.count() ) break; // format error
7119 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7120 if ( i+3 >= colors.count() ) break; // format error
7121 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7122 ballColor.setRgbF( r, g, b );
7125 else if ( type == "outline" ) {
7126 // outline color is set by 3 values r:g:b, where
7127 // - r,g,b - is rgb color components
7128 if ( i+1 >= colors.count() ) break; // format error
7129 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7130 if ( i+2 >= colors.count() ) break; // format error
7131 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7132 if ( i+3 >= colors.count() ) break; // format error
7133 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7134 outlineColor.setRgbF( r, g, b );
7137 else if ( type == "orientation" ) {
7138 // orientation color is set by 3 values r:g:b, where
7139 // - r,g,b - is rgb color components
7140 if ( i+1 >= colors.count() ) break; // format error
7141 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7142 if ( i+2 >= colors.count() ) break; // format error
7143 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7144 if ( i+3 >= colors.count() ) break; // format error
7145 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
7146 orientationColor.setRgbF( r, g, b );
7151 if ( nodeColor.isValid() )
7152 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
7154 if ( edgeColor.isValid() )
7155 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
7157 if ( faceColor.isValid() )
7158 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7160 if ( volumeColor.isValid() )
7161 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
7162 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
7163 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
7165 if ( elem0dColor.isValid() )
7166 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
7168 if ( ballColor.isValid() )
7169 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
7171 if ( outlineColor.isValid() )
7172 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
7173 // orientation color
7174 if ( orientationColor.isValid() )
7175 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
7178 else if (paramNameStr == "Sizes") {
7179 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
7182 int outlineWidth = -1;
7183 int elem0dSize = -1;
7184 //int ballSize = -1;
7185 double ballDiameter = -1.0;
7186 double ballScale = -1.0;
7187 double shrinkSize = -1;
7188 double orientationSize = -1;
7189 bool orientation3d = false;
7190 for ( int i = 0; i < sizes.count(); i++ ) {
7191 QString type = sizes[i];
7192 if ( type == "line" ) {
7193 // line (wireframe) width is given as single integer value
7194 if ( i+1 >= sizes.count() ) break; // format error
7195 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7199 if ( type == "outline" ) {
7200 // outline width is given as single integer value
7201 if ( i+1 >= sizes.count() ) break; // format error
7202 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7206 else if ( type == "elem0d" ) {
7207 // 0d element size is given as single integer value
7208 if ( i+1 >= sizes.count() ) break; // format error
7209 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7213 else if ( type == "ball" ) {
7214 // balls are specified by two values: size:scale, where
7215 // - size - is a integer value specifying size
7216 // - scale - is a double value specifying scale factor
7217 if ( i+1 >= sizes.count() ) break; // format error
7218 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7219 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
7220 if ( i+2 >= sizes.count() ) break; // format error
7221 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
7227 else if ( type == "shrink" ) {
7228 // shrink factor is given as single floating point value
7229 if ( i+1 >= sizes.count() ) break; // format error
7230 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7234 else if ( type == "orientation" ) {
7235 // orientation vectors are specified by two values size:3d, where
7236 // - size - is a floating point value specifying scale factor
7237 // - 3d - is a boolean
7238 if ( i+1 >= sizes.count() ) break; // format error
7239 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
7240 if ( i+2 >= sizes.count() ) break; // format error
7241 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
7242 orientationSize = v1;
7243 orientation3d = (bool)v2;
7247 // line (wireframe) width
7248 if ( lineWidth > 0 )
7249 aSmeshActor->SetLineWidth( lineWidth );
7251 if ( outlineWidth > 0 )
7252 aSmeshActor->SetOutlineWidth( outlineWidth );
7253 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
7254 aSmeshActor->SetOutlineWidth( lineWidth );
7256 if ( elem0dSize > 0 )
7257 aSmeshActor->Set0DSize( elem0dSize );
7259 /*if ( ballSize > 0 )
7260 aSmeshActor->SetBallSize( ballSize );*/
7262 if ( ballDiameter > 0 )
7263 aSmeshActor->SetBallSize( ballDiameter );
7265 if ( ballScale > 0.0 )
7266 aSmeshActor->SetBallScale( ballScale );
7268 if ( shrinkSize > 0 )
7269 aSmeshActor->SetShrinkFactor( shrinkSize );
7270 // orientation vectors
7271 if ( orientationSize > 0 ) {
7272 aSmeshActor->SetFacesOrientationScale( orientationSize );
7273 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
7277 else if (paramNameStr == "PointMarker") {
7278 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
7279 if( data.count() >= 2 ) {
7281 int aParam1 = data[1].toInt( &ok );
7283 if( data[0] == "std" && data.count() == 3 ) {
7284 int aParam2 = data[2].toInt( &ok );
7285 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
7287 else if( data[0] == "custom" ) {
7288 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
7289 if( markerIt != myMarkerMap.end() ) {
7290 VTK::MarkerData aMarkerData = markerIt->second;
7291 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
7298 else if (paramNameStr == "Opacity") {
7299 aSmeshActor->SetOpacity(val.toFloat());
7302 else if (paramNameStr.startsWith("ClippingPlane")) {
7303 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
7304 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
7305 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
7306 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
7307 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
7308 // new format - val looks like "Off" or "0" (plane id)
7309 // (note: in new format "Off" value is used only for consistency,
7310 // so it is processed together with values in old format)
7311 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
7312 if( anIsOldFormat ) {
7313 if (paramNameStr == "ClippingPlane1" || val == "Off")
7314 aSmeshActor->RemoveAllClippingPlanes();
7316 QList<SUIT_ViewManager*> lst;
7317 getApp()->viewManagers(viewerTypStr, lst);
7318 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
7319 if (viewIndex >= 0 && viewIndex < lst.count()) {
7320 SUIT_ViewManager* vman = lst.at(viewIndex);
7321 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
7323 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
7325 SMESH::TActorList anActorList;
7326 anActorList.push_back( aSmeshActor );
7327 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
7328 aPlane->myViewWindow = vtkView;
7329 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
7330 aPlane->PlaneMode = aMode;
7331 bool isOpenGLClipping = ( bool )vals[1].toInt();
7332 aPlane->IsOpenGLClipping = isOpenGLClipping;
7333 if ( aMode == SMESH::Absolute ) {
7334 aPlane->myAbsoluteOrientation = vals[2].toInt();
7335 aPlane->X = vals[3].toFloat();
7336 aPlane->Y = vals[4].toFloat();
7337 aPlane->Z = vals[5].toFloat();
7338 aPlane->Dx = vals[6].toFloat();
7339 aPlane->Dy = vals[7].toFloat();
7340 aPlane->Dz = vals[8].toFloat();
7342 else if ( aMode == SMESH::Relative ) {
7343 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
7344 aPlane->myDistance = vals[3].toFloat();
7345 aPlane->myAngle[0] = vals[4].toFloat();
7346 aPlane->myAngle[1] = vals[5].toFloat();
7350 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7351 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7352 aClippingPlaneInfo.Plane = aPlane;
7353 aClippingPlaneInfo.ActorList = anActorList;
7354 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7362 int aPlaneId = val.toInt( &ok );
7363 if( ok && aPlaneId >= 0 ) {
7364 bool anIsDefinedPlane = false;
7365 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
7366 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
7367 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7368 TPlaneInfo& aPlaneInfo = *anIter;
7369 if( aPlaneInfo.PlaneId == aPlaneId ) {
7370 aPlaneInfo.ActorList.push_back( aSmeshActor );
7371 anIsDefinedPlane = true;
7375 if( !anIsDefinedPlane ) {
7376 TPlaneInfo aPlaneInfo;
7377 aPlaneInfo.PlaneId = aPlaneId;
7378 aPlaneInfo.ActorList.push_back( aSmeshActor );
7379 aPlaneInfo.ViewManager = vman;
7381 // to make the list sorted by plane id
7382 anIter = aPlaneInfoList.begin();
7383 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
7384 const TPlaneInfo& aPlaneInfoRef = *anIter;
7385 if( aPlaneInfoRef.PlaneId > aPlaneId )
7388 aPlaneInfoList.insert( anIter, aPlaneInfo );
7393 } // if (aSmeshActor)
7394 } // other parameters than Visibility
7396 } // for names/parameters iterator
7397 } // for entries iterator
7399 // take into account planes with empty list of actors referred to them
7400 QList<SUIT_ViewManager*> aVMList;
7401 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
7403 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
7404 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
7405 int aViewId = aPlaneDataIter->first;
7406 if( aViewId >= 0 && aViewId < aVMList.count() ) {
7407 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
7409 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
7411 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
7412 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
7413 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
7414 const TPlaneData& aPlaneData = *anIter2;
7415 int aPlaneId = aPlaneData.Id;
7417 bool anIsFound = false;
7418 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7419 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7420 const TPlaneInfo& aPlaneInfo = *anIter3;
7421 if( aPlaneInfo.PlaneId == aPlaneId ) {
7428 TPlaneInfo aPlaneInfo; // ActorList field is empty
7429 aPlaneInfo.PlaneId = aPlaneId;
7430 aPlaneInfo.ViewManager = aViewManager;
7432 // to make the list sorted by plane id
7433 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
7434 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
7435 const TPlaneInfo& aPlaneInfoRef = *anIter4;
7436 if( aPlaneInfoRef.PlaneId > aPlaneId )
7439 aPlaneInfoList.insert( anIter4, aPlaneInfo );
7445 // add clipping planes to actors according to the restored parameters
7446 // and update the clipping plane map
7447 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
7448 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
7449 int aViewId = anIter1->first;
7450 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
7452 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
7453 if( anIter2 == aPlaneDataMap.end() )
7455 const TPlaneDataList& aPlaneDataList = anIter2->second;
7457 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
7458 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
7459 const TPlaneInfo& aPlaneInfo = *anIter3;
7460 int aPlaneId = aPlaneInfo.PlaneId;
7461 const TActorList& anActorList = aPlaneInfo.ActorList;
7462 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
7466 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
7470 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
7472 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
7473 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
7474 const TPlaneData& aPlaneData = *anIter4;
7475 if( aPlaneData.Id == aPlaneId ) {
7476 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
7477 aPlane->myViewWindow = aViewWindow;
7478 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
7479 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
7480 if ( aPlane->PlaneMode == SMESH::Absolute ) {
7481 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
7482 aPlane->X = aPlaneData.X;
7483 aPlane->Y = aPlaneData.Y;
7484 aPlane->Z = aPlaneData.Z;
7485 aPlane->Dx = aPlaneData.Dx;
7486 aPlane->Dy = aPlaneData.Dy;
7487 aPlane->Dz = aPlaneData.Dz;
7489 else if ( aPlane->PlaneMode == SMESH::Relative ) {
7490 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
7491 aPlane->myDistance = aPlaneData.Distance;
7492 aPlane->myAngle[0] = aPlaneData.Angle[0];
7493 aPlane->myAngle[1] = aPlaneData.Angle[1];
7496 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
7497 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
7498 aClippingPlaneInfo.Plane = aPlane;
7499 aClippingPlaneInfo.ActorList = anActorList;
7500 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
7511 // update all VTK views
7512 QList<SUIT_ViewManager*> lst;
7513 getApp()->viewManagers(lst);
7514 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
7515 SUIT_ViewModel* vmodel = (*it)->getViewModel();
7516 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
7517 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
7518 // set OpenGL clipping planes
7519 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
7520 vtkActorCollection* anAllActors = aCopy.GetActors();
7521 anAllActors->InitTraversal();
7522 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
7523 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
7524 anActor->SetOpenGLClippingPlane();
7526 vtkView->getRenderer()->ResetCameraClippingRange();
7533 \brief Adds preferences for dfont of VTK viewer
7535 \param pIf group identifier
7536 \param param parameter
7537 \return identifier of preferences
7539 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
7541 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
7543 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
7546 fam.append( tr( "SMESH_FONT_ARIAL" ) );
7547 fam.append( tr( "SMESH_FONT_COURIER" ) );
7548 fam.append( tr( "SMESH_FONT_TIMES" ) );
7550 setPreferenceProperty( tfont, "fonts", fam );
7552 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
7553 if ( needSize ) f = f | QtxFontEdit::Size;
7554 setPreferenceProperty( tfont, "features", f );
7560 \brief Actions after hypothesis edition
7561 Updates object browser after hypothesis edition
7563 void SMESHGUI::onHypothesisEdit( int result )
7566 SMESHGUI::Modified();
7567 updateObjBrowser( true );
7571 \brief Actions after choosing menu of control modes
7572 Updates control mode actions according to current selection
7574 void SMESHGUI::onUpdateControlActions()
7576 SALOME_ListIO selected;
7577 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7578 aSel->selectedObjects( selected );
7580 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7581 if ( selected.Extent() ) {
7582 if ( selected.First()->hasEntry() ) {
7583 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7584 aControl = anActor->GetControlMode();
7585 SALOME_ListIteratorOfListIO it(selected);
7586 for ( it.Next(); it.More(); it.Next() ) {
7587 Handle(SALOME_InteractiveObject) anIO = it.Value();
7588 if ( anIO->hasEntry() ) {
7589 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7590 if ( aControl != anActor->GetControlMode() ) {
7591 aControl = SMESH_Actor::eNone;
7601 int anAction = ActionToControl( aControl, true );
7603 action( anAction )->setChecked( true );
7605 QMenu* send = (QMenu*)sender();
7606 QList<QAction*> actions = send->actions();
7607 for ( int i = 0; i < actions.size(); i++ )
7608 actions[i]->setChecked( false );
7614 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7615 \param pview view being closed
7617 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7618 #ifndef DISABLE_PLOT2DVIEWER
7619 //Crear all Plot2d Viewers if need.
7620 SMESH::ClearPlot2Viewers(pview);
7622 EmitSignalCloseView();
7625 void SMESHGUI::message( const QString& msg )
7628 QStringList data = msg.split("/");
7629 if ( data.count() > 0 ) {
7630 if ( data.first() == "mesh_loading" ) {
7632 QString entry = data.count() > 1 ? data[1] : QString();
7633 if ( entry.isEmpty() )
7636 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7638 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7641 name = SMESH::fromUtf8(obj->GetName());
7642 if ( name.isEmpty() )
7645 if ( data.last() == "stop" )
7646 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7648 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7649 QApplication::processEvents();
7655 \brief Connects or disconnects signals about activating and cloning view on the module slots
7656 \param pview view which is connected/disconnected
7658 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7662 SUIT_ViewManager* viewMgr = pview->getViewManager();
7664 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7665 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7667 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7668 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7673 \brief Return \c true if object can be renamed
7675 bool SMESHGUI::renameAllowed( const QString& entry) const {
7676 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7680 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7684 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7689 if(appStudy->isComponent(entry) || obj->isReference())
7692 // check type to prevent renaming of inappropriate objects
7693 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7694 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7695 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7696 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7697 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7698 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7705 Rename object by entry.
7706 \param entry entry of the object
7707 \param name new name of the object
7708 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7710 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7712 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7716 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7721 _PTR(Study) aStudy = appStudy->studyDS();
7726 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7728 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7733 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7734 _PTR(GenericAttribute) anAttr;
7735 _PTR(AttributeName) aName;
7737 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7739 // check type to prevent renaming of inappropriate objects
7740 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7741 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7742 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7743 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7744 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7745 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7746 if ( !name.isEmpty() ) {
7747 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7749 // update name of group object and its actor
7750 Handle(SALOME_InteractiveObject) IObject =
7751 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7753 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7754 if( !aGroupObject->_is_nil() ) {
7755 aGroupObject->SetName( qUtf8Printable(name) );
7756 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7757 anActor->setName( qUtf8Printable(name) );
7767 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7769 static QList<QColor> colors;
7771 if ( colors.isEmpty() ) {
7773 for (int s = 0; s < 2 ; s++)
7775 for (int v = 100; v >= 40; v = v - 20)
7777 for (int h = 0; h < 359 ; h = h + 60)
7779 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7784 static int currentColor = randomize( colors.size() );
7786 SALOMEDS::Color color;
7787 color.R = (double)colors[currentColor].red() / 255.0;
7788 color.G = (double)colors[currentColor].green() / 255.0;
7789 color.B = (double)colors[currentColor].blue() / 255.0;
7791 currentColor = (currentColor+1) % colors.count();