1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FieldSelectorWdg.h"
48 #include "SMESHGUI_FileInfoDlg.h"
49 #include "SMESHGUI_FileValidator.h"
50 #include "SMESHGUI_FilterDlg.h"
51 #include "SMESHGUI_FilterLibraryDlg.h"
52 #include "SMESHGUI_FindElemByPointDlg.h"
53 #include "SMESHGUI_GroupDlg.h"
54 #include "SMESHGUI_GroupOnShapeDlg.h"
55 #include "SMESHGUI_GroupOpDlg.h"
56 #include "SMESHGUI_Hypotheses.h"
57 #include "SMESHGUI_Make2DFrom3DOp.h"
58 #include "SMESHGUI_MakeNodeAtPointDlg.h"
59 #include "SMESHGUI_Measurements.h"
60 #include "SMESHGUI_MergeDlg.h"
61 #include "SMESHGUI_MeshInfo.h"
62 #include "SMESHGUI_MeshOp.h"
63 #include "SMESHGUI_MeshOrderOp.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_MultiEditDlg.h"
66 #include "SMESHGUI_NodesDlg.h"
67 #include "SMESHGUI_Operations.h"
68 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
69 #include "SMESHGUI_PropertiesDlg.h"
70 #include "SMESHGUI_RemoveElementsDlg.h"
71 #include "SMESHGUI_RemoveNodesDlg.h"
72 #include "SMESHGUI_RenumberingDlg.h"
73 #include "SMESHGUI_ReorientFacesDlg.h"
74 #include "SMESHGUI_RevolutionDlg.h"
75 #include "SMESHGUI_RotationDlg.h"
76 #include "SMESHGUI_ScaleDlg.h"
77 #include "SMESHGUI_OffsetDlg.h"
78 #include "SMESHGUI_Selection.h"
79 #include "SMESHGUI_SewingDlg.h"
80 #include "SMESHGUI_SingleEditDlg.h"
81 #include "SMESHGUI_SmoothingDlg.h"
82 #include "SMESHGUI_SymmetryDlg.h"
83 #include "SMESHGUI_TranslationDlg.h"
84 #include "SMESHGUI_TransparencyDlg.h"
85 #include "SMESHGUI_DisplayEntitiesDlg.h"
86 #include "SMESHGUI_SplitBiQuad.h"
88 #include "SMESHGUI_FilterUtils.h"
89 #include "SMESHGUI_GEOMGenUtils.h"
90 #include "SMESHGUI_GroupUtils.h"
91 #include "SMESHGUI_HypothesesUtils.h"
92 #include "SMESHGUI_MeshUtils.h"
93 #include "SMESHGUI_PatternUtils.h"
94 #include "SMESHGUI_Utils.h"
95 #include "SMESHGUI_VTKUtils.h"
97 #include "SMESH_version.h"
99 #include "SMESH_ControlsDef.hxx"
100 #include "SMESH_Actor.h"
101 #include "SMESH_ActorUtils.h"
102 #include "SMESH_Client.hxx"
103 #include "SMESH_ScalarBarActor.h"
104 #include "SMESH_TypeFilter.hxx"
106 // SALOME GUI includes
107 #include <SalomeApp_Application.h>
108 #include <SalomeApp_CheckFileDlg.h>
109 #include <SalomeApp_DataObject.h>
110 #include <SalomeApp_Study.h>
111 #include <SalomeApp_Tools.h>
113 #include <LightApp_DataOwner.h>
114 #include <LightApp_NameDlg.h>
115 #include <LightApp_Preferences.h>
116 #include <LightApp_SelectionMgr.h>
117 #include <LightApp_UpdateFlags.h>
119 #include <SVTK_ViewManager.h>
120 #include <SVTK_ViewModel.h>
121 #include <SVTK_ViewWindow.h>
123 #include <VTKViewer_Algorithm.h>
125 #include <SUIT_Desktop.h>
126 #include <SUIT_FileDlg.h>
127 #include <SUIT_MessageBox.h>
128 #include <SUIT_OverrideCursor.h>
129 #include <SUIT_ResourceMgr.h>
130 #include <SUIT_Session.h>
132 #include <QtxPopupMgr.h>
133 #include <QtxFontEdit.h>
135 #include <SALOME_ListIO.hxx>
137 #ifndef DISABLE_PLOT2DVIEWER
138 #include <SPlot2d_ViewModel.h>
139 #include <SPlot2d_Histogram.h>
143 #include <SALOMEconfig.h>
144 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
145 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
146 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
147 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
150 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
151 #include <QApplication>
153 #include <QTextStream>
158 #include <QDialogButtonBox>
161 #include <boost/shared_ptr.hpp>
164 #include <vtkCallbackCommand.h>
165 #include <vtkCamera.h>
166 #include <vtkLookupTable.h>
167 #include <vtkPlane.h>
168 #include <vtkRenderer.h>
170 // SALOME KERNEL includes
171 #include <SALOMEDSClient_ClientFactory.hxx>
172 #include <SALOMEDSClient_IParameters.hxx>
173 #include <SALOMEDSClient_SComponent.hxx>
174 #include <SALOMEDSClient_StudyBuilder.hxx>
175 #include <SALOMEDS_Study.hxx>
176 #include <SALOMEDS_SObject.hxx>
177 #include "utilities.h"
180 #include <Standard_ErrorHandler.hxx>
181 #include <NCollection_DataMap.hxx>
182 #include <NCollection_DoubleMap.hxx>
184 #include <Basics_Utils.hxx>
186 // Below macro, when uncommented, switches on simplified (more performant) algorithm
187 // of auto-color picking up
188 #define SIMPLE_AUTOCOLOR
193 //=============================================================
194 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
197 void ExportMeshToFile(int theCommandID);
199 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
201 void SetDisplayEntity(int theCommandID);
203 int ActionToControl( int theID, bool theReversed = false );
205 void Control( int theCommandID );
208 //================================================================================
210 * \brief Reads meshes from file
212 //================================================================================
214 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
218 std::string myExtension;
220 if ( theCommandID == SMESHOp::OpImportMED ||
221 theCommandID == SMESHOp::OpPopupImportMED ) {
222 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
223 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
225 else if ( theCommandID == SMESHOp::OpImportUNV ||
226 theCommandID == SMESHOp::OpPopupImportUNV ) {
227 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
229 else if ( theCommandID == SMESHOp::OpImportDAT ||
230 theCommandID == SMESHOp::OpPopupImportDAT ) {
231 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
233 else if ( theCommandID == SMESHOp::OpImportSTL ||
234 theCommandID == SMESHOp::OpPopupImportSTL ) {
235 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
237 else if ( theCommandID == SMESHOp::OpImportCGNS ||
238 theCommandID == SMESHOp::OpPopupImportCGNS ) {
239 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
241 else if ( theCommandID == SMESHOp::OpImportSAUV ||
242 theCommandID == SMESHOp::OpPopupImportSAUV ) {
243 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
244 filter.append( QObject::tr( "All files (*)" ) );
246 else if ( theCommandID == SMESHOp::OpImportGMF ||
247 theCommandID == SMESHOp::OpPopupImportGMF ) {
248 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
249 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
252 QString anInitialPath = "";
253 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
254 anInitialPath = QDir::currentPath();
256 QStringList filenames;
257 bool toCreateGroups = true;
259 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
260 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
261 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
262 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
263 // fd->setNameFilters( filter );
264 // fd->SetChecked( true );
266 // filenames << fd->selectedFile();
267 // toCreateGroups = fd->IsChecked();
273 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
276 QObject::tr( "SMESH_IMPORT_MESH" ) );
278 if ( filenames.count() > 0 )
280 SUIT_OverrideCursor wc;
281 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
284 QStringList anEntryList;
285 bool isEmpty = false;
286 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
288 QString filename = *it;
289 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
291 switch ( theCommandID ) {
292 case SMESHOp::OpImportDAT:
293 case SMESHOp::OpPopupImportDAT:
295 // DAT format (currently unsupported)
296 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
297 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
300 case SMESHOp::OpImportUNV:
301 case SMESHOp::OpPopupImportUNV:
304 aMeshes->length( 1 );
305 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
306 if ( aMeshes[0]->_is_nil() )
307 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
308 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
311 case SMESHOp::OpImportMED:
312 case SMESHOp::OpPopupImportMED:
315 SMESH::DriverMED_ReadStatus res;
316 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
317 if ( res != SMESH::DRS_OK ) {
318 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
319 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
323 case SMESHOp::OpImportSTL:
324 case SMESHOp::OpPopupImportSTL:
327 aMeshes->length( 1 );
328 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
329 if ( aMeshes[0]->_is_nil() ) {
330 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
331 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
335 case SMESHOp::OpImportCGNS:
336 case SMESHOp::OpPopupImportCGNS:
339 SMESH::DriverMED_ReadStatus res;
340 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
341 if ( res != SMESH::DRS_OK ) {
342 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
343 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
347 case SMESHOp::OpImportSAUV:
348 case SMESHOp::OpPopupImportSAUV:
351 SMESH::DriverMED_ReadStatus res;
352 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
353 if ( res != SMESH::DRS_OK ) {
354 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
355 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
359 case SMESHOp::OpImportGMF:
360 case SMESHOp::OpPopupImportGMF:
363 SMESH::ComputeError_var res;
364 aMeshes->length( 1 );
365 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
368 if ( res->code != SMESH::DRS_OK ) {
369 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
370 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
371 if ( strlen( res->comment.in() ) > 0 ) {
372 errors.back() += ": ";
373 errors.back() += res->comment.in();
380 catch ( const SALOME::SALOME_Exception& S_ex ) {
381 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
382 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
385 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
387 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
389 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
390 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
391 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
392 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
393 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
395 anEntryList.append( aMeshSO->GetID().c_str() );
403 // update Object browser
404 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
406 // browse to the published meshes
407 if( LightApp_Application* anApp =
408 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
409 anApp->browseObjects( anEntryList );
411 // show Error message box if there were errors
412 if ( errors.count() > 0 ) {
413 SUIT_MessageBox::critical( SMESHGUI::desktop(),
414 QObject::tr( "SMESH_ERROR" ),
415 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
418 // show warning message box, if some imported mesh is empty
420 SUIT_MessageBox::warning( SMESHGUI::desktop(),
421 QObject::tr( "SMESH_WRN_WARNING" ),
422 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
427 //================================================================================
429 * \brief Export selected meshes or groups into a file
431 //================================================================================
433 void ExportMeshToFile( int theCommandID )
435 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
436 SALOME_ListIO selected;
438 aSel->selectedObjects( selected );
440 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
441 theCommandID == SMESHOp::OpPopupExportDAT );
442 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
443 theCommandID == SMESHOp::OpPopupExportMED );
444 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
445 theCommandID == SMESHOp::OpPopupExportUNV );
446 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
447 theCommandID == SMESHOp::OpPopupExportSTL );
448 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
449 theCommandID == SMESHOp::OpPopupExportCGNS );
450 const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV ||
451 theCommandID == SMESHOp::OpPopupExportSAUV );
452 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
453 theCommandID == SMESHOp::OpPopupExportGMF );
455 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
456 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
458 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
459 bool aCheckWarn = true;
461 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
462 // get mesh object from selection and check duplication of their names
463 bool hasDuplicatedMeshNames = false;
464 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
465 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
466 SALOME_ListIteratorOfListIO It( selected );
467 for( ; It.More(); It.Next() )
469 Handle(SALOME_InteractiveObject) anIObject = It.Value();
470 SMESH::SMESH_IDSource_var aMeshItem =
471 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
472 if ( aMeshItem->_is_nil() ) {
473 SUIT_MessageBox::warning( SMESHGUI::desktop(),
474 QObject::tr( "SMESH_WRN_WARNING" ),
475 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
478 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
479 if ( aCheckWarn && !aGroup->_is_nil() )
481 QMessageBox msgBox(SUIT_MessageBox::Warning,
482 QObject::tr("SMESH_WRN_WARNING"),
483 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
484 QMessageBox::StandardButton::NoButton,
485 SMESHGUI::desktop());
486 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
487 msgBox.addButton(QMessageBox::Ok);
488 msgBox.addButton(QMessageBox::Cancel);
489 msgBox.setDefaultButton(QMessageBox::Cancel);
490 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
491 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
492 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
493 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
494 if(msgBox.exec() == QMessageBox::Ok)
496 if(dontShowCheckBox.checkState() == Qt::Checked)
499 resMgr->setValue( "SMESH", "show_warning", false);
507 QString aMeshName = anIObject->getName();
509 // check for name duplications
510 if ( !hasDuplicatedMeshNames )
511 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
512 if( aMeshName == (*aMeshIter).second ) {
513 hasDuplicatedMeshNames = true;
518 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
521 if( hasDuplicatedMeshNames && isMED ) {
522 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
523 QObject::tr("SMESH_WRN_WARNING"),
524 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
525 QObject::tr("SMESH_BUT_YES"),
526 QObject::tr("SMESH_BUT_NO"), 0, 1);
531 aMeshIter = aMeshList.begin();
532 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
533 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
534 QString aMeshName = (*aMeshIter).second;
536 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
538 // check for equal group names within each mesh
539 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
540 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
541 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
542 int aRet = SUIT_MessageBox::warning
543 (SMESHGUI::desktop(),
544 QObject::tr("SMESH_WRN_WARNING"),
545 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
546 QObject::tr("SMESH_BUT_YES"),
547 QObject::tr("SMESH_BUT_NO"), 0, 1);
554 // Warn the user about presence of not supported elements
556 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
560 notSupportedElemTypes.push_back( SMESH::Entity_0D );
561 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
566 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
567 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
568 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
569 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
570 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
571 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
572 notSupportedElemTypes.push_back( SMESH::Entity_0D );
573 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
578 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
579 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
580 notSupportedElemTypes.push_back( SMESH::Entity_0D );
581 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
586 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
591 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
592 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
593 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
594 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
595 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
596 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
597 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
598 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
603 notSupportedElemTypes.push_back( SMESH::Entity_0D );
604 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
605 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
606 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
607 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
608 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
609 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
610 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
611 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
612 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
614 if ( ! notSupportedElemTypes.empty() )
616 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
617 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
618 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
619 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
621 if ( !presentNotSupported.empty() )
624 const char* typeMsg[] = {
625 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
626 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
627 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
628 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
629 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
630 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
631 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
632 "SMESH_BIQUADRATIC_PENTAHEDRONS",
633 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
635 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
636 const int nbTypes = sizeof( typeMsg ) / sizeof( const char* );
637 int _assert[( nbTypes == SMESH::Entity_Last ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
639 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
640 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
641 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
642 if ( iType != presentNotSupported.size() - 1 )
643 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
645 int aRet = SUIT_MessageBox::warning
646 (SMESHGUI::desktop(),
647 QObject::tr("SMESH_WRN_WARNING"),
648 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
649 QObject::tr("SMESH_BUT_YES"),
650 QObject::tr("SMESH_BUT_NO"), 0, 1);
655 // Get parameters of export operation
658 SMESH::MED_VERSION aFormat = SMESH::MED_LATEST;
659 // Init the parameters with the default values
660 bool aIsASCII_STL = true;
661 bool toCreateGroups = false;
663 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
664 bool toOverwrite = true;
665 bool toFindOutDim = true;
667 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
668 QString anInitialPath = "";
669 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
670 anInitialPath = QDir::currentPath();
672 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
674 // Get a file name to write in and additional otions
675 if ( isUNV || isDAT || isGMF ) // Export w/o options
678 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
680 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
682 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
683 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
684 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
685 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
686 anInitialPath + QString("/") + aMeshName,
687 aFilter, aTitle, false);
689 else if ( isCGNS )// Export to CGNS
691 const char* theByTypeResource = "cgns_group_elems_by_type";
692 toCreateGroups = SMESHGUI::resourceMgr()->booleanValue( "SMESH", theByTypeResource, false );
694 QStringList checkBoxes;
695 checkBoxes << QObject::tr("CGNS_EXPORT_ELEMS_BY_TYPE");
697 SalomeApp_CheckFileDlg* fd =
698 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
699 fd->setWindowTitle( aTitle );
700 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
701 if ( !anInitialPath.isEmpty() )
702 fd->setDirectory( anInitialPath );
703 fd->selectFile(aMeshName);
704 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
705 fd->setValidator( fv );
706 fd->SetChecked( toCreateGroups, 0 );
709 aFilename = fd->selectedFile();
710 toOverwrite = fv->isOverwrite();
711 toCreateGroups = fd->IsChecked(0);
712 SMESHGUI::resourceMgr()->setValue("SMESH", theByTypeResource, toCreateGroups );
716 else if ( isSTL ) // Export to STL
718 QMap<QString, int> aFilterMap;
719 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
720 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
723 QMap<QString, int>::const_iterator it = aFilterMap.begin();
724 for ( ; it != aFilterMap.end(); ++it )
725 filters.push_back( it.key() );
727 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
728 fd->setWindowTitle( aTitle );
729 fd->setNameFilters( filters );
730 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
731 if ( !anInitialPath.isEmpty() )
732 fd->setDirectory( anInitialPath );
733 fd->selectFile(aMeshName);
737 aFilename = fd->selectedFile();
738 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
743 else if ( isMED || isSAUV ) // Export to MED or SAUV
745 QMap<QString, SMESH::MED_VERSION> aFilterMap;
747 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
748 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
749 int minor = v22.split(".").last().toInt();
750 int vv= int(SMESH::MED_MINOR_0); // add all minor from 0 to current
751 for (int ii=0; ii<minor; ii++)
753 QString vs = aMesh->GetVersionString(SMESH::MED_VERSION(vv), 2);
754 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", SMESH::MED_VERSION(vv));
759 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
760 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
761 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
765 QString aDefaultFilter;
766 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
767 for ( ; it != aFilterMap.end(); ++it ) {
768 filters.push_back( it.key() );
769 if (it.value() == SMESH::MED_V2_2)
770 aDefaultFilter = it.key();
772 QStringList checkBoxes;
773 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
775 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
776 QList< QWidget* > wdgList;
777 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
778 wdgList.append( fieldSelWdg );
780 SalomeApp_CheckFileDlg* fd =
781 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
782 fd->setWindowTitle( aTitle );
783 fd->setNameFilters( filters );
784 fd->selectNameFilter( aDefaultFilter );
785 fd->SetChecked( toCreateGroups, 0 );
786 fd->SetChecked( toFindOutDim, 1 );
787 if ( !anInitialPath.isEmpty() )
788 fd->setDirectory( anInitialPath );
789 fd->selectFile(aMeshName);
792 QListView *lview = fd->findChild<QListView*>("listView");
794 lview->setMinimumHeight(200);
796 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
798 tview->setMinimumHeight(200);
801 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
802 fd->setValidator( fv );
807 aFilename = fd->selectedFile();
809 aFilename = QString::null;
812 aFormat = aFilterMap[fd->selectedNameFilter()];
813 toOverwrite = fv->isOverwrite();
815 if ( !aFilename.isEmpty() ) {
816 // med-2.1 does not support poly elements
817 if ( aFormat==SMESH::MED_V2_1 )
818 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
819 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
820 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
821 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
822 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
824 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
825 QObject::tr("SMESH_WRN_WARNING"),
826 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
827 QObject::tr("SMESH_BUT_YES"),
828 QObject::tr("SMESH_BUT_NO"), 0, 1);
836 // can't append to an existing using other format
837 SMESH::MED_VERSION aVersion = aFormat; //SMESH::MED_V2_1;
838 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
839 if( !isVersionOk || aVersion != aFormat ) {
840 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
841 QObject::tr("SMESH_WRN_WARNING"),
842 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
843 QObject::tr("SMESH_BUT_YES"),
844 QObject::tr("SMESH_BUT_NO"), 0, 1);
851 QStringList aMeshNamesCollisionList;
852 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
853 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
854 QString anExistingMeshName( aMeshNames[ i ] );
855 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
856 QString anExportMeshName = (*aMeshIter).second;
857 if( anExportMeshName == anExistingMeshName ) {
858 aMeshNamesCollisionList.append( anExportMeshName );
863 if( !aMeshNamesCollisionList.isEmpty() ) {
864 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
865 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
866 QObject::tr("SMESH_WRN_WARNING"),
867 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
868 QObject::tr("SMESH_BUT_YES"),
869 QObject::tr("SMESH_BUT_NO"),
870 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
879 toCreateGroups = fd->IsChecked(0);
880 toFindOutDim = fd->IsChecked(1);
881 fieldSelWdg->GetSelectedFields();
882 if ( !fieldSelWdg->parent() )
893 if ( !aFilename.isEmpty() ) {
894 // Check whether the file already exists and delete it if yes
895 QFile aFile( aFilename );
896 if ( aFile.exists() && toOverwrite )
898 SUIT_OverrideCursor wc;
901 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
902 // bool Renumber = false;
903 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
905 // Renumber= resMgr->booleanValue("renumbering");
907 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
908 // aMeshEditor->RenumberNodes();
909 // aMeshEditor->RenumberElements();
910 // if ( SMESHGUI::automaticUpdate() )
911 // SMESH::UpdateView();
915 aMeshIter = aMeshList.begin();
916 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
918 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
919 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
920 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
921 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
922 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
923 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
924 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
925 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
927 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
928 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
929 fields, geoAssFields.toLatin1().data() );
934 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
936 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
937 if( !aMeshItem->_is_nil() )
938 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
943 if ( aMeshOrGroup->_is_equivalent( aMesh ))
944 aMesh->ExportDAT( aFilename.toUtf8().data() );
946 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
950 if ( aMeshOrGroup->_is_equivalent( aMesh ))
951 aMesh->ExportUNV( aFilename.toUtf8().data() );
953 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
957 if ( aMeshOrGroup->_is_equivalent( aMesh ))
958 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
960 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
964 aMeshIter = aMeshList.begin();
965 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
967 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
968 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
969 aMeshItem->ExportCGNS( aMeshOrGroup,
970 aFilename.toUtf8().data(),
971 toOverwrite && aMeshIndex == 0,
977 toCreateGroups = true;
978 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
981 catch (const SALOME::SALOME_Exception& S_ex){
983 SUIT_MessageBox::warning(SMESHGUI::desktop(),
984 QObject::tr("SMESH_WRN_WARNING"),
985 QObject::tr("SMESH_EXPORT_FAILED"));
991 inline void InverseEntityMode(unsigned int& theOutputMode,
992 unsigned int theMode)
994 bool anIsNotPresent = ~theOutputMode & theMode;
996 theOutputMode |= theMode;
998 theOutputMode &= ~theMode;
1001 void SetDisplayEntity(int theCommandID)
1003 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1004 SALOME_ListIO selected;
1006 aSel->selectedObjects( selected );
1008 if ( selected.Extent() >= 1 ) {
1009 SUIT_OverrideCursor wc;
1010 SALOME_ListIteratorOfListIO It( selected );
1011 for( ; It.More(); It.Next()){
1012 Handle(SALOME_InteractiveObject) IObject = It.Value();
1013 if(IObject->hasEntry()){
1014 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1015 unsigned int aMode = anActor->GetEntityMode();
1016 switch(theCommandID){
1017 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1018 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1019 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1020 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1021 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1022 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1025 anActor->SetEntityMode(aMode);
1034 SalomeApp_Application* app =
1035 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1039 LightApp_SelectionMgr* aSel = app->selectionMgr();
1040 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1041 if ( !aSel || !appStudy )
1044 SALOME_ListIO selected;
1045 aSel->selectedObjects( selected );
1046 if ( selected.IsEmpty() )
1049 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1051 _PTR(Study) aStudy = appStudy->studyDS();
1052 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1053 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1054 if ( aMainObject->_is_nil() )
1057 SUIT_OverrideCursor wc;
1059 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1061 QList<SALOMEDS::Color> aReservedColors;
1063 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1064 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1066 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1068 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1069 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1070 #else // old algorithm for auto-colors
1071 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1072 aReservedColors.append( aColor );
1073 #endif // SIMPLE_AUTOCOLOR
1074 aGroupObject->SetColor( aColor );
1076 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1077 if ( aGroupSObject ) {
1080 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1081 switch ( aGroupObject->GetType ()) {
1083 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1085 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1087 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1089 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1091 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1092 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1095 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1096 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1102 SMESH::RepaintCurrentView();
1105 void OverallMeshQuality()
1107 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1108 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1109 SALOME_ListIO selected;
1111 aSel->selectedObjects( selected );
1113 if ( selected.IsEmpty() ) return;
1114 SALOME_ListIteratorOfListIO It( selected );
1115 for ( ; It.More(); It.Next() ) {
1116 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1117 ctrlDlg->showInfo( It.Value() );
1122 QString functorToString( SMESH::Controls::FunctorPtr f )
1124 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1125 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1126 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1127 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1128 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1129 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1130 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1131 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1132 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1133 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1134 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1135 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1136 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1137 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1138 type = QObject::tr( "WARP_ELEMENTS" );
1139 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1140 type = QObject::tr( "TAPER_ELEMENTS" );
1141 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1142 type = QObject::tr( "SKEW_ELEMENTS" );
1143 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1144 type = QObject::tr( "AREA_ELEMENTS" );
1145 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1146 type = QObject::tr( "LENGTH_EDGES" );
1147 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1148 type = QObject::tr( "LENGTH2D_EDGES" );
1149 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1150 type = QObject::tr( "DEFLECTION2D_FACES" );
1151 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1152 type = QObject::tr( "MULTI_BORDERS" );
1153 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1154 type = QObject::tr( "MULTI2D_BORDERS" );
1155 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1156 type = QObject::tr( "FREE_NODES" );
1157 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1158 type = QObject::tr( "FREE_EDGES" );
1159 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1160 type = QObject::tr( "FREE_BORDERS" );
1161 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1162 type = QObject::tr( "FREE_FACES" );
1163 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1164 type = QObject::tr( "BARE_BORDER_VOLUME" );
1165 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1166 type = QObject::tr( "BARE_BORDER_FACE" );
1167 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1168 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1169 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1170 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1171 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1172 type = QObject::tr( "EQUAL_NODE" );
1173 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1174 type = QObject::tr( "EQUAL_EDGE" );
1175 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1176 type = QObject::tr( "EQUAL_FACE" );
1177 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1178 type = QObject::tr( "EQUAL_VOLUME" );
1179 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1180 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1184 void SaveDistribution()
1186 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1187 SALOME_ListIO selected;
1189 aSel->selectedObjects( selected );
1191 if ( selected.Extent() == 1 ) {
1192 Handle(SALOME_InteractiveObject) anIO = selected.First();
1193 if ( anIO->hasEntry() ) {
1194 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1196 anActor->GetScalarBarActor() &&
1197 anActor->GetControlMode() != SMESH_Actor::eNone )
1199 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1200 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1201 if ( aScalarBarActor && aFunctor ) {
1202 SMESH::Controls::NumericalFunctor* aNumFun =
1203 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1205 std::vector<int> elements;
1206 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1207 if ( mesh->_is_nil() ) {
1208 SMESH::SMESH_IDSource_var idSource =
1209 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1210 if ( !idSource->_is_nil() )
1212 SMESH::long_array_var ids = idSource->GetIDs();
1213 elements.resize( ids->length() );
1214 for ( unsigned i = 0; i < elements.size(); ++i )
1215 elements[i] = ids[i];
1218 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1219 vtkLookupTable* lookupTable =
1220 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1221 double * minmax = lookupTable->GetRange();
1222 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1223 std::vector<int> nbEvents;
1224 std::vector<double> funValues;
1225 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1226 elements, minmax, isLogarithmic );
1227 QString anInitialPath = "";
1228 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1229 anInitialPath = QDir::currentPath();
1230 QString aMeshName = anIO->getName();
1232 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1233 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1234 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1235 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1236 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1239 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1241 if ( !aFilename.isEmpty() ) {
1242 QFile f( aFilename );
1243 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1244 QTextStream out( &f );
1245 out << "# Mesh: " << aMeshName << endl;
1246 out << "# Control: " << functorToString( aFunctor ) << endl;
1248 out.setFieldWidth( 10 );
1249 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1250 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1261 void ShowElement( int theCommandID )
1263 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1264 SALOME_ListIO selected;
1266 aSel->selectedObjects( selected );
1268 if ( selected.Extent() == 1 ) {
1269 Handle(SALOME_InteractiveObject) anIO = selected.First();
1270 if ( anIO->hasEntry() ) {
1271 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1273 anActor->GetScalarBarActor() &&
1274 anActor->GetControlMode() != SMESH_Actor::eNone )
1276 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1277 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1278 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1280 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1281 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1288 #ifndef DISABLE_PLOT2DVIEWER
1289 void PlotDistribution()
1291 SalomeApp_Application* app =
1292 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1296 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1297 SALOME_ListIO selected;
1299 aSel->selectedObjects( selected );
1301 if ( selected.Extent() == 1 ) {
1302 Handle(SALOME_InteractiveObject) anIO = selected.First();
1303 if ( anIO->hasEntry() ) {
1304 //Find Actor by entry before getting Plot2d viewer,
1305 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1306 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1308 SUIT_ViewManager* aViewManager =
1309 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1313 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1317 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1321 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1323 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1324 QString functorName = functorToString( anActor->GetFunctor());
1325 QString aHistogramName("%1 : %2");
1326 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1327 aHistogram->setName(aHistogramName);
1328 aHistogram->setHorTitle(functorName);
1329 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1330 aPlot->displayObject(aHistogram, true);
1335 #endif //DISABLE_PLOT2DVIEWER
1337 void DisableAutoColor()
1339 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1340 SALOME_ListIO selected;
1342 aSel->selectedObjects( selected );
1344 if ( selected.Extent() ) {
1345 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1346 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1347 if ( !aMesh->_is_nil() ) {
1348 aMesh->SetAutoColor( false );
1355 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1356 SALOME_ListIO selected;
1358 aSel->selectedObjects( selected );
1359 if ( selected.Extent() )
1361 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1362 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1363 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1365 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1366 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1373 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1375 SALOME_ListIO selected;
1376 SalomeApp_Application* app =
1377 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1381 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1382 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1383 if ( !aSel || !appStudy )
1386 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1387 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1388 aModule->EmitSignalDeactivateDialog();
1389 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1390 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1395 _PTR(Study) aStudy = appStudy->studyDS();
1397 aSel->selectedObjects( selected );
1399 if ( selected.Extent() >= 1 )
1401 switch ( theCommandID ) {
1402 case SMESHOp::OpTransparency:
1404 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1405 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1408 case SMESHOp::OpProperties:
1411 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1412 QColor orientationColor, outlineColor, volumeColor;
1413 int deltaF = 0, deltaV = 0;
1416 double ballScale = 1.0;
1418 int outlineWidth = 1;
1419 double shrinkCoef = 0.0;
1420 double orientationScale = 0.0;
1421 bool orientation3d = false;
1422 VTK::MarkerType markerType = VTK::MT_NONE;
1423 VTK::MarkerScale markerScale = VTK::MS_NONE;
1425 bool hasNodes = false;
1426 int presentEntities = 0;
1427 bool firstTime = true;
1429 SALOME_ListIteratorOfListIO It( selected );
1430 for ( ; It.More(); It.Next() ) {
1431 Handle(SALOME_InteractiveObject) IObject = It.Value();
1432 if ( !IObject->hasEntry() ) continue;
1433 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1434 if ( !anActor || !anActor->GetObject() ) continue;
1437 // nodes: color, marker
1438 anActor->GetNodeColor( color[0], color[1], color[2] );
1439 nodeColor.setRgbF( color[0], color[1], color[2] );
1440 markerType = anActor->GetMarkerType();
1441 markerScale = anActor->GetMarkerScale();
1442 markerId = anActor->GetMarkerTexture();
1443 // edges: color, width
1444 anActor->GetEdgeColor( color[0], color[1], color[2] );
1445 edgeColor.setRgbF( color[0], color[1], color[2] );
1446 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1447 // faces: front color, back color (delta)
1448 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1449 faceColor.setRgbF( color[0], color[1], color[2] );
1450 // faces: front color, back color (delta)
1451 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1452 volumeColor.setRgbF( color[0], color[1], color[2] );
1453 // 0d elements: color, size
1454 anActor->Get0DColor( color[0], color[1], color[2] );
1455 elem0dColor.setRgbF( color[0], color[1], color[2] );
1456 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1457 // balls: color, size
1458 anActor->GetBallColor( color[0], color[1], color[2] );
1459 ballColor.setRgbF( color[0], color[1], color[2] );
1460 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1461 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1463 anActor->GetOutlineColor( color[0], color[1], color[2] );
1464 outlineColor.setRgbF( color[0], color[1], color[2] );
1465 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1466 // orientation vectors: color, scale, 3d flag
1467 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1468 orientationColor.setRgbF( color[0], color[1], color[2] );
1469 orientationScale = anActor->GetFacesOrientationScale();
1470 orientation3d = anActor->GetFacesOrientation3DVectors();
1472 shrinkCoef = anActor->GetShrinkFactor();
1475 firstTime = false; // we only take properties from first object (for performance reasons)
1478 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1479 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1480 presentEntities = presentEntities | SMESH_Actor::eEdges;
1481 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1482 presentEntities = presentEntities | SMESH_Actor::eFaces;
1483 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1484 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1485 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1486 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1487 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1488 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1490 // as we know that all types of elements are present, we can exit the loop
1491 if ( presentEntities == SMESH_Actor::eAllEntity )
1495 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1496 // nodes: color, marker
1497 dlg.setNodeColor( nodeColor );
1498 if( markerType != VTK::MT_USER )
1499 dlg.setNodeMarker( markerType, markerScale );
1501 dlg.setNodeCustomMarker( markerId );
1502 // edges: color, line width
1503 dlg.setEdgeColor( edgeColor );
1504 dlg.setEdgeWidth( edgeWidth );
1505 // faces: front color, back color
1506 dlg.setFaceColor( faceColor, deltaF );
1507 // volumes: normal color, reversed color
1508 dlg.setVolumeColor( volumeColor, deltaV );
1509 // outlines: color, line width
1510 dlg.setOutlineColor( outlineColor );
1511 dlg.setOutlineWidth( outlineWidth );
1512 // 0d elements: color, size
1513 dlg.setElem0dColor( elem0dColor );
1514 dlg.setElem0dSize( elem0dSize );
1515 // balls: color, size
1516 dlg.setBallColor( ballColor );
1517 //dlg.setBallSize( ballSize );
1518 dlg.setBallScale( ballScale );
1519 // orientation: color, scale, 3d flag
1520 dlg.setOrientationColor( orientationColor );
1521 dlg.setOrientationSize( int( orientationScale * 100. ) );
1522 dlg.setOrientation3d( orientation3d );
1523 // shrink: scale factor
1524 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1525 // hide unused controls
1526 dlg.showControls( presentEntities, hasNodes );
1529 nodeColor = dlg.nodeColor();
1530 markerType = dlg.nodeMarkerType();
1531 markerScale = dlg.nodeMarkerScale();
1532 markerId = dlg.nodeMarkerId();
1533 edgeColor = dlg.edgeColor();
1534 edgeWidth = dlg.edgeWidth();
1535 faceColor = dlg.faceColor();
1536 deltaF = dlg.faceColorDelta();
1537 volumeColor = dlg.volumeColor();
1538 deltaV = dlg.volumeColorDelta();
1539 outlineColor = dlg.outlineColor();
1540 outlineWidth = dlg.outlineWidth();
1541 elem0dColor = dlg.elem0dColor();
1542 elem0dSize = dlg.elem0dSize();
1543 ballColor = dlg.ballColor();
1544 // ballSize = dlg.ballSize();
1545 ballScale = dlg.ballScale();
1546 orientationColor = dlg.orientationColor();
1547 orientationScale = dlg.orientationSize() / 100.;
1548 orientation3d = dlg.orientation3d();
1549 shrinkCoef = dlg.shrinkCoef() / 100.;
1551 // store point markers map that might be changed by the user
1552 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1554 // set properties from dialog box to the presentations
1555 SALOME_ListIteratorOfListIO It( selected );
1556 for ( ; It.More(); It.Next() ) {
1557 Handle(SALOME_InteractiveObject) IObject = It.Value();
1558 if ( !IObject->hasEntry() ) continue;
1559 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1560 if ( !anActor ) continue;
1562 // nodes: color, marker
1563 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1564 if ( markerType != VTK::MT_USER ) {
1565 anActor->SetMarkerStd( markerType, markerScale );
1568 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1569 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1570 if ( iter != markerMap.end() )
1571 anActor->SetMarkerTexture( markerId, iter->second.second );
1573 // volumes: normal color, reversed color (delta)
1574 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1575 // faces: front color, back color (delta)
1576 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1577 // edges: color, width
1578 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1579 anActor->SetLineWidth( edgeWidth );
1581 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1582 anActor->SetOutlineWidth( outlineWidth );
1583 // 0D elements: color, size
1584 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1585 anActor->Set0DSize( elem0dSize );
1586 // balls: color, size
1587 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1588 // anActor->SetBallSize( ballSize );
1589 anActor->SetBallScale( ballScale );
1590 // orientation: color, scale, 3d flag
1591 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1592 anActor->SetFacesOrientationScale( orientationScale );
1593 anActor->SetFacesOrientation3DVectors( orientation3d );
1595 anActor->SetShrinkFactor( shrinkCoef );
1597 // for groups, set also proper color
1598 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1599 if ( !aGroupObject->_is_nil() ) {
1600 SMESH::ElementType anElementType = aGroupObject->GetType();
1602 switch( anElementType ) {
1604 aColor = nodeColor; break;
1606 aColor = edgeColor; break;
1608 aColor = faceColor; break;
1610 aColor = volumeColor; break;
1612 aColor = elem0dColor; break;
1614 aColor = ballColor; break;
1618 if ( aColor.isValid() ) {
1619 SALOMEDS::Color aGroupColor;
1620 aGroupColor.R = aColor.redF();
1621 aGroupColor.G = aColor.greenF();
1622 aGroupColor.B = aColor.blueF();
1623 aGroupObject->SetColor( aGroupColor );
1625 } // if ( !aGroupObject->_is_nil() )
1626 } // for ( ; It.More(); It.Next() )
1627 SMESH::RepaintCurrentView();
1628 } // if ( dlg.exec() )
1630 } // case SMESHOp::OpProperties:
1631 } // switch(theCommandID)
1632 SUIT_OverrideCursor wc;
1633 SALOME_ListIteratorOfListIO It( selected );
1634 for( ; It.More(); It.Next()){
1635 Handle(SALOME_InteractiveObject) IObject = It.Value();
1636 if(IObject->hasEntry()){
1637 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1638 switch(theCommandID){
1639 case SMESHOp::OpDMWireframe:
1640 anActor->SetRepresentation(SMESH_Actor::eEdge);
1642 case SMESHOp::OpDMShading:
1643 anActor->SetRepresentation(SMESH_Actor::eSurface);
1645 case SMESHOp::OpDMShrink:
1646 if(anActor->IsShrunk())
1647 anActor->UnShrink();
1649 anActor->SetShrink();
1651 case SMESHOp::OpDMNodes:
1652 anActor->SetRepresentation(SMESH_Actor::ePoint);
1654 case SMESHOp::OpRepresentationLines:
1655 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1656 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1658 case SMESHOp::OpRepresentationArcs:
1659 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1660 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1666 SMESH::RepaintCurrentView();
1670 int ActionToControl( int theID, bool theReversed )
1672 NCollection_DoubleMap<int,int> ActionControl;
1673 ActionControl.Bind( 0, SMESH_Actor::eNone );
1674 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1675 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1676 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1677 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1678 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1679 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1680 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1681 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1682 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1683 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1684 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1685 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1686 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1687 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1688 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1689 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1690 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1691 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1692 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1693 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1694 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1695 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1696 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1697 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1698 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1699 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1700 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1701 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1704 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1705 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1708 void Control( int theCommandID )
1710 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1711 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1713 SALOME_ListIO selected;
1714 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1715 aSel->selectedObjects( selected );
1717 if ( !selected.IsEmpty() ) {
1718 SALOME_ListIteratorOfListIO It(selected);
1719 for ( ; It.More(); It.Next())
1721 Handle(SALOME_InteractiveObject) anIO = It.Value();
1722 if ( !anIO.IsNull() ) {
1723 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1725 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1726 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1727 if ( !anIDSrc->_is_nil() ) {
1728 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1729 if (( !anActor && selected.Extent() == 1 ) &&
1730 ( anActor = SMESH::CreateActor( aStudy, anIO->getEntry() )))
1732 anActor->SetControlMode( aControl );
1733 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1734 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1738 if ( anActor->GetControlMode() != aControl )
1739 anActor->SetControlMode( aControl );
1740 QString functorName = functorToString( anActor->GetFunctor() );
1741 int anEntitiesCount = anActor->GetNumberControlEntities();
1742 if (anEntitiesCount >= 0)
1743 functorName = functorName + ": " + QString::number(anEntitiesCount);
1744 anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
1745 SMESH::RepaintCurrentView();
1746 #ifndef DISABLE_PLOT2DVIEWER
1747 if ( anActor->GetPlot2Histogram() ) {
1748 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1749 QString aHistogramName("%1 : %2");
1750 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1751 aHistogram->setName( aHistogramName );
1752 aHistogram->setHorTitle( functorName );
1753 SMESH::ProcessIn2DViewers( anActor );
1765 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1766 SMESH::MeshObjectType theType,
1767 const QString theInTypeName,
1768 QString & theOutTypeName)
1770 SMESH_TypeFilter aTypeFilter( theType );
1772 if ( !theIO.IsNull() )
1774 entry = theIO->getEntry();
1775 LightApp_DataOwner owner( entry );
1776 if ( aTypeFilter.isOk( &owner )) {
1777 theOutTypeName = theInTypeName;
1785 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1787 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1788 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1790 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1791 CORBA::String_var anID = aSComp->GetID().c_str();
1792 if ( !strcmp(anID.in(),theIO->getEntry()) )
1798 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1799 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1800 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1801 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1802 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1810 // QString CheckHomogeneousSelection()
1812 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1813 // SALOME_ListIO selected;
1815 // aSel->selectedObjects( selected );
1817 // QString RefType = CheckTypeObject(selected.First());
1818 // SALOME_ListIteratorOfListIO It(selected);
1819 // for ( ; It.More(); It.Next())
1821 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1822 // QString Type = CheckTypeObject(IObject);
1823 // if ( Type.compare(RefType) != 0 )
1824 // return "Heterogeneous Selection";
1830 uint randomize( uint size )
1832 static bool initialized = false;
1833 if ( !initialized ) {
1834 qsrand( QDateTime::currentDateTime().toTime_t() );
1838 v = uint( (double)( v ) / RAND_MAX * size );
1839 v = qMax( uint(0), qMin ( v, size-1 ) );
1845 void SMESHGUI::OnEditDelete()
1847 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1848 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1849 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1851 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1852 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1853 _PTR(GenericAttribute) anAttr;
1854 _PTR(AttributeIOR) anIOR;
1856 int objectCount = 0;
1858 QString aParentComponent = QString::null;
1859 Handle(SALOME_InteractiveObject) anIO;
1860 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1862 anIO = anIt.Value();
1863 QString cur = anIO->getComponentDataType();
1864 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1866 // check if object is reference
1867 _PTR(SObject) aRefSObj;
1868 aNameList.append("\n - ");
1869 if ( aSO->ReferencedObject( aRefSObj ) ) {
1870 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1871 aNameList.append( aRefName );
1872 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1875 aNameList.append(anIO->getName());
1879 if( aParentComponent.isNull() )
1880 aParentComponent = cur;
1881 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1882 aParentComponent = "";
1885 if ( objectCount == 0 )
1886 return; // No Valid Objects Selected
1888 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1889 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1890 QObject::tr("ERR_ERROR"),
1891 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1894 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1895 if (SUIT_MessageBox::warning
1896 (SMESHGUI::desktop(),
1897 QObject::tr("SMESH_WRN_WARNING"),
1898 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1899 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1900 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1903 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1905 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1906 // then treat them all starting from the deepest objects (at list back)
1907 std::list< _PTR(SObject) > listSO;
1908 SALOME_ListIteratorOfListIO It(selected);
1909 for( ; It.More(); It.Next()) // loop on selected IO's
1911 Handle(SALOME_InteractiveObject) IObject = It.Value();
1912 if(IObject->hasEntry()) {
1913 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1915 // disable removal of "SMESH" component object
1916 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1918 if ( engineIOR() == anIOR->Value().c_str() )
1921 //Check the referenced object
1922 _PTR(SObject) aRefSObject;
1923 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1924 aSO = aRefSObject; // Delete main Object instead of reference
1926 listSO.push_back( aSO );
1927 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1928 for ( ; itSO != listSO.end(); ++itSO ) {
1929 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1930 for (it->InitEx(false); it->More(); it->Next())
1931 listSO.push_back( it->Value() );
1935 // Check if none of objects to delete is referred from outside
1936 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1937 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1939 _PTR(SObject) SO = *ritSO;
1940 if ( !SO ) continue;
1941 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1942 for (size_t i = 0; i < aReferences.size(); i++) {
1943 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1944 std::string type = aComponent->ComponentDataType();
1945 if ( type != "SMESH" )
1947 SUIT_MessageBox::warning( anApp->desktop(),
1948 QObject::tr("WRN_WARNING"),
1949 QObject::tr("DEP_OBJECT") );
1950 return; // outside SMESH, there is an object depending on a SMESH object
1955 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1956 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1958 Handle(SALOME_InteractiveObject) IObject = It.Value();
1959 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1960 if ( !mesh->_is_nil() )
1964 // Treat SO's in the list starting from the back
1965 aStudyBuilder->NewCommand(); // There is a transaction
1966 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1968 _PTR(SObject) SO = *ritSO;
1969 if ( !SO ) continue;
1970 std::string anEntry = SO->GetID();
1972 /** Erase graphical object and remove all its data **/
1973 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1974 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1976 /** Remove an object from data structures **/
1977 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1978 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1979 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1980 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1981 aMesh->RemoveGroup( aGroup );
1983 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1984 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1985 aMesh->RemoveSubMesh( aSubMesh );
1987 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1989 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1992 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1993 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1994 QString objType = CheckTypeObject(IObject);
1995 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1996 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1997 aStudyBuilder->RemoveObjectWithChildren( SO );
1999 else {// default action: remove SObject from the study
2000 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2001 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2003 aStudyBuilder->RemoveObjectWithChildren( SO );
2007 } /* listSO back loop */
2009 aStudyBuilder->CommitCommand();
2011 /* Clear any previous selection */
2013 aSel->setSelectedObjects( l1 );
2015 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2019 SMESHGUI_EXPORT CAM_Module* createModule()
2021 return new SMESHGUI();
2024 SMESHGUI_EXPORT char* getModuleVersion() {
2025 return (char*)SMESH_VERSION_STR;
2029 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2031 //=============================================================================
2035 //=============================================================================
2036 SMESHGUI::SMESHGUI() :
2037 SalomeApp_Module( "SMESH" )
2039 if ( CORBA::is_nil( myComponentSMESH ) )
2041 CORBA::Boolean anIsEmbeddedMode;
2042 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2043 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2045 // 0019923: EDF 765 SMESH : default values of hypothesis
2046 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2047 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2048 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2049 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2050 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2052 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2053 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2054 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2056 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2057 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2061 myActiveDialogBox = 0;
2062 myFilterLibraryDlg = 0;
2066 myEventCallbackCommand = vtkCallbackCommand::New();
2067 myEventCallbackCommand->Delete();
2068 myEventCallbackCommand->SetClientData( this );
2069 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2072 /* load resources for all available meshers */
2073 SMESH::InitAvailableHypotheses();
2076 //=============================================================================
2080 //=============================================================================
2081 SMESHGUI::~SMESHGUI()
2085 //=============================================================================
2089 //=============================================================================
2090 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2092 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2094 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2099 //=============================================================================
2103 //=============================================================================
2104 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2106 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2110 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2111 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2112 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2113 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2114 return autoUpdate && !exceeded;
2117 //=============================================================================
2121 //=============================================================================
2122 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2123 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2125 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2129 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2130 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2131 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2133 SMESH::long_array_var info = theMesh->GetMeshInfo();
2134 long nbOdElems = info[SMDSEntity_0D];
2135 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2136 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2137 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2138 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2139 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2140 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2141 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2142 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2143 info[SMDSEntity_Polyhedra] +
2144 info[SMDSEntity_Hexagonal_Prism];
2145 long nbBalls = info[SMDSEntity_Ball];
2147 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2148 *nbElements = requestedSize;
2150 *entities = SMESH_Actor::eAllEntity;
2153 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2155 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2157 if ( incrementalLimit ) {
2160 if ( nbOdElems > 0 ) {
2161 if ( total + nbOdElems > updateLimit ) {
2162 *entities = *entities & ~SMESH_Actor::e0DElements;
2163 *hidden = *hidden | SMESH_Actor::e0DElements;
2170 if ( nbEdges > 0 ) {
2171 if ( total + nbEdges > updateLimit ) {
2172 *entities = *entities & ~SMESH_Actor::eEdges;
2173 *hidden = *hidden | SMESH_Actor::eEdges;
2180 if ( nbFaces > 0 ) {
2181 if ( total + nbFaces > updateLimit ) {
2182 *entities = *entities & ~SMESH_Actor::eFaces;
2183 *hidden = *hidden | SMESH_Actor::eFaces;
2190 if ( nbVolumes > 0 ) {
2191 if ( total + nbVolumes > updateLimit ) {
2192 *entities = *entities & ~SMESH_Actor::eVolumes;
2193 *hidden = *hidden | SMESH_Actor::eVolumes;
2200 if ( nbBalls > 0 ) {
2201 if ( total + nbBalls > updateLimit ) {
2202 *entities = *entities & ~SMESH_Actor::eBallElem;
2203 *hidden = *hidden | SMESH_Actor::eBallElem;
2211 return autoUpdate && !exceeded;
2214 //=============================================================================
2218 //=============================================================================
2219 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2221 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2224 //=============================================================================
2228 //=============================================================================
2229 SMESHGUI* SMESHGUI::GetSMESHGUI()
2231 SMESHGUI* smeshMod = 0;
2232 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2235 CAM_Module* module = app->module( "Mesh" );
2236 smeshMod = dynamic_cast<SMESHGUI*>( module );
2239 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2241 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2244 _PTR(Study) aStudy = study->studyDS();
2246 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2255 Standard_EXPORT SMESHGUI* GetComponentGUI()
2257 return SMESHGUI::GetSMESHGUI();
2261 //=============================================================================
2265 //=============================================================================
2266 void SMESHGUI::SetState(int aState)
2271 //=============================================================================
2275 //=============================================================================
2276 void SMESHGUI::ResetState()
2281 //=============================================================================
2285 //=============================================================================
2286 void SMESHGUI::EmitSignalDeactivateDialog()
2288 emit SignalDeactivateActiveDialog();
2291 //=============================================================================
2295 //=============================================================================
2296 void SMESHGUI::EmitSignalStudyFrameChanged()
2298 emit SignalStudyFrameChanged();
2301 //=============================================================================
2305 //=============================================================================
2306 void SMESHGUI::EmitSignalCloseAllDialogs()
2308 emit SignalCloseAllDialogs();
2311 //=============================================================================
2315 //=============================================================================
2316 void SMESHGUI::EmitSignalVisibilityChanged()
2318 emit SignalVisibilityChanged();
2321 //=============================================================================
2325 //=============================================================================
2326 void SMESHGUI::EmitSignalCloseView()
2328 emit SignalCloseView();
2331 //=============================================================================
2335 //=============================================================================
2336 void SMESHGUI::EmitSignalActivatedViewManager()
2338 emit SignalActivatedViewManager();
2341 //=============================================================================
2345 //=============================================================================
2346 QDialog *SMESHGUI::GetActiveDialogBox()
2348 return myActiveDialogBox;
2351 //=============================================================================
2355 //=============================================================================
2356 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2358 myActiveDialogBox = (QDialog *) aDlg;
2362 //=============================================================================
2366 //=============================================================================
2367 SUIT_Desktop* SMESHGUI::desktop()
2369 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2371 return app->desktop();
2376 //=============================================================================
2380 //=============================================================================
2381 SalomeApp_Study* SMESHGUI::activeStudy()
2383 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2385 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2390 //=============================================================================
2394 //=============================================================================
2395 void SMESHGUI::Modified( bool theIsUpdateActions )
2397 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2398 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2399 appStudy->Modified();
2400 if( theIsUpdateActions )
2401 app->updateActions();
2406 //=============================================================================
2410 //=============================================================================
2411 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2413 /* Here the position is on the bottom right corner - 10 */
2414 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2416 SUIT_Desktop *PP = desktop();
2417 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2418 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2422 //=============================================================================
2426 //=============================================================================
2427 static int isStudyLocked(_PTR(Study) theStudy){
2428 return theStudy->GetProperties()->IsLocked();
2431 static bool checkLock(_PTR(Study) theStudy) {
2432 if (isStudyLocked(theStudy)) {
2433 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2434 QObject::tr("WRN_WARNING"),
2435 QObject::tr("WRN_STUDY_LOCKED") );
2441 //=======================================================================
2442 //function : CheckActiveStudyLocked
2444 //=======================================================================
2446 bool SMESHGUI::isActiveStudyLocked()
2448 _PTR(Study) aStudy = activeStudy()->studyDS();
2449 return checkLock( aStudy );
2452 //=============================================================================
2456 //=============================================================================
2457 bool SMESHGUI::OnGUIEvent( int theCommandID )
2459 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2463 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2464 SUIT_ResourceMgr* mgr = resourceMgr();
2468 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2469 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2472 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2473 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2475 //QAction* act = action( theCommandID );
2477 switch (theCommandID) {
2478 case SMESHOp::OpDelete:
2479 if(checkLock(aStudy)) break;
2482 case SMESHOp::OpImportDAT:
2483 case SMESHOp::OpImportUNV:
2484 case SMESHOp::OpImportMED:
2485 case SMESHOp::OpImportSTL:
2486 case SMESHOp::OpImportCGNS:
2487 case SMESHOp::OpImportSAUV:
2488 case SMESHOp::OpImportGMF:
2489 case SMESHOp::OpPopupImportDAT:
2490 case SMESHOp::OpPopupImportUNV:
2491 case SMESHOp::OpPopupImportMED:
2492 case SMESHOp::OpPopupImportSTL:
2493 case SMESHOp::OpPopupImportCGNS:
2494 case SMESHOp::OpPopupImportSAUV:
2495 case SMESHOp::OpPopupImportGMF:
2497 if(checkLock(aStudy)) break;
2498 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2502 case SMESHOp::OpFileInformation:
2504 SALOME_ListIO selected;
2505 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2507 aSel->selectedObjects( selected );
2508 if( selected.Extent() )
2510 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2511 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2512 if ( !aMesh->_is_nil() )
2514 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2520 case SMESHOp::OpExportDAT:
2521 case SMESHOp::OpExportMED:
2522 case SMESHOp::OpExportUNV:
2523 case SMESHOp::OpExportSTL:
2524 case SMESHOp::OpExportCGNS:
2525 case SMESHOp::OpExportSAUV:
2526 case SMESHOp::OpExportGMF:
2527 case SMESHOp::OpPopupExportDAT:
2528 case SMESHOp::OpPopupExportMED:
2529 case SMESHOp::OpPopupExportUNV:
2530 case SMESHOp::OpPopupExportSTL:
2531 case SMESHOp::OpPopupExportCGNS:
2532 case SMESHOp::OpPopupExportSAUV:
2533 case SMESHOp::OpPopupExportGMF:
2535 ::ExportMeshToFile(theCommandID);
2539 case SMESHOp::OpReset: // SCALAR BAR
2541 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2542 SALOME_ListIO selected;
2544 aSel->selectedObjects( selected );
2546 SALOME_ListIteratorOfListIO it(selected);
2547 for( ; it.More(); it.Next()) {
2548 Handle(SALOME_InteractiveObject) anIO = it.Value();
2549 if( anIO->hasEntry() ) {
2550 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2551 anActor->SetControlMode( SMESH_Actor::eNone );
2552 #ifndef DISABLE_PLOT2DVIEWER
2553 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2558 SMESH::UpdateView();
2561 case SMESHOp::OpScalarBarProperties:
2563 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2566 case SMESHOp::OpShowScalarBar:
2568 // show/hide scalar bar
2569 ::ShowElement(theCommandID);
2572 case SMESHOp::OpSaveDistribution:
2574 // dump control distribution data to the text file
2575 ::SaveDistribution();
2579 case SMESHOp::OpShowDistribution:
2581 // show/hide distribution
2582 ::ShowElement(theCommandID);
2586 #ifndef DISABLE_PLOT2DVIEWER
2587 case SMESHOp::OpPlotDistribution:
2589 // plot distribution
2590 ::PlotDistribution();
2596 case SMESHOp::OpAutoColor:
2600 case SMESHOp::OpDisableAutoColor:
2601 ::DisableAutoColor();
2604 case SMESHOp::OpClipping:
2605 case SMESHOp::OpTransparency:
2606 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2609 case SMESHOp::OpDMWireframe:
2610 case SMESHOp::OpDMShading:
2611 case SMESHOp::OpDMNodes:
2612 case SMESHOp::OpDMShrink:
2613 ::SetDisplayMode(theCommandID, myMarkerMap);
2616 //2D quadratic representation
2617 case SMESHOp::OpRepresentationLines:
2618 case SMESHOp::OpRepresentationArcs:
2619 ::SetDisplayMode(theCommandID, myMarkerMap);
2623 case SMESHOp::OpDE0DElements:
2624 case SMESHOp::OpDEEdges:
2625 case SMESHOp::OpDEFaces:
2626 case SMESHOp::OpDEVolumes:
2627 case SMESHOp::OpDEBalls:
2628 case SMESHOp::OpDEAllEntity:
2629 ::SetDisplayEntity(theCommandID);
2632 // Choose entities to be displayed
2633 case SMESHOp::OpDEChoose:
2635 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2639 case SMESHOp::OpOrientationOnFaces:
2641 SUIT_OverrideCursor wc;
2642 LightApp_SelectionMgr* mgr = selectionMgr();
2643 SALOME_ListIO selected; mgr->selectedObjects( selected );
2645 SALOME_ListIteratorOfListIO it(selected);
2646 for( ; it.More(); it.Next()) {
2647 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2648 if(anIObject->hasEntry()) {
2649 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2650 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2657 case SMESHOp::OpUpdate:
2659 if(checkLock(aStudy)) break;
2660 SUIT_OverrideCursor wc;
2663 SMESH::UpdateView();
2665 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2666 SMESH::OnVisuException();
2668 catch (...) { // PAL16774 (Crash after display of many groups)
2669 SMESH::OnVisuException();
2673 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2674 aSel->selectedObjects( l );
2675 aSel->setSelectedObjects( l );
2679 case SMESHOp::OpHide:
2680 case SMESHOp::OpShow:
2681 case SMESHOp::OpShowOnly:
2683 SUIT_OverrideCursor wc;
2684 SMESH::EDisplaing anAction;
2685 switch (theCommandID) {
2686 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2687 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2688 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2691 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2692 SALOME_ListIO sel_objects, to_process;
2694 aSel->selectedObjects( sel_objects );
2696 if ( theCommandID==SMESHOp::OpShowOnly )
2698 //MESSAGE("anAction = SMESH::eDisplayOnly");
2699 startOperation( myEraseAll );
2702 extractContainers( sel_objects, to_process );
2707 SALOME_ListIteratorOfListIO It( to_process );
2708 for ( ; It.More(); It.Next())
2710 Handle(SALOME_InteractiveObject) IOS = It.Value();
2711 if ( IOS->hasEntry() )
2713 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2714 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2715 break; // PAL16774 (Crash after display of many groups)
2717 if (anAction == SMESH::eDisplayOnly)
2718 anAction = SMESH::eDisplay;
2723 // PAL13338 + PAL15161 -->
2724 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !checkLock(aStudy)) {
2725 SMESH::UpdateView();
2726 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2728 // PAL13338 + PAL15161 <--
2730 catch (...) { // PAL16774 (Crash after display of many groups)
2731 SMESH::OnVisuException();
2734 if (anAction == SMESH::eErase) {
2736 aSel->setSelectedObjects( l1 );
2739 aSel->setSelectedObjects( to_process );
2744 case SMESHOp::OpNode:
2746 if(checkLock(aStudy)) break;
2749 EmitSignalDeactivateDialog();
2751 ( new SMESHGUI_NodesDlg( this ) )->show();
2754 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2759 case SMESHOp::OpCreateMesh:
2760 case SMESHOp::OpCreateSubMesh:
2761 case SMESHOp::OpEditMeshOrSubMesh:
2762 case SMESHOp::OpEditMesh:
2763 case SMESHOp::OpEditSubMesh:
2764 case SMESHOp::OpCompute:
2765 case SMESHOp::OpComputeSubMesh:
2766 case SMESHOp::OpPreCompute:
2767 case SMESHOp::OpEvaluate:
2768 case SMESHOp::OpMeshOrder:
2769 startOperation( theCommandID );
2771 case SMESHOp::OpCopyMesh:
2773 if (checkLock(aStudy)) break;
2774 EmitSignalDeactivateDialog();
2775 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2778 case SMESHOp::OpBuildCompoundMesh:
2780 if (checkLock(aStudy)) break;
2781 EmitSignalDeactivateDialog();
2782 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2786 case SMESHOp::OpDiagonalInversion:
2787 case SMESHOp::OpUnionOfTwoTriangle:
2791 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2795 if ( checkLock( aStudy ) )
2798 /*Standard_Boolean aRes;
2799 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2800 if ( aMesh->_is_nil() )
2802 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2803 tr( "SMESH_BAD_SELECTION" ) );
2807 EmitSignalDeactivateDialog();
2808 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2809 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2811 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2814 case SMESHOp::OpOrientation:
2815 case SMESHOp::OpUnionOfTriangles:
2816 case SMESHOp::OpCuttingOfQuadrangles:
2817 case SMESHOp::OpSplitVolumes:
2821 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2825 if ( checkLock( aStudy ) )
2828 EmitSignalDeactivateDialog();
2829 SMESHGUI_MultiEditDlg* aDlg = NULL;
2830 if ( theCommandID == SMESHOp::OpOrientation )
2831 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2832 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2833 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2834 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2835 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2837 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2842 case SMESHOp::OpSmoothing:
2844 if(checkLock(aStudy)) break;
2846 EmitSignalDeactivateDialog();
2847 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2850 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2854 case SMESHOp::OpExtrusion:
2856 if (checkLock(aStudy)) break;
2858 EmitSignalDeactivateDialog();
2859 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2861 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2865 case SMESHOp::OpExtrusionAlongAPath:
2867 if (checkLock(aStudy)) break;
2869 EmitSignalDeactivateDialog();
2870 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2872 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2876 case SMESHOp::OpRevolution:
2878 if(checkLock(aStudy)) break;
2880 EmitSignalDeactivateDialog();
2881 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2884 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2888 case SMESHOp::OpPatternMapping:
2890 if ( checkLock( aStudy ) )
2894 EmitSignalDeactivateDialog();
2895 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2898 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2902 case SMESHOp::OpSplitBiQuadratic:
2903 case SMESHOp::OpConvertMeshToQuadratic:
2904 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2905 case SMESHOp::OpReorientFaces:
2906 case SMESHOp::OpCreateGeometryGroup:
2908 startOperation( theCommandID );
2911 case SMESHOp::OpCreateGroup:
2915 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2919 if(checkLock(aStudy)) break;
2920 EmitSignalDeactivateDialog();
2921 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2923 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2924 SALOME_ListIO selected;
2926 aSel->selectedObjects( selected );
2928 int nbSel = selected.Extent();
2930 // check if mesh is selected
2931 aMesh = SMESH::GetMeshByIO( selected.First() );
2933 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2938 case SMESHOp::OpConstructGroup:
2942 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2946 if(checkLock(aStudy)) break;
2947 EmitSignalDeactivateDialog();
2949 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2950 SALOME_ListIO selected;
2952 aSel->selectedObjects( selected );
2954 int nbSel = selected.Extent();
2956 // check if submesh is selected
2957 Handle(SALOME_InteractiveObject) IObject = selected.First();
2958 if (IObject->hasEntry()) {
2959 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2961 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2962 if (!aSubMesh->_is_nil()) {
2964 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2965 // get submesh elements list by types
2966 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2967 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2968 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2969 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2970 // create group for each type o elements
2971 QString aName = IObject->getName();
2972 QStringList anEntryList;
2973 if (aNodes->length() > 0) {
2974 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2975 aGroup->Add(aNodes.inout());
2976 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2977 anEntryList.append( aSObject->GetID().c_str() );
2979 if (aEdges->length() > 0) {
2980 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2981 aGroup->Add(aEdges.inout());
2982 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2983 anEntryList.append( aSObject->GetID().c_str() );
2985 if (aFaces->length() > 0) {
2986 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2987 aGroup->Add(aFaces.inout());
2988 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2989 anEntryList.append( aSObject->GetID().c_str() );
2991 if (aVolumes->length() > 0) {
2992 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2993 aGroup->Add(aVolumes.inout());
2994 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2995 anEntryList.append( aSObject->GetID().c_str() );
2998 anApp->browseObjects( anEntryList );
3000 catch(const SALOME::SALOME_Exception & S_ex){
3001 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3008 SUIT_MessageBox::warning(desktop(),
3009 tr("SMESH_WRN_WARNING"),
3010 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3015 case SMESHOp::OpEditGroup:
3019 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3023 if(checkLock(aStudy)) break;
3024 EmitSignalDeactivateDialog();
3026 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3027 SALOME_ListIO selected;
3029 aSel->selectedObjects( selected );
3031 SALOME_ListIteratorOfListIO It (selected);
3032 int nbSelectedGroups = 0;
3033 for ( ; It.More(); It.Next() )
3035 SMESH::SMESH_GroupBase_var aGroup =
3036 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3037 if (!aGroup->_is_nil()) {
3039 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3043 if (nbSelectedGroups == 0)
3045 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3051 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3053 if(checkLock(aStudy)) break;
3054 if (myState == 800) {
3055 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3056 if (aDlg) aDlg->onAdd();
3061 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3063 if(checkLock(aStudy)) break;
3064 if (myState == 800) {
3065 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3066 if (aDlg) aDlg->onRemove();
3071 case SMESHOp::OpEditGeomGroupAsGroup:
3075 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3079 if(checkLock(aStudy)) break;
3080 EmitSignalDeactivateDialog();
3082 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3083 SALOME_ListIO selected;
3085 aSel->selectedObjects( selected );
3087 SALOME_ListIteratorOfListIO It (selected);
3088 for ( ; It.More(); It.Next() )
3090 SMESH::SMESH_GroupOnGeom_var aGroup =
3091 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3092 if (!aGroup->_is_nil()) {
3093 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3098 SMESH::SMESH_GroupOnFilter_var aGroup =
3099 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3100 if (!aGroup->_is_nil()) {
3101 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3109 case SMESHOp::OpUnionGroups:
3110 case SMESHOp::OpIntersectGroups:
3111 case SMESHOp::OpCutGroups:
3115 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3119 if ( checkLock( aStudy ) )
3122 EmitSignalDeactivateDialog();
3124 SMESHGUI_GroupOpDlg* aDlg = 0;
3125 if ( theCommandID == SMESHOp::OpUnionGroups )
3126 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3127 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3128 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3130 aDlg = new SMESHGUI_CutGroupsDlg( this );
3137 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3139 if ( checkLock( aStudy ) )
3142 EmitSignalDeactivateDialog();
3143 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3149 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3153 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3157 if ( checkLock( aStudy ) )
3160 EmitSignalDeactivateDialog();
3162 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3166 case SMESHOp::OpMeshInformation:
3167 case SMESHOp::OpWhatIs:
3169 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3170 EmitSignalDeactivateDialog();
3171 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3172 SALOME_ListIO selected;
3174 aSel->selectedObjects( selected );
3176 if ( selected.Extent() > 1 ) { // a dlg for each IO
3177 SALOME_ListIteratorOfListIO It( selected );
3178 for ( ; It.More(); It.Next() ) {
3179 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3180 dlg->showInfo( It.Value() );
3185 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3191 case SMESHOp::OpFindElementByPoint:
3193 startOperation( theCommandID );
3197 case SMESHOp::OpEditHypothesis:
3199 if(checkLock(aStudy)) break;
3201 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3202 SALOME_ListIO selected;
3204 aSel->selectedObjects( selected );
3206 int nbSel = selected.Extent();
3209 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3210 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3212 if ( !aHypothesis->_is_nil() )
3214 SMESHGUI_GenericHypothesisCreator* aCreator =
3215 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3218 // set geometry of mesh and sub-mesh to aCreator
3219 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3220 if ( selected.Extent() == 1 )
3222 QString subGeomID, meshGeomID;
3223 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3224 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3226 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3227 aCreator->setShapeEntry( subGeomID );
3228 aCreator->setMainShapeEntry( meshGeomID );
3232 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3242 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3244 if(checkLock(aStudy)) break;
3245 SUIT_OverrideCursor wc;
3247 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3248 SALOME_ListIO selected;
3250 aSel->selectedObjects( selected, QString::null, false );
3252 SALOME_ListIteratorOfListIO It(selected);
3253 for (int i = 0; It.More(); It.Next(), i++) {
3254 Handle(SALOME_InteractiveObject) IObject = It.Value();
3255 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3258 aSel->setSelectedObjects( l1 );
3263 case SMESHOp::OpElem0D:
3264 case SMESHOp::OpBall:
3265 case SMESHOp::OpEdge:
3266 case SMESHOp::OpTriangle:
3267 case SMESHOp::OpQuadrangle:
3268 case SMESHOp::OpPolygon:
3269 case SMESHOp::OpTetrahedron:
3270 case SMESHOp::OpHexahedron:
3271 case SMESHOp::OpPentahedron:
3272 case SMESHOp::OpPyramid:
3273 case SMESHOp::OpHexagonalPrism:
3275 if(checkLock(aStudy)) break;
3277 EmitSignalDeactivateDialog();
3278 SMDSAbs_EntityType type = SMDSEntity_Edge;
3279 switch (theCommandID) {
3280 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3281 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3282 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3283 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3284 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3285 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3286 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3287 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3288 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3289 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3292 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3295 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3299 case SMESHOp::OpPolyhedron:
3301 if(checkLock(aStudy)) break;
3303 EmitSignalDeactivateDialog();
3304 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3307 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3311 case SMESHOp::OpQuadraticEdge:
3312 case SMESHOp::OpQuadraticTriangle:
3313 case SMESHOp::OpBiQuadraticTriangle:
3314 case SMESHOp::OpQuadraticQuadrangle:
3315 case SMESHOp::OpBiQuadraticQuadrangle:
3316 case SMESHOp::OpQuadraticPolygon:
3317 case SMESHOp::OpQuadraticTetrahedron:
3318 case SMESHOp::OpQuadraticPyramid:
3319 case SMESHOp::OpQuadraticPentahedron:
3320 case SMESHOp::OpBiQuadraticPentahedron:
3321 case SMESHOp::OpQuadraticHexahedron:
3322 case SMESHOp::OpTriQuadraticHexahedron:
3324 if(checkLock(aStudy)) break;
3326 EmitSignalDeactivateDialog();
3327 SMDSAbs_EntityType type = SMDSEntity_Last;
3329 switch (theCommandID) {
3330 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3331 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3332 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3333 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3334 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3335 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3336 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3337 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3338 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3339 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3340 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3341 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3344 if ( type != SMDSEntity_Last )
3345 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3348 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3349 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3353 case SMESHOp::OpRemoveNodes:
3355 if(checkLock(aStudy)) break;
3357 EmitSignalDeactivateDialog();
3358 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3361 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3362 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3366 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3368 if(checkLock(aStudy)) break;
3370 EmitSignalDeactivateDialog();
3371 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3375 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3376 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3380 case SMESHOp::OpClearMesh: {
3382 if(checkLock(aStudy)) break;
3384 SALOME_ListIO selected;
3385 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3386 aSel->selectedObjects( selected );
3388 SUIT_OverrideCursor wc;
3389 SALOME_ListIteratorOfListIO It (selected);
3390 for ( ; It.More(); It.Next() )
3392 Handle(SALOME_InteractiveObject) IOS = It.Value();
3393 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3394 if ( aMesh->_is_nil()) continue;
3397 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3398 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3399 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3400 SMESH::ModifiedMesh( aMeshSObj, false, true);
3401 // hide groups and submeshes
3402 _PTR(ChildIterator) anIter =
3403 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3404 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3406 _PTR(SObject) so = anIter->Value();
3407 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3410 catch (const SALOME::SALOME_Exception& S_ex){
3412 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3416 SMESH::UpdateView();
3420 case SMESHOp::OpRemoveOrphanNodes:
3422 if(checkLock(aStudy)) break;
3423 SALOME_ListIO selected;
3424 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3425 aSel->selectedObjects( selected );
3426 if ( selected.Extent() == 1 ) {
3427 Handle(SALOME_InteractiveObject) anIO = selected.First();
3428 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3429 if ( !aMesh->_is_nil() ) {
3430 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3431 tr( "SMESH_WARNING" ),
3432 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3433 SUIT_MessageBox::Yes |
3434 SUIT_MessageBox::No,
3435 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3438 SUIT_OverrideCursor wc;
3439 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3440 int removed = aMeshEditor->RemoveOrphanNodes();
3441 SUIT_MessageBox::information(SMESHGUI::desktop(),
3442 tr("SMESH_INFORMATION"),
3443 tr("NB_NODES_REMOVED").arg(removed));
3444 if ( removed > 0 ) {
3445 SMESH::UpdateView();
3446 SMESHGUI::Modified();
3449 catch (const SALOME::SALOME_Exception& S_ex) {
3450 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3459 case SMESHOp::OpRenumberingNodes:
3461 if(checkLock(aStudy)) break;
3463 EmitSignalDeactivateDialog();
3464 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3468 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3469 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3473 case SMESHOp::OpRenumberingElements:
3475 if(checkLock(aStudy)) break;
3477 EmitSignalDeactivateDialog();
3478 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3482 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3483 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3487 case SMESHOp::OpTranslation:
3489 if(checkLock(aStudy)) break;
3491 EmitSignalDeactivateDialog();
3492 ( new SMESHGUI_TranslationDlg( this ) )->show();
3495 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3496 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3500 case SMESHOp::OpRotation:
3502 if(checkLock(aStudy)) break;
3504 EmitSignalDeactivateDialog();
3505 ( new SMESHGUI_RotationDlg( this ) )->show();
3508 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3509 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3513 case SMESHOp::OpSymmetry:
3515 if(checkLock(aStudy)) break;
3517 EmitSignalDeactivateDialog();
3518 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3521 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3522 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3526 case SMESHOp::OpScale:
3528 if(checkLock(aStudy)) break;
3530 EmitSignalDeactivateDialog();
3531 ( new SMESHGUI_ScaleDlg( this ) )->show();
3534 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3535 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3540 case SMESHOp::OpOffset:
3542 if(checkLock(aStudy)) break;
3544 EmitSignalDeactivateDialog();
3545 ( new SMESHGUI_OffsetDlg( this ) )->show();
3548 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3549 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3554 case SMESHOp::OpSewing:
3556 if(checkLock(aStudy)) break;
3558 EmitSignalDeactivateDialog();
3559 ( new SMESHGUI_SewingDlg( this ) )->show();
3562 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3563 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3567 case SMESHOp::OpMergeNodes:
3569 if(checkLock(aStudy)) break;
3571 EmitSignalDeactivateDialog();
3572 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3575 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3576 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3580 case SMESHOp::OpMergeElements:
3582 if (checkLock(aStudy)) break;
3584 EmitSignalDeactivateDialog();
3585 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3587 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3588 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3593 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3594 startOperation( SMESHOp::OpMoveNode );
3597 case SMESHOp::OpDuplicateNodes:
3599 if(checkLock(aStudy)) break;
3601 EmitSignalDeactivateDialog();
3602 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3605 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3606 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3611 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3612 startOperation( SMESHOp::OpElem0DOnElemNodes );
3615 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3617 static QList<int> aTypes;
3618 if ( aTypes.isEmpty() )
3620 aTypes.append( SMESH::NODE );
3621 aTypes.append( SMESH::EDGE );
3622 aTypes.append( SMESH::FACE );
3623 aTypes.append( SMESH::VOLUME );
3625 if (!myFilterLibraryDlg)
3626 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3627 else if (myFilterLibraryDlg->isHidden())
3628 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3629 myFilterLibraryDlg->raise();
3633 case SMESHOp::OpFreeNode:
3634 case SMESHOp::OpEqualNode:
3635 case SMESHOp::OpNodeConnectivityNb:
3636 case SMESHOp::OpFreeEdge:
3637 case SMESHOp::OpFreeBorder:
3638 case SMESHOp::OpLength:
3639 case SMESHOp::OpConnection:
3640 case SMESHOp::OpEqualEdge:
3641 case SMESHOp::OpFreeFace:
3642 case SMESHOp::OpBareBorderFace:
3643 case SMESHOp::OpOverConstrainedFace:
3644 case SMESHOp::OpLength2D:
3645 case SMESHOp::OpDeflection2D:
3646 case SMESHOp::OpConnection2D:
3647 case SMESHOp::OpArea:
3648 case SMESHOp::OpTaper:
3649 case SMESHOp::OpAspectRatio:
3650 case SMESHOp::OpMinimumAngle:
3651 case SMESHOp::OpWarpingAngle:
3652 case SMESHOp::OpSkew:
3653 case SMESHOp::OpMaxElementLength2D:
3654 case SMESHOp::OpEqualFace:
3655 case SMESHOp::OpAspectRatio3D:
3656 case SMESHOp::OpVolume:
3657 case SMESHOp::OpMaxElementLength3D:
3658 case SMESHOp::OpBareBorderVolume:
3659 case SMESHOp::OpOverConstrainedVolume:
3660 case SMESHOp::OpEqualVolume:
3663 LightApp_SelectionMgr* mgr = selectionMgr();
3664 SALOME_ListIO selected; mgr->selectedObjects( selected );
3666 if( !selected.IsEmpty() ) {
3667 SUIT_OverrideCursor wc;
3668 ::Control( theCommandID );
3671 SUIT_MessageBox::warning(desktop(),
3672 tr( "SMESH_WRN_WARNING" ),
3673 tr( "SMESH_BAD_SELECTION" ) );
3677 SUIT_MessageBox::warning(desktop(),
3678 tr( "SMESH_WRN_WARNING" ),
3679 tr( "NOT_A_VTK_VIEWER" ) );
3682 case SMESHOp::OpOverallMeshQuality:
3683 OverallMeshQuality();
3685 case SMESHOp::OpNumberingNodes:
3687 SUIT_OverrideCursor wc;
3688 LightApp_SelectionMgr* mgr = selectionMgr();
3689 SALOME_ListIO selected; mgr->selectedObjects( selected );
3691 SALOME_ListIteratorOfListIO it(selected);
3692 for( ; it.More(); it.Next()) {
3693 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3694 if(anIObject->hasEntry()) {
3695 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3696 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3702 case SMESHOp::OpNumberingElements:
3704 SUIT_OverrideCursor wc;
3705 LightApp_SelectionMgr* mgr = selectionMgr();
3706 SALOME_ListIO selected; mgr->selectedObjects( selected );
3708 SALOME_ListIteratorOfListIO it(selected);
3709 for( ; it.More(); it.Next()) {
3710 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3711 if(anIObject->hasEntry())
3712 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3713 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3718 case SMESHOp::OpPropertiesLength:
3719 case SMESHOp::OpPropertiesArea:
3720 case SMESHOp::OpPropertiesVolume:
3721 case SMESHOp::OpMinimumDistance:
3722 case SMESHOp::OpBoundingBox:
3724 int page = SMESHGUI_MeasureDlg::MinDistance;
3725 if ( theCommandID == SMESHOp::OpBoundingBox )
3726 page = SMESHGUI_MeasureDlg::BoundingBox;
3727 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3728 page = SMESHGUI_MeasureDlg::Length;
3729 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3730 page = SMESHGUI_MeasureDlg::Area;
3731 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3732 page = SMESHGUI_MeasureDlg::Volume;
3734 EmitSignalDeactivateDialog();
3735 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3739 case SMESHOp::OpSortChild:
3745 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3746 //updateObjBrowser();
3750 //=============================================================================
3754 //=============================================================================
3755 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3760 //=============================================================================
3764 //=============================================================================
3765 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3770 //=============================================================================
3774 //=============================================================================
3775 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3780 //=============================================================================
3781 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3782 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3784 //=============================================================================
3785 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3786 SUIT_ViewWindow* wnd )
3788 if(theIO->hasEntry()){
3789 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3790 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3794 //=======================================================================
3795 // function : createSMESHAction
3797 //=======================================================================
3798 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3799 const int key, const bool toggle, const QString& shortcutAction )
3802 QWidget* parent = application()->desktop();
3803 SUIT_ResourceMgr* resMgr = resourceMgr();
3805 if ( !icon_id.isEmpty() )
3806 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3808 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3809 if ( !pix.isNull() )
3810 icon = QIcon( pix );
3812 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3813 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3814 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3816 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3817 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3820 //=======================================================================
3821 // function : createPopupItem
3823 //=======================================================================
3824 void SMESHGUI::createPopupItem( const int id,
3825 const QString& clients,
3826 const QString& types,
3827 const QString& theRule,
3830 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3831 popupMgr()->insert( action( id ), pId, 0 );
3833 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3834 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3835 QString rule = "(%1) and (%2) and (%3)";
3836 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3837 if( clients.isEmpty() )
3838 rule = rule.arg( QString( "true" ) );
3840 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3841 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3844 bool cont = myRules.contains( id );
3846 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3848 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3849 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3852 //=======================================================================
3853 // function : initialize
3855 //=======================================================================
3856 void SMESHGUI::initialize( CAM_Application* app )
3858 SalomeApp_Module::initialize( app );
3860 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3862 /* Automatic Update flag */
3863 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3865 // ----- create actions --------------
3867 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3868 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
3869 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3870 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
3872 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
3874 createSMESHAction( SMESHOp::OpImportSAUV, "IMPORT_SAUV" );
3875 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
3876 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
3877 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
3878 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
3880 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
3882 createSMESHAction( SMESHOp::OpPopupImportSAUV, "IMPORT_SAUV" );
3883 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
3885 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
3886 createSMESHAction( SMESHOp::OpExportMED, "MED" );
3887 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
3888 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
3890 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
3892 createSMESHAction( SMESHOp::OpExportSAUV, "SAUV");
3893 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
3894 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
3895 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
3896 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
3897 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
3899 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
3901 createSMESHAction( SMESHOp::OpPopupExportSAUV, "SAUV");
3902 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
3903 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
3904 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3905 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
3906 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3907 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3908 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
3909 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
3910 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
3911 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3912 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
3913 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
3914 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
3915 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3916 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
3917 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
3918 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3919 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
3920 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3921 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3922 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3923 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
3924 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
3925 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
3926 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
3927 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
3928 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
3929 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
3930 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
3931 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
3932 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3933 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
3935 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3936 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3937 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
3938 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3939 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3940 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
3941 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
3942 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3943 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3944 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3945 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3946 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3947 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
3948 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3949 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
3950 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
3951 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
3952 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
3953 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
3954 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
3955 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3956 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3957 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3958 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3959 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3960 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3961 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3962 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3963 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
3965 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
3966 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
3967 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3968 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
3969 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
3970 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3971 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
3972 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
3973 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
3974 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
3975 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
3976 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
3977 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
3978 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3979 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3980 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3981 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3982 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3983 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3984 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
3985 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3986 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3987 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3988 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
3989 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3990 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3992 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3993 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3994 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3995 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
3997 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3998 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4000 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4001 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4002 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4003 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4004 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4005 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4006 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4007 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4008 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4009 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4010 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4011 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4012 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4013 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4014 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4015 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4016 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4017 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4018 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4019 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4020 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4021 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4022 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4023 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4024 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4026 createSMESHAction( SMESHOp::OpReset, "RESET" );
4027 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4028 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4029 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4030 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4031 #ifndef DISABLE_PLOT2DVIEWER
4032 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4034 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4035 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4036 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4037 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4038 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4039 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4040 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4041 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4042 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4043 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4044 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4045 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4046 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4048 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4049 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4051 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4052 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4053 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4054 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4055 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4056 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4057 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4058 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4059 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4061 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4062 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4063 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4064 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4065 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4067 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4068 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4069 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4071 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4073 QList<int> aCtrlActions;
4074 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4075 << SMESHOp::OpNodeConnectivityNb // node controls
4076 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4077 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4078 << SMESHOp::OpDeflection2D
4079 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4080 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4081 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4082 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4083 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4084 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4085 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4086 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4087 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4088 aCtrlGroup->setExclusive( true );
4089 for( int i = 0; i < aCtrlActions.size(); i++ )
4090 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4092 // ----- create menu --------------
4093 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4094 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4095 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4096 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4097 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4098 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4099 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4100 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4102 createMenu( separator(), fileId );
4104 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4105 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4106 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4107 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4108 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4109 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4110 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4111 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4112 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4113 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4114 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4115 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4116 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4118 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4119 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4120 createMenu( SMESHOp::OpImportMED, importId, -1 );
4121 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4123 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4125 createMenu( SMESHOp::OpImportSAUV, importId, -1 );
4126 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4127 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4128 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4129 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4130 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4132 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4134 createMenu( SMESHOp::OpExportSAUV, exportId, -1 );
4135 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4136 createMenu( separator(), fileId, 10 );
4138 createMenu( SMESHOp::OpDelete, editId, -1 );
4140 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4142 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4143 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4144 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4145 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4146 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4147 createMenu( separator(), meshId, -1 );
4148 createMenu( SMESHOp::OpCompute, meshId, -1 );
4149 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4150 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4151 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4152 createMenu( separator(), meshId, -1 );
4153 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4154 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4155 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4156 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4157 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4158 createMenu( separator(), meshId, -1 );
4159 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4160 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4161 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4162 createMenu( separator(), meshId, -1 );
4163 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4164 createMenu( separator(), meshId, -1 );
4165 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4166 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4167 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4168 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4169 createMenu( separator(), meshId, -1 );
4171 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4172 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4173 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4174 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4175 createMenu( SMESHOp::OpLength, edgeId, -1 );
4176 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4177 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4178 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4179 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4180 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4181 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4182 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4183 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4184 createMenu( SMESHOp::OpArea, faceId, -1 );
4185 createMenu( SMESHOp::OpTaper, faceId, -1 );
4186 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4187 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4188 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4189 createMenu( SMESHOp::OpSkew, faceId, -1 );
4190 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4191 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4192 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4193 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4194 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4195 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4196 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4197 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4198 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4199 createMenu( separator(), ctrlId, -1 );
4200 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4201 createMenu( separator(), ctrlId, -1 );
4202 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4204 createMenu( SMESHOp::OpNode, addId, -1 );
4205 createMenu( SMESHOp::OpElem0D, addId, -1 );
4206 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4207 createMenu( SMESHOp::OpBall, addId, -1 );
4208 createMenu( SMESHOp::OpEdge, addId, -1 );
4209 createMenu( SMESHOp::OpTriangle, addId, -1 );
4210 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4211 createMenu( SMESHOp::OpPolygon, addId, -1 );
4212 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4213 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4214 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4215 createMenu( SMESHOp::OpPyramid, addId, -1 );
4216 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4217 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4218 createMenu( separator(), addId, -1 );
4219 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4220 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4221 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4222 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4223 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4224 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4225 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4226 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4227 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4228 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4229 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4230 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4232 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4233 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4234 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4235 createMenu( separator(), removeId, -1 );
4236 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4237 createMenu( separator(), removeId, -1 );
4238 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4240 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4241 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4243 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4244 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4245 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4246 createMenu( SMESHOp::OpRotation, transfId, -1 );
4247 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4248 createMenu( SMESHOp::OpScale, transfId, -1 );
4249 createMenu( SMESHOp::OpOffset, transfId, -1 );
4250 createMenu( SMESHOp::OpSewing, transfId, -1 );
4251 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4253 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4254 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4255 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4256 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4257 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4258 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4259 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4260 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4261 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4262 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4263 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4264 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4265 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4266 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4267 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4268 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4270 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4271 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4272 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4273 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4274 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4275 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4277 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4278 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4279 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4280 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4282 // ----- create toolbars --------------
4283 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ),
4284 info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ),
4285 groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ),
4286 ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ),
4287 ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ),
4288 ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ),
4289 ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ),
4290 addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ),
4291 addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ),
4292 remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ),
4293 //renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ),
4294 transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
4295 modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ),
4296 measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ),
4297 dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4299 createTool( SMESHOp::OpCreateMesh, meshTb );
4300 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4301 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4302 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4303 createTool( SMESHOp::OpCopyMesh, meshTb );
4304 createTool( separator(), meshTb );
4305 createTool( SMESHOp::OpCompute, meshTb );
4306 createTool( SMESHOp::OpPreCompute, meshTb );
4307 createTool( SMESHOp::OpEvaluate, meshTb );
4308 createTool( SMESHOp::OpMeshOrder, meshTb );
4310 createTool( SMESHOp::OpCreateGroup, groupTb );
4311 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4312 createTool( SMESHOp::OpConstructGroup, groupTb );
4313 createTool( SMESHOp::OpEditGroup, groupTb );
4315 createTool( SMESHOp::OpMeshInformation, info );
4316 //createTool( SMESHOp::OpStdInfo, meshTb );
4317 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4318 createTool( SMESHOp::OpFindElementByPoint, info );
4320 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4321 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4322 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4324 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4325 createTool( SMESHOp::OpLength, ctrl1dTb );
4326 createTool( SMESHOp::OpConnection, ctrl1dTb );
4327 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4329 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4330 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4331 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4332 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4333 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4334 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4335 createTool( SMESHOp::OpArea, ctrl2dTb );
4336 createTool( SMESHOp::OpTaper, ctrl2dTb );
4337 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4338 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4339 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4340 createTool( SMESHOp::OpSkew, ctrl2dTb );
4341 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4342 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4343 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4345 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4346 createTool( SMESHOp::OpVolume, ctrl3dTb );
4347 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4348 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4349 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4350 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4352 createTool( SMESHOp::OpNode, addElemTb );
4353 createTool( SMESHOp::OpElem0D, addElemTb );
4354 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4355 createTool( SMESHOp::OpBall, addElemTb );
4356 createTool( SMESHOp::OpEdge, addElemTb );
4357 createTool( SMESHOp::OpTriangle, addElemTb );
4358 createTool( SMESHOp::OpQuadrangle, addElemTb );
4359 createTool( SMESHOp::OpPolygon, addElemTb );
4360 createTool( SMESHOp::OpTetrahedron, addElemTb );
4361 createTool( SMESHOp::OpHexahedron, addElemTb );
4362 createTool( SMESHOp::OpPentahedron, addElemTb );
4363 createTool( SMESHOp::OpPyramid, addElemTb );
4364 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4365 createTool( SMESHOp::OpPolyhedron, addElemTb );
4367 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4368 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4369 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4370 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4371 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4372 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4373 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4374 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4375 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4376 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4377 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4378 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4380 createTool( SMESHOp::OpRemoveNodes, remTb );
4381 createTool( SMESHOp::OpRemoveElements, remTb );
4382 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4383 createTool( SMESHOp::OpClearMesh, remTb );
4385 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4386 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4388 createTool( SMESHOp::OpMergeNodes, transformTb );
4389 createTool( SMESHOp::OpMergeElements, transformTb );
4390 createTool( SMESHOp::OpTranslation, transformTb );
4391 createTool( SMESHOp::OpRotation, transformTb );
4392 createTool( SMESHOp::OpSymmetry, transformTb );
4393 createTool( SMESHOp::OpScale, transformTb );
4394 createTool( SMESHOp::OpOffset, transformTb );
4395 createTool( SMESHOp::OpSewing, transformTb );
4396 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4398 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4399 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4400 createTool( SMESHOp::OpExtrusion, modifyTb );
4401 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4402 createTool( SMESHOp::OpRevolution, modifyTb );
4403 createTool( SMESHOp::OpOrientation, modifyTb );
4404 createTool( SMESHOp::OpReorientFaces, modifyTb );
4405 createTool( SMESHOp::OpMoveNode, modifyTb );
4406 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4407 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4408 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4409 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4410 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4411 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4412 createTool( SMESHOp::OpSmoothing, modifyTb );
4413 createTool( SMESHOp::OpPatternMapping, modifyTb );
4415 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4417 createTool( SMESHOp::OpUpdate, dispModeTb );
4419 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4420 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4424 OB = "'ObjectBrowser'",
4425 View = "'" + SVTK_Viewer::Type() + "'",
4427 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4428 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4429 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4430 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4431 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4432 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4433 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4434 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4435 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4436 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4437 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4438 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4440 mesh_part = mesh + " " + subMesh + " " + group,
4441 mesh_group = mesh + " " + group,
4442 mesh_submesh = mesh + " " + subMesh,
4443 hyp_alg = hypo + " " + algo;
4445 // popup for object browser
4447 isInvisible("not( isVisible )"),
4448 isEmpty("numberOfNodes = 0"),
4449 isNotEmpty("numberOfNodes <> 0"),
4451 // has nodes, edges, etc in VISIBLE! actor
4452 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4453 hasElems("(count( elemTypes ) > 0)"),
4454 hasDifferentElems("(count( elemTypes ) > 1)"),
4455 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4456 hasBalls("({'BallElem'} in elemTypes)"),
4457 hasElems0d("({'Elem0d'} in elemTypes)"),
4458 hasEdges("({'Edge'} in elemTypes)"),
4459 hasFaces("({'Face'} in elemTypes)"),
4460 hasVolumes("({'Volume'} in elemTypes)"),
4461 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4463 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4464 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4465 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4466 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4467 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4468 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4470 popupMgr()->insert( separator(), -1, 0 );
4471 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && isComputable" );
4472 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && isComputable" );
4473 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && isPreComputable" );
4474 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && isComputable" );
4475 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && isComputable && hasGeomReference" );
4476 createPopupItem( SMESHOp::OpUpdate, OB, mesh_part );
4477 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4478 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1" );
4479 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4480 popupMgr()->insert( separator(), -1, 0 );
4481 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4482 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4483 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4484 popupMgr()->insert( separator(), -1, 0 );
4485 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4486 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4487 popupMgr()->insert( separator(), -1, 0 );
4488 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh );
4489 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4490 popupMgr()->insert( separator(), -1, 0 );
4491 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4492 //popupMgr()->insert( separator(), -1, 0 );
4494 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4495 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4496 QString only_one_2D = only_one_non_empty + " && dim>1";
4498 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4499 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4500 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4501 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4503 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4505 createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
4506 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4507 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4508 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4509 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4511 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4512 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4513 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4514 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4516 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4518 createPopupItem( SMESHOp::OpPopupImportSAUV, OB, smesh, "", anId );
4519 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4520 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4521 popupMgr()->insert( separator(), -1, 0 );
4524 createPopupItem( SMESHOp::OpEditGroup, View, group );
4525 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4526 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4528 popupMgr()->insert( separator(), -1, 0 );
4529 createPopupItem( SMESHOp::OpUpdate, View, mesh_part );
4530 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4531 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4532 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
4533 popupMgr()->insert( separator(), -1, 0 );
4535 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4536 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4537 popupMgr()->insert( separator(), -1, 0 );
4539 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4540 QString aType = QString( "%1type in {%2}" ).arg( lc );
4541 aType = aType.arg( mesh_part );
4542 QString aMeshInVTK = aClient + "&&" + aType;
4544 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4545 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4546 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4548 //-------------------------------------------------
4550 //-------------------------------------------------
4551 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4553 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4554 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4555 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4557 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4558 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4559 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4561 popupMgr()->insert( separator(), -1, -1 );
4563 //-------------------------------------------------
4565 //-------------------------------------------------
4566 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4568 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4569 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4570 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4572 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4573 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4574 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4576 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4577 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4578 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4580 popupMgr()->insert( separator(), anId, -1 );
4582 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4583 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4584 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4586 //-------------------------------------------------
4588 //-------------------------------------------------
4589 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4591 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4593 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4594 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4595 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4597 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4598 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4599 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4601 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4602 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4603 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4605 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4606 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4607 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4609 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4610 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4611 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4613 popupMgr()->insert( separator(), anId, -1 );
4615 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4616 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4618 popupMgr()->insert( separator(), anId, -1 );
4620 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4621 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4624 //-------------------------------------------------
4625 // Representation of the 2D Quadratic elements
4626 //-------------------------------------------------
4627 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4628 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4629 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4630 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4632 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4633 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4634 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4636 //-------------------------------------------------
4637 // Orientation of faces
4638 //-------------------------------------------------
4639 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4640 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4641 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4643 //-------------------------------------------------
4645 //-------------------------------------------------
4646 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4647 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4649 //-------------------------------------------------
4651 //-------------------------------------------------
4652 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4653 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4655 //-------------------------------------------------
4657 //-------------------------------------------------
4659 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4660 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4661 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4662 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4664 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4666 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4667 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4669 popupMgr()->insert( separator(), anId, -1 );
4671 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4673 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4674 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4675 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4677 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4678 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4679 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4681 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4682 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4683 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4685 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4687 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4688 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4689 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4691 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4692 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4693 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4695 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4696 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4697 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4698 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4699 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4700 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4702 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4704 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4705 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4706 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4708 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4709 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4710 QtxPopupMgr::VisibleRule );
4711 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4713 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4714 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4715 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4717 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4718 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4719 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4721 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4722 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4723 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4725 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4726 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4727 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4729 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4730 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4731 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4733 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4734 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4735 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4737 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4738 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4739 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4741 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4742 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4743 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4745 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4746 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4747 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4749 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4750 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4751 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4753 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4754 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4755 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4757 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4758 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4759 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4761 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
4762 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
4763 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
4765 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4767 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4768 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4769 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4771 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4772 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4773 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4775 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4776 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4777 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4779 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
4780 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4781 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4783 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
4784 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4785 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4787 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
4788 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4789 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4791 popupMgr()->insert( separator(), anId, -1 );
4793 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
4794 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4795 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
4796 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
4797 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4799 popupMgr()->insert( separator(), anId, -1 );
4801 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4803 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
4804 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4806 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
4807 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4808 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
4810 #ifndef DISABLE_PLOT2DVIEWER
4811 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
4812 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4815 //-------------------------------------------------
4817 //-------------------------------------------------
4818 popupMgr()->insert( separator(), -1, -1 );
4819 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4820 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4821 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
4822 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4824 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
4825 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4827 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
4828 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4830 popupMgr()->insert( separator(), -1, -1 );
4832 //-------------------------------------------------
4834 //-------------------------------------------------
4835 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
4836 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4838 popupMgr()->insert( separator(), -1, -1 );
4840 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
4841 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4842 popupMgr()->insert( separator(), -1, -1 );
4844 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4845 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4847 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4848 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4851 //================================================================================
4853 * \brief Return true if SMESH or GEOM objects are selected.
4854 * Is called form LightApp_Module::activateModule() which clear selection if
4855 * not isSelectionCompatible()
4857 //================================================================================
4859 bool SMESHGUI::isSelectionCompatible()
4861 bool isCompatible = true;
4862 SALOME_ListIO selected;
4863 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4864 Sel->selectedObjects( selected );
4866 SALOME_ListIteratorOfListIO It( selected );
4867 for ( ; isCompatible && It.More(); It.Next())
4869 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4870 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4872 return isCompatible;
4876 bool SMESHGUI::reusableOperation( const int id )
4878 // compute, evaluate and precompute are not reusable operations
4879 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
4882 bool SMESHGUI::activateModule( SUIT_Study* study )
4884 bool res = SalomeApp_Module::activateModule( study );
4886 setMenuShown( true );
4887 setToolShown( true );
4889 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4890 PyGILState_STATE gstate = PyGILState_Ensure();
4891 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4892 if ( !pluginsmanager ) {
4896 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
4901 PyGILState_Release(gstate);
4902 // end of SMESH plugins loading
4904 // Reset actions accelerator keys
4905 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
4907 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4908 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4909 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study )) {
4910 if ( _PTR(Study) aStudy = s->studyDS() )
4911 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4914 // get all view currently opened in the study and connect their signals to
4915 // the corresponding slots of the class.
4916 SUIT_Desktop* aDesk = study->application()->desktop();
4918 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4919 SUIT_ViewWindow* wnd;
4920 foreach ( wnd, wndList )
4924 Py_XDECREF(pluginsmanager);
4928 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4930 setMenuShown( false );
4931 setToolShown( false );
4933 EmitSignalCloseAllDialogs();
4935 // Unset actions accelerator keys
4936 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
4938 return SalomeApp_Module::deactivateModule( study );
4941 void SMESHGUI::studyClosed( SUIT_Study* s )
4945 SMESH::RemoveVisuData( s->id() );
4946 SalomeApp_Module::studyClosed( s );
4949 void SMESHGUI::OnGUIEvent()
4951 const QObject* obj = sender();
4952 if ( !obj || !obj->inherits( "QAction" ) )
4954 int id = actionId((QAction*)obj);
4959 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4961 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4962 if ( CORBA::is_nil( myComponentSMESH ) )
4964 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4966 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4967 return aGUI.myComponentSMESH;
4970 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4971 return myComponentSMESH;
4974 QString SMESHGUI::engineIOR() const
4976 CORBA::ORB_var anORB = getApp()->orb();
4977 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4978 return QString( anIOR.in() );
4981 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4983 SalomeApp_Module::contextMenuPopup( client, menu, title );
4985 selectionMgr()->selectedObjects( lst );
4986 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4987 Handle(SALOME_InteractiveObject) io = lst.First();
4988 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4989 _PTR(Study) study = appStudy->studyDS();
4990 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4992 QString aName = QString( SMESH::fromUtf8(obj->GetName()) );
4993 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4994 aName.remove( (aName.length() - 1), 1 );
5000 LightApp_Selection* SMESHGUI::createSelection() const
5002 return new SMESHGUI_Selection();
5005 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5007 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5008 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5009 #ifndef DISABLE_PYCONSOLE
5010 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5014 void SMESHGUI::viewManagers( QStringList& list ) const
5016 list.append( SVTK_Viewer::Type() );
5019 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5021 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5022 SMESH::UpdateSelectionProp( this );
5024 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5025 for(int i = 0; i < aViews.count() ; i++){
5026 SUIT_ViewWindow *sf = aViews[i];
5029 EmitSignalActivatedViewManager();
5033 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5035 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5036 myClippingPlaneInfoMap.erase( theViewManager );
5039 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5041 theActor->AddObserver( SMESH::DeleteActorEvent,
5042 myEventCallbackCommand.GetPointer(),
5046 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5047 unsigned long theEvent,
5048 void* theClientData,
5051 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5052 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5053 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5054 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5055 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5056 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5057 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5058 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5059 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5060 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5061 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5062 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5063 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5064 if( anActor == *anIter3 ) {
5065 anActorList.erase( anIter3 );
5076 void SMESHGUI::createPreferences()
5078 // General tab ------------------------------------------------------------------------
5079 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5081 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5082 setPreferenceProperty( autoUpdate, "columns", 2 );
5083 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5084 setPreferenceProperty( lim, "min", 0 );
5085 setPreferenceProperty( lim, "max", 100000000 );
5086 setPreferenceProperty( lim, "step", 1000 );
5087 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5088 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5090 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5091 setPreferenceProperty( dispgroup, "columns", 2 );
5092 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5094 modes.append( tr("MEN_WIRE") );
5095 modes.append( tr("MEN_SHADE") );
5096 modes.append( tr("MEN_NODES") );
5097 modes.append( tr("MEN_SHRINK") );
5098 QList<QVariant> indices;
5099 indices.append( 0 );
5100 indices.append( 1 );
5101 indices.append( 2 );
5102 indices.append( 3 );
5103 setPreferenceProperty( dispmode, "strings", modes );
5104 setPreferenceProperty( dispmode, "indexes", indices );
5106 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5107 setPreferenceProperty( arcgroup, "columns", 2 );
5108 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5109 QStringList quadraticModes;
5110 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5111 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5113 indices.append( 0 );
5114 indices.append( 1 );
5115 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5116 setPreferenceProperty( quadraticmode, "indexes", indices );
5118 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5119 "SMESH", "max_angle" );
5120 setPreferenceProperty( maxAngle, "min", 1 );
5121 setPreferenceProperty( maxAngle, "max", 90 );
5123 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5124 setPreferenceProperty( qaGroup, "columns", 2 );
5125 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5126 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5127 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5128 setPreferenceProperty( prec, "min", 0 );
5129 setPreferenceProperty( prec, "max", 100 );
5130 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5131 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5132 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5133 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5134 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5137 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5138 setPreferenceProperty( exportgroup, "columns", 2 );
5139 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5140 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5141 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5143 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5144 setPreferenceProperty( computeGroup, "columns", 2 );
5145 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5147 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5148 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5149 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5151 indices.append( 0 );
5152 indices.append( 1 );
5153 indices.append( 2 );
5154 setPreferenceProperty( notifyMode, "strings", modes );
5155 setPreferenceProperty( notifyMode, "indexes", indices );
5157 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5158 setPreferenceProperty( infoGroup, "columns", 2 );
5159 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5161 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5162 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5164 indices.append( 0 );
5165 indices.append( 1 );
5166 setPreferenceProperty( elemInfo, "strings", modes );
5167 setPreferenceProperty( elemInfo, "indexes", indices );
5168 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5169 setPreferenceProperty( nodesLim, "min", 0 );
5170 setPreferenceProperty( nodesLim, "max", 10000000 );
5171 setPreferenceProperty( nodesLim, "step", 10000 );
5172 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5173 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5174 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5175 setPreferenceProperty( ctrlLim, "min", 0 );
5176 setPreferenceProperty( ctrlLim, "max", 10000000 );
5177 setPreferenceProperty( ctrlLim, "step", 1000 );
5178 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5179 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5180 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5181 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5182 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5184 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5185 setPreferenceProperty( segGroup, "columns", 2 );
5186 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5187 "SMESH", "segmentation" );
5188 setPreferenceProperty( segLen, "min", 1 );
5189 setPreferenceProperty( segLen, "max", 10000000 );
5190 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5191 "SMESH", "nb_segments_per_edge" );
5192 setPreferenceProperty( nbSeg, "min", 1 );
5193 setPreferenceProperty( nbSeg, "max", 10000000 );
5195 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5196 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5197 "SMESH", "forget_mesh_on_hyp_modif" );
5200 // Quantities with individual precision settings
5201 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5202 setPreferenceProperty( precGroup, "columns", 2 );
5204 const int nbQuantities = 6;
5205 int precs[nbQuantities], ii = 0;
5206 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5207 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5208 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5209 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5210 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5211 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5212 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5213 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5214 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5215 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5216 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5217 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5219 // Set property for precision value for spinboxes
5220 for ( ii = 0; ii < nbQuantities; ii++ ){
5221 setPreferenceProperty( precs[ii], "min", -14 );
5222 setPreferenceProperty( precs[ii], "max", 14 );
5223 setPreferenceProperty( precs[ii], "precision", 2 );
5226 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5227 setPreferenceProperty( previewGroup, "columns", 2 );
5228 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5229 setPreferenceProperty( chunkSize, "min", 1 );
5230 setPreferenceProperty( chunkSize, "max", 1000 );
5231 setPreferenceProperty( chunkSize, "step", 50 );
5233 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5234 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5236 // Mesh tab ------------------------------------------------------------------------
5237 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5238 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5239 setPreferenceProperty( nodeGroup, "columns", 3 );
5241 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5243 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5245 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5246 QList<QVariant> aMarkerTypeIndicesList;
5247 QList<QVariant> aMarkerTypeIconsList;
5248 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5249 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5250 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5251 aMarkerTypeIndicesList << i;
5252 aMarkerTypeIconsList << pixmap;
5254 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5255 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5257 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5259 QList<QVariant> aMarkerScaleIndicesList;
5260 QStringList aMarkerScaleValuesList;
5261 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5262 aMarkerScaleIndicesList << i;
5263 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5264 aMarkerScaleValuesList << QString::number( i );
5266 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5267 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5269 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5270 //setPreferenceProperty( elemGroup, "columns", 2 );
5272 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5273 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5274 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5275 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5276 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5277 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5278 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5279 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5280 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5283 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5284 setPreferenceProperty( grpGroup, "columns", 2 );
5286 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5287 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5289 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5290 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5291 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5292 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5293 double ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5294 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5295 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5296 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5297 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5298 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5299 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5300 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5301 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5302 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5304 setPreferenceProperty( size0d, "min", 1 );
5305 setPreferenceProperty( size0d, "max", 10 );
5307 // setPreferenceProperty( ballSize, "min", 1 );
5308 // setPreferenceProperty( ballSize, "max", 10 );
5310 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5311 setPreferenceProperty( ballDiameter, "max", 1e9 );
5312 setPreferenceProperty( ballDiameter, "step", 0.1 );
5314 setPreferenceProperty( ballScale, "min", 1e-2 );
5315 setPreferenceProperty( ballScale, "max", 1e7 );
5316 setPreferenceProperty( ballScale, "step", 0.5 );
5318 setPreferenceProperty( elemW, "min", 1 );
5319 setPreferenceProperty( elemW, "max", 5 );
5321 setPreferenceProperty( outW, "min", 1 );
5322 setPreferenceProperty( outW, "max", 5 );
5324 setPreferenceProperty( shrink, "min", 0 );
5325 setPreferenceProperty( shrink, "max", 100 );
5327 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5328 setPreferenceProperty( numGroup, "columns", 2 );
5330 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5331 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5333 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5334 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5336 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5337 setPreferenceProperty( orientGroup, "columns", 1 );
5339 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5340 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5342 setPreferenceProperty( orientScale, "min", 0.05 );
5343 setPreferenceProperty( orientScale, "max", 0.5 );
5344 setPreferenceProperty( orientScale, "step", 0.05 );
5346 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5348 // Selection tab ------------------------------------------------------------------------
5349 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5351 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5352 setPreferenceProperty( selGroup, "columns", 2 );
5354 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5355 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5357 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5358 setPreferenceProperty( preGroup, "columns", 2 );
5360 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5362 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5363 setPreferenceProperty( precSelGroup, "columns", 2 );
5365 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5366 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5367 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5369 // Scalar Bar tab ------------------------------------------------------------------------
5370 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5371 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5372 setPreferenceProperty( fontGr, "columns", 2 );
5374 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5375 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5377 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5378 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5380 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5381 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5383 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5384 setPreferenceProperty( numcol, "min", 2 );
5385 setPreferenceProperty( numcol, "max", 256 );
5387 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5388 setPreferenceProperty( numlab, "min", 2 );
5389 setPreferenceProperty( numlab, "max", 65 );
5391 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5392 setPreferenceProperty( orientGr, "columns", 2 );
5393 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5394 QStringList orients;
5395 orients.append( tr( "SMESH_VERTICAL" ) );
5396 orients.append( tr( "SMESH_HORIZONTAL" ) );
5397 indices.clear(); indices.append( 0 ); indices.append( 1 );
5398 setPreferenceProperty( orient, "strings", orients );
5399 setPreferenceProperty( orient, "indexes", indices );
5401 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5402 setPreferenceProperty( posVSizeGr, "columns", 2 );
5403 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5404 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5405 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5406 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5407 setPreferenceProperty( xv, "step", 0.1 );
5408 setPreferenceProperty( xv, "min", 0.0 );
5409 setPreferenceProperty( xv, "max", 1.0 );
5410 setPreferenceProperty( yv, "step", 0.1 );
5411 setPreferenceProperty( yv, "min", 0.0 );
5412 setPreferenceProperty( yv, "max", 1.0 );
5413 setPreferenceProperty( wv, "step", 0.1 );
5414 setPreferenceProperty( wv, "min", 0.0 );
5415 setPreferenceProperty( wv, "max", 1.0 );
5416 setPreferenceProperty( hv, "min", 0.0 );
5417 setPreferenceProperty( hv, "max", 1.0 );
5418 setPreferenceProperty( hv, "step", 0.1 );
5420 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5421 setPreferenceProperty( posHSizeGr, "columns", 2 );
5422 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5423 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5424 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5425 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5426 setPreferenceProperty( xv, "min", 0.0 );
5427 setPreferenceProperty( xv, "max", 1.0 );
5428 setPreferenceProperty( xv, "step", 0.1 );
5429 setPreferenceProperty( xh, "min", 0.0 );
5430 setPreferenceProperty( xh, "max", 1.0 );
5431 setPreferenceProperty( xh, "step", 0.1 );
5432 setPreferenceProperty( yh, "min", 0.0 );
5433 setPreferenceProperty( yh, "max", 1.0 );
5434 setPreferenceProperty( yh, "step", 0.1 );
5435 setPreferenceProperty( wh, "min", 0.0 );
5436 setPreferenceProperty( wh, "max", 1.0 );
5437 setPreferenceProperty( wh, "step", 0.1 );
5438 setPreferenceProperty( hh, "min", 0.0 );
5439 setPreferenceProperty( hh, "max", 1.0 );
5440 setPreferenceProperty( hh, "step", 0.1 );
5442 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5443 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5444 setPreferenceProperty( distributionGr, "columns", 3 );
5446 types.append( tr( "SMESH_MONOCOLOR" ) );
5447 types.append( tr( "SMESH_MULTICOLOR" ) );
5448 indices.clear(); indices.append( 0 ); indices.append( 1 );
5449 setPreferenceProperty( coloringType, "strings", types );
5450 setPreferenceProperty( coloringType, "indexes", indices );
5451 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5455 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5457 if ( sect=="SMESH" ) {
5458 float sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5459 float aTol = 1.00000009999999;
5460 std::string aWarning;
5461 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5463 if ( name== "selection_object_color" ||
5464 name=="selection_element_color" ||
5465 name== "highlight_color" ||
5466 name=="selection_precision_node" ||
5467 name=="selection_precision_element" ||
5468 name=="selection_precision_object" )
5470 SMESH::UpdateSelectionProp( this );
5472 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5474 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5475 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5476 if ( sbX1+sbW > aTol ) {
5477 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5480 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5481 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5484 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5486 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5487 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5488 if ( sbY1 + sbH > aTol ) {
5489 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5490 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5491 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5494 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5496 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5497 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5498 if ( sbX1 + sbW > aTol ) {
5499 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5502 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5503 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5506 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5508 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5509 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5510 if ( sbY1 + sbH > aTol ) {
5511 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5514 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5515 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5518 else if ( name == "segmentation" )
5520 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5521 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5523 else if ( name == "nb_segments_per_edge" )
5525 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5526 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5528 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5530 QString val = aResourceMgr->stringValue( "SMESH", name );
5531 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5533 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5535 SMESH::UpdateFontProp( this );
5537 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5539 SMESH::UpdateFontProp( this );
5542 if ( aWarning.size() != 0 ) {
5543 aWarning += "The default values are applied instead.";
5544 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5545 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5546 QObject::tr(aWarning.c_str()));
5551 //================================================================================
5553 * \brief Update something in accordance with update flags
5554 * \param theFlags - update flags
5556 * Update viewer or/and object browser etc. in accordance with update flags ( see
5557 * LightApp_UpdateFlags enumeration ).
5559 //================================================================================
5560 void SMESHGUI::update( const int flags )
5562 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5563 SMESH::UpdateView();
5565 SalomeApp_Module::update( flags );
5568 //================================================================================
5570 * \brief Set default selection mode
5572 * SLOT called when operation committed. Sets default selection mode
5574 //================================================================================
5575 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5577 SVTK_ViewWindow* vtkWnd =
5578 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5580 vtkWnd->SetSelectionMode( ActorSelection );
5583 //================================================================================
5585 * \brief Set default selection mode
5587 * SLOT called when operation aborted. Sets default selection mode
5589 //================================================================================
5590 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5592 SVTK_ViewWindow* vtkWnd =
5593 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5595 vtkWnd->SetSelectionMode( ActorSelection );
5598 //================================================================================
5600 * \brief Creates operation with given identifier
5601 * \param id - identifier of operation to be started
5602 * \return Pointer on created operation or NULL if operation is not created
5604 * Virtual method redefined from the base class creates operation with given id.
5605 * It is called called automatically from startOperation method of base class.
5607 //================================================================================
5608 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5610 LightApp_Operation* op = 0;
5611 // to do : create operation here
5614 case SMESHOp::OpSplitBiQuadratic:
5615 op = new SMESHGUI_SplitBiQuadOp();
5617 case SMESHOp::OpConvertMeshToQuadratic:
5618 op = new SMESHGUI_ConvToQuadOp();
5620 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5621 op = new SMESHGUI_Make2DFrom3DOp();
5623 case SMESHOp::OpReorientFaces:
5624 op = new SMESHGUI_ReorientFacesOp();
5626 case SMESHOp::OpCreateMesh:
5627 op = new SMESHGUI_MeshOp( true, true );
5629 case SMESHOp::OpCreateSubMesh:
5630 op = new SMESHGUI_MeshOp( true, false );
5632 case SMESHOp::OpEditMeshOrSubMesh:
5633 case SMESHOp::OpEditMesh:
5634 case SMESHOp::OpEditSubMesh:
5635 op = new SMESHGUI_MeshOp( false );
5637 case SMESHOp::OpCompute:
5638 case SMESHOp::OpComputeSubMesh:
5639 op = new SMESHGUI_ComputeOp();
5641 case SMESHOp::OpPreCompute:
5642 op = new SMESHGUI_PrecomputeOp();
5644 case SMESHOp::OpEvaluate:
5645 op = new SMESHGUI_EvaluateOp();
5647 case SMESHOp::OpMeshOrder:
5648 op = new SMESHGUI_MeshOrderOp();
5650 case SMESHOp::OpCreateGeometryGroup:
5651 op = new SMESHGUI_GroupOnShapeOp();
5653 case SMESHOp::OpFindElementByPoint:
5654 op = new SMESHGUI_FindElemByPointOp();
5656 case SMESHOp::OpMoveNode: // Make mesh pass through point
5657 op = new SMESHGUI_MakeNodeAtPointOp();
5659 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5660 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5667 op = SalomeApp_Module::createOperation( id );
5671 //================================================================================
5673 * \brief Stops current operations and starts a given one
5674 * \param id - The id of the operation to start
5676 //================================================================================
5678 void SMESHGUI::switchToOperation(int id)
5680 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5681 activeStudy()->abortAllOperations();
5682 startOperation( id );
5685 LightApp_Displayer* SMESHGUI::displayer()
5688 myDisplayer = new SMESHGUI_Displayer( getApp() );
5692 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5695 int aTolerance = 64;
5696 int anIterations = 0;
5702 if( anIterations % aPeriod == 0 )
5705 if( aTolerance < 1 )
5709 aHue = (int)( 360.0 * rand() / RAND_MAX );
5712 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5713 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5714 for( ; it != itEnd; ++it )
5716 SALOMEDS::Color anAutoColor = *it;
5717 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5720 aQColor.getHsv( &h, &s, &v );
5721 if( abs( h - aHue ) < aTolerance )
5733 aColor.setHsv( aHue, 255, 255 );
5735 SALOMEDS::Color aSColor;
5736 aSColor.R = aColor.redF();
5737 aSColor.G = aColor.greenF();
5738 aSColor.B = aColor.blueF();
5743 const char* gSeparator = "_"; // character used to separate parameter names
5744 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5745 const char* gPathSep = "|"; // character used to separate paths
5748 * \brief Store visual parameters
5750 * This method is called just before the study document is saved.
5751 * Store visual parameters in AttributeParameter attribue(s)
5753 void SMESHGUI::storeVisualParameters (int savePoint)
5756 Kernel_Utils::Localizer loc;
5758 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5759 if (!appStudy || !appStudy->studyDS())
5761 _PTR(Study) studyDS = appStudy->studyDS();
5763 // componentName is used for encoding of entries when storing them in IParameters
5764 std::string componentName = myComponentSMESH->ComponentDataType();
5765 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5766 //if (!aSComponent) return;
5769 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5770 componentName.c_str(),
5772 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5774 // store map of custom markers
5775 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5776 if( !aMarkerMap.empty() )
5778 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5779 for( ; anIter != aMarkerMap.end(); anIter++ )
5781 int anId = anIter->first;
5782 VTK::MarkerData aMarkerData = anIter->second;
5783 std::string aMarkerFileName = aMarkerData.first;
5784 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5785 if( aMarkerTexture.size() < 3 )
5786 continue; // should contain at least width, height and the first value
5788 QString aPropertyName( "texture" );
5789 aPropertyName += gSeparator;
5790 aPropertyName += QString::number( anId );
5792 QString aPropertyValue = aMarkerFileName.c_str();
5793 aPropertyValue += gPathSep;
5795 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5796 ushort aWidth = *aTextureIter++;
5797 ushort aHeight = *aTextureIter++;
5798 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5799 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5800 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5801 aPropertyValue += QString::number( *aTextureIter );
5803 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5807 // viewers counters are used for storing view_numbers in IParameters
5810 // main cycle to store parameters of displayed objects
5811 QList<SUIT_ViewManager*> lst;
5812 QList<SUIT_ViewManager*>::Iterator it;
5813 getApp()->viewManagers(lst);
5814 for (it = lst.begin(); it != lst.end(); it++)
5816 SUIT_ViewManager* vman = *it;
5817 QString vType = vman->getType();
5819 // saving VTK actors properties
5820 if (vType == SVTK_Viewer::Type())
5822 // store the clipping planes attached to the view manager
5823 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5824 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5825 if( anIter != myClippingPlaneInfoMap.end() )
5826 aClippingPlaneInfoList = anIter->second;
5828 if( !aClippingPlaneInfoList.empty() ) {
5829 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5830 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5832 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5833 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5835 QString aPropertyName( "ClippingPlane" );
5836 aPropertyName += gSeparator;
5837 aPropertyName += QString::number( vtkViewers );
5838 aPropertyName += gSeparator;
5839 aPropertyName += QString::number( anId );
5841 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5842 aPropertyValue += gDigitsSep;
5843 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5844 aPropertyValue += gDigitsSep;
5845 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5846 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5847 aPropertyValue += gDigitsSep;
5848 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5849 aPropertyValue += gDigitsSep;
5850 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5851 aPropertyValue += gDigitsSep;
5852 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5853 aPropertyValue += gDigitsSep;
5854 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5855 aPropertyValue += gDigitsSep;
5856 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5857 aPropertyValue += gDigitsSep;
5858 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5860 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5861 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5862 aPropertyValue += gDigitsSep;
5863 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5864 aPropertyValue += gDigitsSep;
5865 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5866 aPropertyValue += gDigitsSep;
5867 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5870 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5874 QVector<SUIT_ViewWindow*> views = vman->getViews();
5875 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5877 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5879 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5880 vtkActorCollection* allActors = aCopy.GetActors();
5881 allActors->InitTraversal();
5882 while (vtkActor* actor = allActors->GetNextActor())
5884 if (actor->GetVisibility()) // store only visible actors
5886 SMESH_Actor* aSmeshActor = 0;
5887 if (actor->IsA("SMESH_Actor"))
5888 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5889 if (aSmeshActor && aSmeshActor->hasIO())
5891 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5894 // entry is "encoded" = it does NOT contain component address,
5895 // since it is a subject to change on next component loading
5896 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5898 std::string param, vtkParam = vType.toLatin1().data();
5899 vtkParam += gSeparator;
5900 vtkParam += QString::number(vtkViewers).toLatin1().data();
5901 vtkParam += gSeparator;
5904 param = vtkParam + "Visibility";
5905 ip->setParameter(entry, param, "On");
5908 param = vtkParam + "Representation";
5909 ip->setParameter(entry, param, QString::number
5910 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5913 param = vtkParam + "IsShrunk";
5914 ip->setParameter(entry, param, QString::number
5915 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5917 // Displayed entities
5918 unsigned int aMode = aSmeshActor->GetEntityMode();
5919 bool isE = aMode & SMESH_Actor::eEdges;
5920 bool isF = aMode & SMESH_Actor::eFaces;
5921 bool isV = aMode & SMESH_Actor::eVolumes;
5922 bool is0d = aMode & SMESH_Actor::e0DElements;
5923 bool isB = aMode & SMESH_Actor::eBallElem;
5925 QString modeStr ("e");
5926 modeStr += gDigitsSep; modeStr += QString::number(isE);
5927 modeStr += gDigitsSep; modeStr += "f";
5928 modeStr += gDigitsSep; modeStr += QString::number(isF);
5929 modeStr += gDigitsSep; modeStr += "v";
5930 modeStr += gDigitsSep; modeStr += QString::number(isV);
5931 modeStr += gDigitsSep; modeStr += "0d";
5932 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5933 modeStr += gDigitsSep; modeStr += "b";
5934 modeStr += gDigitsSep; modeStr += QString::number(isB);
5936 param = vtkParam + "Entities";
5937 ip->setParameter(entry, param, modeStr.toLatin1().data());
5943 aSmeshActor->GetSufaceColor(r, g, b, delta);
5944 QStringList colorStr;
5945 colorStr << "surface";
5946 colorStr << QString::number(r);
5947 colorStr << QString::number(g);
5948 colorStr << QString::number(b);
5950 colorStr << "backsurface";
5951 colorStr << QString::number(delta);
5953 aSmeshActor->GetVolumeColor(r, g, b, delta);
5954 colorStr << "volume";
5955 colorStr << QString::number(r);
5956 colorStr << QString::number(g);
5957 colorStr << QString::number(b);
5958 colorStr << QString::number(delta);
5960 aSmeshActor->GetEdgeColor(r, g, b);
5962 colorStr << QString::number(r);
5963 colorStr << QString::number(g);
5964 colorStr << QString::number(b);
5966 aSmeshActor->GetNodeColor(r, g, b);
5968 colorStr << QString::number(r);
5969 colorStr << QString::number(g);
5970 colorStr << QString::number(b);
5972 aSmeshActor->GetOutlineColor(r, g, b);
5973 colorStr << "outline";
5974 colorStr << QString::number(r);
5975 colorStr << QString::number(g);
5976 colorStr << QString::number(b);
5978 aSmeshActor->Get0DColor(r, g, b);
5979 colorStr << "elem0d";
5980 colorStr << QString::number(r);
5981 colorStr << QString::number(g);
5982 colorStr << QString::number(b);
5984 aSmeshActor->GetBallColor(r, g, b);
5986 colorStr << QString::number(r);
5987 colorStr << QString::number(g);
5988 colorStr << QString::number(b);
5990 aSmeshActor->GetFacesOrientationColor(r, g, b);
5991 colorStr << "orientation";
5992 colorStr << QString::number(r);
5993 colorStr << QString::number(g);
5994 colorStr << QString::number(b);
5996 param = vtkParam + "Colors";
5997 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6000 QStringList sizeStr;
6002 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6003 sizeStr << "outline";
6004 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6005 sizeStr << "elem0d";
6006 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6008 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6009 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6010 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6011 sizeStr << "shrink";
6012 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6013 sizeStr << "orientation";
6014 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6015 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6017 param = vtkParam + "Sizes";
6018 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6023 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6024 if( aMarkerType == VTK::MT_USER ) {
6025 markerStr += "custom";
6026 markerStr += gDigitsSep;
6027 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6031 markerStr += gDigitsSep;
6032 markerStr += QString::number( (int)aMarkerType );
6033 markerStr += gDigitsSep;
6034 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6037 param = vtkParam + "PointMarker";
6038 ip->setParameter(entry, param, markerStr.toLatin1().data());
6041 param = vtkParam + "Opacity";
6042 ip->setParameter(entry, param,
6043 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6046 param = vtkParam + "ClippingPlane";
6048 if( !aClippingPlaneInfoList.empty() ) {
6049 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6050 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6052 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6053 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6054 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6055 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6056 if( aSmeshActor == *anIter2 ) {
6057 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6058 QString::number( anId ).toLatin1().constData() );
6065 ip->setParameter( entry, param, "Off" );
6066 } // if (io->hasEntry())
6067 } // SMESH_Actor && hasIO
6069 } // while.. actors traversal
6073 } // if (SVTK view model)
6074 } // for (viewManagers)
6077 // data structures for clipping planes processing
6081 bool isOpenGLClipping;
6082 vtkIdType RelativeOrientation;
6085 int AbsoluteOrientation;
6086 double X, Y, Z, Dx, Dy, Dz;
6088 typedef std::list<TPlaneData> TPlaneDataList;
6089 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6091 typedef std::list<vtkActor*> TActorList;
6094 TActorList ActorList;
6095 SUIT_ViewManager* ViewManager;
6097 typedef std::list<TPlaneInfo> TPlaneInfoList;
6098 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6101 * \brief Restore visual parameters
6103 * This method is called after the study document is opened.
6104 * Restore visual parameters from AttributeParameter attribue(s)
6106 void SMESHGUI::restoreVisualParameters (int savePoint)
6109 Kernel_Utils::Localizer loc;
6111 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6112 if (!appStudy || !appStudy->studyDS())
6114 _PTR(Study) studyDS = appStudy->studyDS();
6116 // componentName is used for encoding of entries when storing them in IParameters
6117 std::string componentName = myComponentSMESH->ComponentDataType();
6118 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
6119 //if (!aSComponent) return;
6122 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6123 componentName.c_str(),
6125 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6127 // restore map of custom markers and map of clipping planes
6128 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
6129 TPlaneDataMap aPlaneDataMap;
6131 std::vector<std::string> properties = ip->getProperties();
6132 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6134 std::string property = *propIt;
6135 QString aPropertyName( property.c_str() );
6136 QString aPropertyValue( ip->getProperty( property ).c_str() );
6138 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6139 if( aPropertyNameList.isEmpty() )
6142 QString aPropertyType = aPropertyNameList[0];
6143 if( aPropertyType == "texture" )
6145 if( aPropertyNameList.size() != 2 )
6149 int anId = aPropertyNameList[1].toInt( &ok );
6150 if( !ok || anId < 1 )
6153 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6154 if( aPropertyValueList.size() != 2 )
6157 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6158 QString aMarkerTextureString = aPropertyValueList[1];
6159 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6160 if( aMarkerTextureStringList.size() != 3 )
6164 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6169 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6173 VTK::MarkerTexture aMarkerTexture;
6174 aMarkerTexture.push_back( aWidth );
6175 aMarkerTexture.push_back( aHeight );
6177 QString aMarkerTextureData = aMarkerTextureStringList[2];
6178 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6180 QChar aChar = aMarkerTextureData.at( i );
6181 if( aChar.isDigit() )
6182 aMarkerTexture.push_back( aChar.digitValue() );
6185 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6187 else if( aPropertyType == "ClippingPlane" )
6189 if( aPropertyNameList.size() != 3 )
6193 int aViewId = aPropertyNameList[1].toInt( &ok );
6194 if( !ok || aViewId < 0 )
6198 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6199 if( !ok || aClippingPlaneId < 0 )
6202 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6203 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6206 TPlaneData aPlaneData;
6207 aPlaneData.AbsoluteOrientation = false;
6208 aPlaneData.RelativeOrientation = 0;
6209 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6210 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6211 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6213 aPlaneData.Id = aClippingPlaneId;
6216 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6221 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6225 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6228 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6233 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6238 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6243 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6248 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6253 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6258 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6262 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6264 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6269 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6274 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6279 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6284 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6285 aPlaneDataList.push_back( aPlaneData );
6289 TPlaneInfoMap aPlaneInfoMap;
6291 std::vector<std::string> entries = ip->getEntries();
6293 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6295 // entry is a normal entry - it should be "decoded" (setting base address of component)
6296 QString entry (ip->decodeEntry(*entIt).c_str());
6298 // Check that the entry corresponds to a real object in the Study
6299 // as the object may be deleted or modified after the visual state is saved.
6300 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6301 if (!so) continue; //Skip the not existent entry
6303 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6304 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6306 std::vector<std::string>::iterator namesIt = paramNames.begin();
6307 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6309 // actors are stored in a map after displaying of them for
6310 // quicker access in the future: map < viewID to actor >
6311 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6313 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6315 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6316 // '_' is used as separator and should not be used in viewer type or parameter names.
6317 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6318 if (lst.size() != 3)
6321 QString viewerTypStr = lst[0];
6322 QString viewIndexStr = lst[1];
6323 QString paramNameStr = lst[2];
6326 int viewIndex = viewIndexStr.toUInt(&ok);
6327 if (!ok) // bad conversion of view index to integer
6331 if (viewerTypStr == SVTK_Viewer::Type())
6333 SMESH_Actor* aSmeshActor = 0;
6334 if (vtkActors.IsBound(viewIndex))
6335 aSmeshActor = vtkActors.Find(viewIndex);
6337 QList<SUIT_ViewManager*> lst;
6338 getApp()->viewManagers(viewerTypStr, lst);
6340 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6341 SUIT_ViewManager* vman = NULL;
6342 if (viewIndex >= 0 && viewIndex < lst.count())
6343 vman = lst.at(viewIndex);
6345 if (paramNameStr == "Visibility")
6347 if (!aSmeshActor && displayer() && vman)
6349 SUIT_ViewModel* vmodel = vman->getViewModel();
6350 // SVTK view model can be casted to SALOME_View
6351 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6353 // store displayed actor in a temporary map for quicker
6354 // access later when restoring other parameters
6355 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6356 vtkRenderer* Renderer = vtkView->getRenderer();
6357 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6358 vtkActorCollection* theActors = aCopy.GetActors();
6359 theActors->InitTraversal();
6360 bool isFound = false;
6361 vtkActor *ac = theActors->GetNextActor();
6362 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6363 if (ac->IsA("SMESH_Actor")) {
6364 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6365 if (aGeomAc->hasIO()) {
6366 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6367 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6369 vtkActors.Bind(viewIndex, aGeomAc);
6375 } // if (paramNameStr == "Visibility")
6378 // the rest properties "work" with SMESH_Actor
6381 QString val ((*valuesIt).c_str());
6384 if (paramNameStr == "Representation") {
6385 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6388 else if (paramNameStr == "IsShrunk") {
6390 if (!aSmeshActor->IsShrunk())
6391 aSmeshActor->SetShrink();
6394 if (aSmeshActor->IsShrunk())
6395 aSmeshActor->UnShrink();
6398 // Displayed entities
6399 else if (paramNameStr == "Entities") {
6400 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6401 int aEntityMode = SMESH_Actor::eAllEntity;
6402 for ( int i = 0; i < mode.count(); i+=2 ) {
6403 if ( i < mode.count()-1 ) {
6404 QString type = mode[i];
6405 bool val = mode[i+1].toInt();
6406 if ( type == "e" && !val )
6407 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6408 else if ( type == "f" && !val )
6409 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6410 else if ( type == "v" && !val )
6411 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6412 else if ( type == "0d" && !val )
6413 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6414 else if ( type == "b" && !val )
6415 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6418 aSmeshActor->SetEntityMode( aEntityMode );
6421 else if (paramNameStr == "Colors") {
6422 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6429 QColor outlineColor;
6430 QColor orientationColor;
6436 // below lines are required to get default values for delta coefficients
6437 // of backface color for faces and color of reversed volumes
6438 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6439 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6440 for ( int i = 0; i < colors.count(); i++ ) {
6441 QString type = colors[i];
6442 if ( type == "surface" ) {
6443 // face color is set by 3 values r:g:b, where
6444 // - r,g,b - is rgb color components
6445 if ( i+1 >= colors.count() ) break; // format error
6446 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6447 if ( i+2 >= colors.count() ) break; // format error
6448 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6449 if ( i+3 >= colors.count() ) break; // format error
6450 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6451 faceColor.setRgbF( r, g, b );
6454 else if ( type == "backsurface" ) {
6455 // backface color can be defined in several ways
6456 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6457 // - in latest versions, it is set as delta coefficient
6458 bool rgbOk = false, deltaOk;
6459 if ( i+1 >= colors.count() ) break; // format error
6460 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6461 int delta = colors[i+1].toInt( &deltaOk );
6463 if ( i+1 < colors.count() ) // index is shifted to 1
6464 g = colors[i+1].toDouble( &rgbOk );
6465 if ( rgbOk ) i++; // shift index
6466 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6467 b = colors[i+1].toDouble( &rgbOk );
6469 // - as currently there's no way to set directly backsurface color as it was before,
6470 // we ignore old dump where r,g,b triple was set
6471 // - also we check that delta parameter is set properly
6472 if ( !rgbOk && deltaOk )
6475 else if ( type == "volume" ) {
6476 // volume color is set by 4 values r:g:b:delta, where
6477 // - r,g,b - is a normal volume rgb color components
6478 // - delta - is a reversed volume color delta coefficient
6479 if ( i+1 >= colors.count() ) break; // format error
6480 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6481 if ( i+2 >= colors.count() ) break; // format error
6482 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6483 if ( i+3 >= colors.count() ) break; // format error
6484 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6485 if ( i+4 >= colors.count() ) break; // format error
6486 int delta = colors[i+4].toInt( &bOk );
6487 if ( !bOk ) break; // format error
6488 volumeColor.setRgbF( r, g, b );
6492 else if ( type == "edge" ) {
6493 // edge color is set by 3 values r:g:b, where
6494 // - r,g,b - is rgb color components
6495 if ( i+1 >= colors.count() ) break; // format error
6496 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6497 if ( i+2 >= colors.count() ) break; // format error
6498 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6499 if ( i+3 >= colors.count() ) break; // format error
6500 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6501 edgeColor.setRgbF( r, g, b );
6504 else if ( type == "node" ) {
6505 // node color is set by 3 values r:g:b, where
6506 // - r,g,b - is rgb color components
6507 if ( i+1 >= colors.count() ) break; // format error
6508 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6509 if ( i+2 >= colors.count() ) break; // format error
6510 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6511 if ( i+3 >= colors.count() ) break; // format error
6512 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6513 nodeColor.setRgbF( r, g, b );
6516 else if ( type == "elem0d" ) {
6517 // 0d element color is set by 3 values r:g:b, where
6518 // - r,g,b - is rgb color components
6519 if ( i+1 >= colors.count() ) break; // format error
6520 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6521 if ( i+2 >= colors.count() ) break; // format error
6522 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6523 if ( i+3 >= colors.count() ) break; // format error
6524 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6525 elem0dColor.setRgbF( r, g, b );
6528 else if ( type == "ball" ) {
6529 // ball color is set by 3 values r:g:b, where
6530 // - r,g,b - is rgb color components
6531 if ( i+1 >= colors.count() ) break; // format error
6532 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6533 if ( i+2 >= colors.count() ) break; // format error
6534 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6535 if ( i+3 >= colors.count() ) break; // format error
6536 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6537 ballColor.setRgbF( r, g, b );
6540 else if ( type == "outline" ) {
6541 // outline color is set by 3 values r:g:b, where
6542 // - r,g,b - is rgb color components
6543 if ( i+1 >= colors.count() ) break; // format error
6544 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6545 if ( i+2 >= colors.count() ) break; // format error
6546 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6547 if ( i+3 >= colors.count() ) break; // format error
6548 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6549 outlineColor.setRgbF( r, g, b );
6552 else if ( type == "orientation" ) {
6553 // orientation color is set by 3 values r:g:b, where
6554 // - r,g,b - is rgb color components
6555 if ( i+1 >= colors.count() ) break; // format error
6556 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6557 if ( i+2 >= colors.count() ) break; // format error
6558 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6559 if ( i+3 >= colors.count() ) break; // format error
6560 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6561 orientationColor.setRgbF( r, g, b );
6566 if ( nodeColor.isValid() )
6567 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6569 if ( edgeColor.isValid() )
6570 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6572 if ( faceColor.isValid() )
6573 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6575 if ( volumeColor.isValid() )
6576 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6577 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6578 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6580 if ( elem0dColor.isValid() )
6581 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6583 if ( ballColor.isValid() )
6584 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6586 if ( outlineColor.isValid() )
6587 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6588 // orientation color
6589 if ( orientationColor.isValid() )
6590 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6593 else if (paramNameStr == "Sizes") {
6594 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6597 int outlineWidth = -1;
6598 int elem0dSize = -1;
6599 //int ballSize = -1;
6600 double ballDiameter = -1.0;
6601 double ballScale = -1.0;
6602 double shrinkSize = -1;
6603 double orientationSize = -1;
6604 bool orientation3d = false;
6605 for ( int i = 0; i < sizes.count(); i++ ) {
6606 QString type = sizes[i];
6607 if ( type == "line" ) {
6608 // line (wireframe) width is given as single integer value
6609 if ( i+1 >= sizes.count() ) break; // format error
6610 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6614 if ( type == "outline" ) {
6615 // outline width is given as single integer value
6616 if ( i+1 >= sizes.count() ) break; // format error
6617 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6621 else if ( type == "elem0d" ) {
6622 // 0d element size is given as single integer value
6623 if ( i+1 >= sizes.count() ) break; // format error
6624 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6628 else if ( type == "ball" ) {
6629 // balls are specified by two values: size:scale, where
6630 // - size - is a integer value specifying size
6631 // - scale - is a double value specifying scale factor
6632 if ( i+1 >= sizes.count() ) break; // format error
6633 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6634 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6635 if ( i+2 >= sizes.count() ) break; // format error
6636 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6642 else if ( type == "shrink" ) {
6643 // shrink factor is given as single floating point value
6644 if ( i+1 >= sizes.count() ) break; // format error
6645 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6649 else if ( type == "orientation" ) {
6650 // orientation vectors are specified by two values size:3d, where
6651 // - size - is a floating point value specifying scale factor
6652 // - 3d - is a boolean
6653 if ( i+1 >= sizes.count() ) break; // format error
6654 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6655 if ( i+2 >= sizes.count() ) break; // format error
6656 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6657 orientationSize = v1;
6658 orientation3d = (bool)v2;
6662 // line (wireframe) width
6663 if ( lineWidth > 0 )
6664 aSmeshActor->SetLineWidth( lineWidth );
6666 if ( outlineWidth > 0 )
6667 aSmeshActor->SetOutlineWidth( outlineWidth );
6668 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6669 aSmeshActor->SetOutlineWidth( lineWidth );
6671 if ( elem0dSize > 0 )
6672 aSmeshActor->Set0DSize( elem0dSize );
6674 /*if ( ballSize > 0 )
6675 aSmeshActor->SetBallSize( ballSize );*/
6677 if ( ballDiameter > 0 )
6678 aSmeshActor->SetBallSize( ballDiameter );
6680 if ( ballScale > 0.0 )
6681 aSmeshActor->SetBallScale( ballScale );
6683 if ( shrinkSize > 0 )
6684 aSmeshActor->SetShrinkFactor( shrinkSize );
6685 // orientation vectors
6686 if ( orientationSize > 0 ) {
6687 aSmeshActor->SetFacesOrientationScale( orientationSize );
6688 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6692 else if (paramNameStr == "PointMarker") {
6693 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6694 if( data.count() >= 2 ) {
6696 int aParam1 = data[1].toInt( &ok );
6698 if( data[0] == "std" && data.count() == 3 ) {
6699 int aParam2 = data[2].toInt( &ok );
6700 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6702 else if( data[0] == "custom" ) {
6703 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6704 if( markerIt != aMarkerMap.end() ) {
6705 VTK::MarkerData aMarkerData = markerIt->second;
6706 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6713 else if (paramNameStr == "Opacity") {
6714 aSmeshActor->SetOpacity(val.toFloat());
6717 else if (paramNameStr.startsWith("ClippingPlane")) {
6718 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6719 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6720 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6721 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6722 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6723 // new format - val looks like "Off" or "0" (plane id)
6724 // (note: in new format "Off" value is used only for consistency,
6725 // so it is processed together with values in old format)
6726 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6727 if( anIsOldFormat ) {
6728 if (paramNameStr == "ClippingPlane1" || val == "Off")
6729 aSmeshActor->RemoveAllClippingPlanes();
6731 QList<SUIT_ViewManager*> lst;
6732 getApp()->viewManagers(viewerTypStr, lst);
6733 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6734 if (viewIndex >= 0 && viewIndex < lst.count()) {
6735 SUIT_ViewManager* vman = lst.at(viewIndex);
6736 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6738 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6740 SMESH::TActorList anActorList;
6741 anActorList.push_back( aSmeshActor );
6742 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6743 aPlane->myViewWindow = vtkView;
6744 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6745 aPlane->PlaneMode = aMode;
6746 bool isOpenGLClipping = ( bool )vals[1].toInt();
6747 aPlane->IsOpenGLClipping = isOpenGLClipping;
6748 if ( aMode == SMESH::Absolute ) {
6749 aPlane->myAbsoluteOrientation = vals[2].toInt();
6750 aPlane->X = vals[3].toFloat();
6751 aPlane->Y = vals[4].toFloat();
6752 aPlane->Z = vals[5].toFloat();
6753 aPlane->Dx = vals[6].toFloat();
6754 aPlane->Dy = vals[7].toFloat();
6755 aPlane->Dz = vals[8].toFloat();
6757 else if ( aMode == SMESH::Relative ) {
6758 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6759 aPlane->myDistance = vals[3].toFloat();
6760 aPlane->myAngle[0] = vals[4].toFloat();
6761 aPlane->myAngle[1] = vals[5].toFloat();
6765 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6766 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6767 aClippingPlaneInfo.Plane = aPlane;
6768 aClippingPlaneInfo.ActorList = anActorList;
6769 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6777 int aPlaneId = val.toInt( &ok );
6778 if( ok && aPlaneId >= 0 ) {
6779 bool anIsDefinedPlane = false;
6780 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6781 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6782 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6783 TPlaneInfo& aPlaneInfo = *anIter;
6784 if( aPlaneInfo.PlaneId == aPlaneId ) {
6785 aPlaneInfo.ActorList.push_back( aSmeshActor );
6786 anIsDefinedPlane = true;
6790 if( !anIsDefinedPlane ) {
6791 TPlaneInfo aPlaneInfo;
6792 aPlaneInfo.PlaneId = aPlaneId;
6793 aPlaneInfo.ActorList.push_back( aSmeshActor );
6794 aPlaneInfo.ViewManager = vman;
6796 // to make the list sorted by plane id
6797 anIter = aPlaneInfoList.begin();
6798 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6799 const TPlaneInfo& aPlaneInfoRef = *anIter;
6800 if( aPlaneInfoRef.PlaneId > aPlaneId )
6803 aPlaneInfoList.insert( anIter, aPlaneInfo );
6808 } // if (aSmeshActor)
6809 } // other parameters than Visibility
6811 } // for names/parameters iterator
6812 } // for entries iterator
6814 // take into account planes with empty list of actors referred to them
6815 QList<SUIT_ViewManager*> aVMList;
6816 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6818 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6819 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6820 int aViewId = aPlaneDataIter->first;
6821 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6822 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6824 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6826 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6827 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6828 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6829 const TPlaneData& aPlaneData = *anIter2;
6830 int aPlaneId = aPlaneData.Id;
6832 bool anIsFound = false;
6833 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6834 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6835 const TPlaneInfo& aPlaneInfo = *anIter3;
6836 if( aPlaneInfo.PlaneId == aPlaneId ) {
6843 TPlaneInfo aPlaneInfo; // ActorList field is empty
6844 aPlaneInfo.PlaneId = aPlaneId;
6845 aPlaneInfo.ViewManager = aViewManager;
6847 // to make the list sorted by plane id
6848 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6849 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6850 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6851 if( aPlaneInfoRef.PlaneId > aPlaneId )
6854 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6860 // add clipping planes to actors according to the restored parameters
6861 // and update the clipping plane map
6862 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6863 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6864 int aViewId = anIter1->first;
6865 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6867 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6868 if( anIter2 == aPlaneDataMap.end() )
6870 const TPlaneDataList& aPlaneDataList = anIter2->second;
6872 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6873 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6874 const TPlaneInfo& aPlaneInfo = *anIter3;
6875 int aPlaneId = aPlaneInfo.PlaneId;
6876 const TActorList& anActorList = aPlaneInfo.ActorList;
6877 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6881 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6885 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6887 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6888 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6889 const TPlaneData& aPlaneData = *anIter4;
6890 if( aPlaneData.Id == aPlaneId ) {
6891 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6892 aPlane->myViewWindow = aViewWindow;
6893 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6894 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6895 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6896 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6897 aPlane->X = aPlaneData.X;
6898 aPlane->Y = aPlaneData.Y;
6899 aPlane->Z = aPlaneData.Z;
6900 aPlane->Dx = aPlaneData.Dx;
6901 aPlane->Dy = aPlaneData.Dy;
6902 aPlane->Dz = aPlaneData.Dz;
6904 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6905 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6906 aPlane->myDistance = aPlaneData.Distance;
6907 aPlane->myAngle[0] = aPlaneData.Angle[0];
6908 aPlane->myAngle[1] = aPlaneData.Angle[1];
6911 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6912 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6913 aClippingPlaneInfo.Plane = aPlane;
6914 aClippingPlaneInfo.ActorList = anActorList;
6915 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6926 // update all VTK views
6927 QList<SUIT_ViewManager*> lst;
6928 getApp()->viewManagers(lst);
6929 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6930 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6931 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6932 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6933 // set OpenGL clipping planes
6934 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6935 vtkActorCollection* anAllActors = aCopy.GetActors();
6936 anAllActors->InitTraversal();
6937 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6938 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6939 anActor->SetOpenGLClippingPlane();
6941 vtkView->getRenderer()->ResetCameraClippingRange();
6948 \brief Adds preferences for dfont of VTK viewer
6950 \param pIf group identifier
6951 \param param parameter
6952 \return identifier of preferences
6954 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6956 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6958 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6961 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6962 fam.append( tr( "SMESH_FONT_COURIER" ) );
6963 fam.append( tr( "SMESH_FONT_TIMES" ) );
6965 setPreferenceProperty( tfont, "fonts", fam );
6967 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6968 if ( needSize ) f = f | QtxFontEdit::Size;
6969 setPreferenceProperty( tfont, "features", f );
6975 \brief Actions after hypothesis edition
6976 Updates object browser after hypothesis edition
6978 void SMESHGUI::onHypothesisEdit( int result )
6981 SMESHGUI::Modified();
6982 updateObjBrowser( true );
6986 \brief Actions after choosing menu of control modes
6987 Updates control mode actions according to current selection
6989 void SMESHGUI::onUpdateControlActions()
6991 SALOME_ListIO selected;
6992 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
6993 aSel->selectedObjects( selected );
6995 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
6996 if ( selected.Extent() ) {
6997 if ( selected.First()->hasEntry() ) {
6998 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
6999 aControl = anActor->GetControlMode();
7000 SALOME_ListIteratorOfListIO it(selected);
7001 for ( it.Next(); it.More(); it.Next() ) {
7002 Handle(SALOME_InteractiveObject) anIO = it.Value();
7003 if ( anIO->hasEntry() ) {
7004 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7005 if ( aControl != anActor->GetControlMode() ) {
7006 aControl = SMESH_Actor::eNone;
7016 int anAction = ActionToControl( aControl, true );
7018 action( anAction )->setChecked( true );
7020 QMenu* send = (QMenu*)sender();
7021 QList<QAction*> actions = send->actions();
7022 for ( int i = 0; i < actions.size(); i++ )
7023 actions[i]->setChecked( false );
7029 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7030 \param pview view being closed
7032 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7033 #ifndef DISABLE_PLOT2DVIEWER
7034 //Crear all Plot2d Viewers if need.
7035 SMESH::ClearPlot2Viewers(pview);
7037 EmitSignalCloseView();
7040 void SMESHGUI::message( const QString& msg )
7043 QStringList data = msg.split("/");
7044 if ( data.count() > 0 ) {
7045 if ( data.first() == "mesh_loading" ) {
7047 QString entry = data.count() > 1 ? data[1] : QString();
7048 if ( entry.isEmpty() )
7051 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7053 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
7056 name = SMESH::fromUtf8(obj->GetName());
7057 if ( name.isEmpty() )
7060 if ( data.last() == "stop" )
7061 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7063 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7064 QApplication::processEvents();
7070 \brief Connects or disconnects signals about activating and cloning view on the module slots
7071 \param pview view which is connected/disconnected
7073 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7077 SUIT_ViewManager* viewMgr = pview->getViewManager();
7079 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7080 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7082 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7083 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7088 \brief Return \c true if object can be renamed
7090 bool SMESHGUI::renameAllowed( const QString& entry) const {
7091 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7095 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7099 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7104 if(appStudy->isComponent(entry) || obj->isReference())
7107 // check type to prevent renaming of inappropriate objects
7108 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
7109 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7110 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7111 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7112 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7113 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7120 Rename object by entry.
7121 \param entry entry of the object
7122 \param name new name of the object
7123 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7125 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7127 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7131 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7136 _PTR(Study) aStudy = appStudy->studyDS();
7141 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7143 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7148 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7149 _PTR(GenericAttribute) anAttr;
7150 _PTR(AttributeName) aName;
7152 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7154 // check type to prevent renaming of inappropriate objects
7155 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
7156 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7157 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7158 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7159 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7160 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7161 if ( !name.isEmpty() ) {
7162 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
7164 // update name of group object and its actor
7165 Handle(SALOME_InteractiveObject) IObject =
7166 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7168 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7169 if( !aGroupObject->_is_nil() ) {
7170 aGroupObject->SetName( qPrintable(name) );
7171 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7172 anActor->setName( qPrintable(name) );
7182 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7184 static QList<QColor> colors;
7186 if ( colors.isEmpty() ) {
7188 for (int s = 0; s < 2 ; s++)
7190 for (int v = 100; v >= 40; v = v - 20)
7192 for (int h = 0; h < 359 ; h = h + 60)
7194 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7199 static int currentColor = randomize( colors.size() );
7201 SALOMEDS::Color color;
7202 color.R = (double)colors[currentColor].red() / 255.0;
7203 color.G = (double)colors[currentColor].green() / 255.0;
7204 color.B = (double)colors[currentColor].blue() / 255.0;
7206 currentColor = (currentColor+1) % colors.count();