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 );
1703 return theReversed ? ActionControl.Find2( theID ) : ActionControl.Find1( theID );
1706 void Control( int theCommandID )
1708 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1709 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1711 SALOME_ListIO selected;
1712 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1713 aSel->selectedObjects( selected );
1715 if ( !selected.IsEmpty() ) {
1716 SALOME_ListIteratorOfListIO It(selected);
1717 for ( ; It.More(); It.Next())
1719 Handle(SALOME_InteractiveObject) anIO = It.Value();
1720 if ( !anIO.IsNull() ) {
1721 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1723 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1724 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1725 if ( !anIDSrc->_is_nil() ) {
1726 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1727 if (( !anActor && selected.Extent() == 1 ) &&
1728 ( anActor = SMESH::CreateActor( aStudy, anIO->getEntry() )))
1730 anActor->SetControlMode( aControl );
1731 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1732 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1736 if ( anActor->GetControlMode() != aControl )
1737 anActor->SetControlMode( aControl );
1738 QString functorName = functorToString( anActor->GetFunctor() );
1739 int anEntitiesCount = anActor->GetNumberControlEntities();
1740 if (anEntitiesCount >= 0)
1741 functorName = functorName + ": " + QString::number(anEntitiesCount);
1742 anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
1743 SMESH::RepaintCurrentView();
1744 #ifndef DISABLE_PLOT2DVIEWER
1745 if ( anActor->GetPlot2Histogram() ) {
1746 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1747 QString aHistogramName("%1 : %2");
1748 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1749 aHistogram->setName( aHistogramName );
1750 aHistogram->setHorTitle( functorName );
1751 SMESH::ProcessIn2DViewers( anActor );
1763 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1764 SMESH::MeshObjectType theType,
1765 const QString theInTypeName,
1766 QString & theOutTypeName)
1768 SMESH_TypeFilter aTypeFilter( theType );
1770 if ( !theIO.IsNull() )
1772 entry = theIO->getEntry();
1773 LightApp_DataOwner owner( entry );
1774 if ( aTypeFilter.isOk( &owner )) {
1775 theOutTypeName = theInTypeName;
1783 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1785 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1786 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1788 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1789 CORBA::String_var anID = aSComp->GetID().c_str();
1790 if ( !strcmp(anID.in(),theIO->getEntry()) )
1796 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1797 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1798 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1799 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1800 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1808 // QString CheckHomogeneousSelection()
1810 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1811 // SALOME_ListIO selected;
1813 // aSel->selectedObjects( selected );
1815 // QString RefType = CheckTypeObject(selected.First());
1816 // SALOME_ListIteratorOfListIO It(selected);
1817 // for ( ; It.More(); It.Next())
1819 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1820 // QString Type = CheckTypeObject(IObject);
1821 // if ( Type.compare(RefType) != 0 )
1822 // return "Heterogeneous Selection";
1828 uint randomize( uint size )
1830 static bool initialized = false;
1831 if ( !initialized ) {
1832 qsrand( QDateTime::currentDateTime().toTime_t() );
1836 v = uint( (double)( v ) / RAND_MAX * size );
1837 v = qMax( uint(0), qMin ( v, size-1 ) );
1843 void SMESHGUI::OnEditDelete()
1845 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1846 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1847 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1849 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1850 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1851 _PTR(GenericAttribute) anAttr;
1852 _PTR(AttributeIOR) anIOR;
1854 int objectCount = 0;
1856 QString aParentComponent = QString::null;
1857 Handle(SALOME_InteractiveObject) anIO;
1858 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1860 anIO = anIt.Value();
1861 QString cur = anIO->getComponentDataType();
1862 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1864 // check if object is reference
1865 _PTR(SObject) aRefSObj;
1866 aNameList.append("\n - ");
1867 if ( aSO->ReferencedObject( aRefSObj ) ) {
1868 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1869 aNameList.append( aRefName );
1870 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1873 aNameList.append(anIO->getName());
1877 if( aParentComponent.isNull() )
1878 aParentComponent = cur;
1879 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1880 aParentComponent = "";
1883 if ( objectCount == 0 )
1884 return; // No Valid Objects Selected
1886 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1887 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1888 QObject::tr("ERR_ERROR"),
1889 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1892 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1893 if (SUIT_MessageBox::warning
1894 (SMESHGUI::desktop(),
1895 QObject::tr("SMESH_WRN_WARNING"),
1896 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1897 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1898 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1901 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1903 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1904 // then treat them all starting from the deepest objects (at list back)
1905 std::list< _PTR(SObject) > listSO;
1906 SALOME_ListIteratorOfListIO It(selected);
1907 for( ; It.More(); It.Next()) // loop on selected IO's
1909 Handle(SALOME_InteractiveObject) IObject = It.Value();
1910 if(IObject->hasEntry()) {
1911 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1913 // disable removal of "SMESH" component object
1914 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1916 if ( engineIOR() == anIOR->Value().c_str() )
1919 //Check the referenced object
1920 _PTR(SObject) aRefSObject;
1921 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1922 aSO = aRefSObject; // Delete main Object instead of reference
1924 listSO.push_back( aSO );
1925 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1926 for ( ; itSO != listSO.end(); ++itSO ) {
1927 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1928 for (it->InitEx(false); it->More(); it->Next())
1929 listSO.push_back( it->Value() );
1933 // Check if none of objects to delete is referred from outside
1934 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1935 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1937 _PTR(SObject) SO = *ritSO;
1938 if ( !SO ) continue;
1939 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1940 for (size_t i = 0; i < aReferences.size(); i++) {
1941 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1942 std::string type = aComponent->ComponentDataType();
1943 if ( type != "SMESH" )
1945 SUIT_MessageBox::warning( anApp->desktop(),
1946 QObject::tr("WRN_WARNING"),
1947 QObject::tr("DEP_OBJECT") );
1948 return; // outside SMESH, there is an object depending on a SMESH object
1953 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1954 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1956 Handle(SALOME_InteractiveObject) IObject = It.Value();
1957 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1958 if ( !mesh->_is_nil() )
1962 // Treat SO's in the list starting from the back
1963 aStudyBuilder->NewCommand(); // There is a transaction
1964 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1966 _PTR(SObject) SO = *ritSO;
1967 if ( !SO ) continue;
1968 std::string anEntry = SO->GetID();
1970 /** Erase graphical object and remove all its data **/
1971 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1972 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1974 /** Remove an object from data structures **/
1975 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1976 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1977 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1978 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1979 aMesh->RemoveGroup( aGroup );
1981 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1982 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1983 aMesh->RemoveSubMesh( aSubMesh );
1985 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1987 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1990 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1991 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1992 QString objType = CheckTypeObject(IObject);
1993 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1994 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1995 aStudyBuilder->RemoveObjectWithChildren( SO );
1997 else {// default action: remove SObject from the study
1998 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1999 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2001 aStudyBuilder->RemoveObjectWithChildren( SO );
2005 } /* listSO back loop */
2007 aStudyBuilder->CommitCommand();
2009 /* Clear any previous selection */
2011 aSel->setSelectedObjects( l1 );
2013 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2017 SMESHGUI_EXPORT CAM_Module* createModule()
2019 return new SMESHGUI();
2022 SMESHGUI_EXPORT char* getModuleVersion() {
2023 return (char*)SMESH_VERSION_STR;
2027 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2029 //=============================================================================
2033 //=============================================================================
2034 SMESHGUI::SMESHGUI() :
2035 SalomeApp_Module( "SMESH" )
2037 if ( CORBA::is_nil( myComponentSMESH ) )
2039 CORBA::Boolean anIsEmbeddedMode;
2040 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2041 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2043 // 0019923: EDF 765 SMESH : default values of hypothesis
2044 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2045 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2046 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2047 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2048 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2050 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2051 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2052 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2054 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2055 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2059 myActiveDialogBox = 0;
2060 myFilterLibraryDlg = 0;
2064 myEventCallbackCommand = vtkCallbackCommand::New();
2065 myEventCallbackCommand->Delete();
2066 myEventCallbackCommand->SetClientData( this );
2067 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2070 /* load resources for all available meshers */
2071 SMESH::InitAvailableHypotheses();
2074 //=============================================================================
2078 //=============================================================================
2079 SMESHGUI::~SMESHGUI()
2083 //=============================================================================
2087 //=============================================================================
2088 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2090 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2092 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2097 //=============================================================================
2101 //=============================================================================
2102 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2104 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2108 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2109 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2110 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2111 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2112 return autoUpdate && !exceeded;
2115 //=============================================================================
2119 //=============================================================================
2120 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2121 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2123 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2127 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2128 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2129 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2131 SMESH::long_array_var info = theMesh->GetMeshInfo();
2132 long nbOdElems = info[SMDSEntity_0D];
2133 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2134 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2135 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2136 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2137 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2138 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2139 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2140 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2141 info[SMDSEntity_Polyhedra] +
2142 info[SMDSEntity_Hexagonal_Prism];
2143 long nbBalls = info[SMDSEntity_Ball];
2145 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2146 *nbElements = requestedSize;
2148 *entities = SMESH_Actor::eAllEntity;
2151 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2153 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2155 if ( incrementalLimit ) {
2158 if ( nbOdElems > 0 ) {
2159 if ( total + nbOdElems > updateLimit ) {
2160 *entities = *entities & ~SMESH_Actor::e0DElements;
2161 *hidden = *hidden | SMESH_Actor::e0DElements;
2168 if ( nbEdges > 0 ) {
2169 if ( total + nbEdges > updateLimit ) {
2170 *entities = *entities & ~SMESH_Actor::eEdges;
2171 *hidden = *hidden | SMESH_Actor::eEdges;
2178 if ( nbFaces > 0 ) {
2179 if ( total + nbFaces > updateLimit ) {
2180 *entities = *entities & ~SMESH_Actor::eFaces;
2181 *hidden = *hidden | SMESH_Actor::eFaces;
2188 if ( nbVolumes > 0 ) {
2189 if ( total + nbVolumes > updateLimit ) {
2190 *entities = *entities & ~SMESH_Actor::eVolumes;
2191 *hidden = *hidden | SMESH_Actor::eVolumes;
2198 if ( nbBalls > 0 ) {
2199 if ( total + nbBalls > updateLimit ) {
2200 *entities = *entities & ~SMESH_Actor::eBallElem;
2201 *hidden = *hidden | SMESH_Actor::eBallElem;
2209 return autoUpdate && !exceeded;
2212 //=============================================================================
2216 //=============================================================================
2217 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2219 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2222 //=============================================================================
2226 //=============================================================================
2227 SMESHGUI* SMESHGUI::GetSMESHGUI()
2229 SMESHGUI* smeshMod = 0;
2230 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2233 CAM_Module* module = app->module( "Mesh" );
2234 smeshMod = dynamic_cast<SMESHGUI*>( module );
2237 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2239 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2242 _PTR(Study) aStudy = study->studyDS();
2244 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2253 Standard_EXPORT SMESHGUI* GetComponentGUI()
2255 return SMESHGUI::GetSMESHGUI();
2259 //=============================================================================
2263 //=============================================================================
2264 void SMESHGUI::SetState(int aState)
2269 //=============================================================================
2273 //=============================================================================
2274 void SMESHGUI::ResetState()
2279 //=============================================================================
2283 //=============================================================================
2284 void SMESHGUI::EmitSignalDeactivateDialog()
2286 emit SignalDeactivateActiveDialog();
2289 //=============================================================================
2293 //=============================================================================
2294 void SMESHGUI::EmitSignalStudyFrameChanged()
2296 emit SignalStudyFrameChanged();
2299 //=============================================================================
2303 //=============================================================================
2304 void SMESHGUI::EmitSignalCloseAllDialogs()
2306 emit SignalCloseAllDialogs();
2309 //=============================================================================
2313 //=============================================================================
2314 void SMESHGUI::EmitSignalVisibilityChanged()
2316 emit SignalVisibilityChanged();
2319 //=============================================================================
2323 //=============================================================================
2324 void SMESHGUI::EmitSignalCloseView()
2326 emit SignalCloseView();
2329 //=============================================================================
2333 //=============================================================================
2334 void SMESHGUI::EmitSignalActivatedViewManager()
2336 emit SignalActivatedViewManager();
2339 //=============================================================================
2343 //=============================================================================
2344 QDialog *SMESHGUI::GetActiveDialogBox()
2346 return myActiveDialogBox;
2349 //=============================================================================
2353 //=============================================================================
2354 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2356 myActiveDialogBox = (QDialog *) aDlg;
2360 //=============================================================================
2364 //=============================================================================
2365 SUIT_Desktop* SMESHGUI::desktop()
2367 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2369 return app->desktop();
2374 //=============================================================================
2378 //=============================================================================
2379 SalomeApp_Study* SMESHGUI::activeStudy()
2381 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2383 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2388 //=============================================================================
2392 //=============================================================================
2393 void SMESHGUI::Modified( bool theIsUpdateActions )
2395 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2396 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2397 appStudy->Modified();
2398 if( theIsUpdateActions )
2399 app->updateActions();
2404 //=============================================================================
2408 //=============================================================================
2409 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2411 /* Here the position is on the bottom right corner - 10 */
2412 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2414 SUIT_Desktop *PP = desktop();
2415 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2416 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2420 //=============================================================================
2424 //=============================================================================
2425 static int isStudyLocked(_PTR(Study) theStudy){
2426 return theStudy->GetProperties()->IsLocked();
2429 static bool checkLock(_PTR(Study) theStudy) {
2430 if (isStudyLocked(theStudy)) {
2431 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2432 QObject::tr("WRN_WARNING"),
2433 QObject::tr("WRN_STUDY_LOCKED") );
2439 //=======================================================================
2440 //function : CheckActiveStudyLocked
2442 //=======================================================================
2444 bool SMESHGUI::isActiveStudyLocked()
2446 _PTR(Study) aStudy = activeStudy()->studyDS();
2447 return checkLock( aStudy );
2450 //=============================================================================
2454 //=============================================================================
2455 bool SMESHGUI::OnGUIEvent( int theCommandID )
2457 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2461 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2462 SUIT_ResourceMgr* mgr = resourceMgr();
2466 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2467 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2470 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2471 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2473 //QAction* act = action( theCommandID );
2475 switch (theCommandID) {
2476 case SMESHOp::OpDelete:
2477 if(checkLock(aStudy)) break;
2480 case SMESHOp::OpImportDAT:
2481 case SMESHOp::OpImportUNV:
2482 case SMESHOp::OpImportMED:
2483 case SMESHOp::OpImportSTL:
2484 case SMESHOp::OpImportCGNS:
2485 case SMESHOp::OpImportSAUV:
2486 case SMESHOp::OpImportGMF:
2487 case SMESHOp::OpPopupImportDAT:
2488 case SMESHOp::OpPopupImportUNV:
2489 case SMESHOp::OpPopupImportMED:
2490 case SMESHOp::OpPopupImportSTL:
2491 case SMESHOp::OpPopupImportCGNS:
2492 case SMESHOp::OpPopupImportSAUV:
2493 case SMESHOp::OpPopupImportGMF:
2495 if(checkLock(aStudy)) break;
2496 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2500 case SMESHOp::OpFileInformation:
2502 SALOME_ListIO selected;
2503 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2505 aSel->selectedObjects( selected );
2506 if( selected.Extent() )
2508 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2509 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2510 if ( !aMesh->_is_nil() )
2512 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2518 case SMESHOp::OpExportDAT:
2519 case SMESHOp::OpExportMED:
2520 case SMESHOp::OpExportUNV:
2521 case SMESHOp::OpExportSTL:
2522 case SMESHOp::OpExportCGNS:
2523 case SMESHOp::OpExportSAUV:
2524 case SMESHOp::OpExportGMF:
2525 case SMESHOp::OpPopupExportDAT:
2526 case SMESHOp::OpPopupExportMED:
2527 case SMESHOp::OpPopupExportUNV:
2528 case SMESHOp::OpPopupExportSTL:
2529 case SMESHOp::OpPopupExportCGNS:
2530 case SMESHOp::OpPopupExportSAUV:
2531 case SMESHOp::OpPopupExportGMF:
2533 ::ExportMeshToFile(theCommandID);
2537 case SMESHOp::OpReset: // SCALAR BAR
2539 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2540 SALOME_ListIO selected;
2542 aSel->selectedObjects( selected );
2544 SALOME_ListIteratorOfListIO it(selected);
2545 for( ; it.More(); it.Next()) {
2546 Handle(SALOME_InteractiveObject) anIO = it.Value();
2547 if( anIO->hasEntry() ) {
2548 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2549 anActor->SetControlMode( SMESH_Actor::eNone );
2550 #ifndef DISABLE_PLOT2DVIEWER
2551 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2556 SMESH::UpdateView();
2559 case SMESHOp::OpScalarBarProperties:
2561 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2564 case SMESHOp::OpShowScalarBar:
2566 // show/hide scalar bar
2567 ::ShowElement(theCommandID);
2570 case SMESHOp::OpSaveDistribution:
2572 // dump control distribution data to the text file
2573 ::SaveDistribution();
2577 case SMESHOp::OpShowDistribution:
2579 // show/hide distribution
2580 ::ShowElement(theCommandID);
2584 #ifndef DISABLE_PLOT2DVIEWER
2585 case SMESHOp::OpPlotDistribution:
2587 // plot distribution
2588 ::PlotDistribution();
2594 case SMESHOp::OpAutoColor:
2598 case SMESHOp::OpDisableAutoColor:
2599 ::DisableAutoColor();
2602 case SMESHOp::OpClipping:
2603 case SMESHOp::OpTransparency:
2604 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2607 case SMESHOp::OpDMWireframe:
2608 case SMESHOp::OpDMShading:
2609 case SMESHOp::OpDMNodes:
2610 case SMESHOp::OpDMShrink:
2611 ::SetDisplayMode(theCommandID, myMarkerMap);
2614 //2D quadratic representation
2615 case SMESHOp::OpRepresentationLines:
2616 case SMESHOp::OpRepresentationArcs:
2617 ::SetDisplayMode(theCommandID, myMarkerMap);
2621 case SMESHOp::OpDE0DElements:
2622 case SMESHOp::OpDEEdges:
2623 case SMESHOp::OpDEFaces:
2624 case SMESHOp::OpDEVolumes:
2625 case SMESHOp::OpDEBalls:
2626 case SMESHOp::OpDEAllEntity:
2627 ::SetDisplayEntity(theCommandID);
2630 // Choose entities to be displayed
2631 case SMESHOp::OpDEChoose:
2633 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2637 case SMESHOp::OpOrientationOnFaces:
2639 SUIT_OverrideCursor wc;
2640 LightApp_SelectionMgr* mgr = selectionMgr();
2641 SALOME_ListIO selected; mgr->selectedObjects( selected );
2643 SALOME_ListIteratorOfListIO it(selected);
2644 for( ; it.More(); it.Next()) {
2645 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2646 if(anIObject->hasEntry()) {
2647 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2648 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2655 case SMESHOp::OpUpdate:
2657 if(checkLock(aStudy)) break;
2658 SUIT_OverrideCursor wc;
2661 SMESH::UpdateView();
2663 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2664 SMESH::OnVisuException();
2666 catch (...) { // PAL16774 (Crash after display of many groups)
2667 SMESH::OnVisuException();
2671 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2672 aSel->selectedObjects( l );
2673 aSel->setSelectedObjects( l );
2677 case SMESHOp::OpHide:
2678 case SMESHOp::OpShow:
2679 case SMESHOp::OpShowOnly:
2681 SUIT_OverrideCursor wc;
2682 SMESH::EDisplaing anAction;
2683 switch (theCommandID) {
2684 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2685 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2686 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2689 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2690 SALOME_ListIO sel_objects, to_process;
2692 aSel->selectedObjects( sel_objects );
2694 if ( theCommandID==SMESHOp::OpShowOnly )
2696 //MESSAGE("anAction = SMESH::eDisplayOnly");
2697 startOperation( myEraseAll );
2700 extractContainers( sel_objects, to_process );
2705 SALOME_ListIteratorOfListIO It( to_process );
2706 for ( ; It.More(); It.Next())
2708 Handle(SALOME_InteractiveObject) IOS = It.Value();
2709 if ( IOS->hasEntry() )
2711 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2712 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2713 break; // PAL16774 (Crash after display of many groups)
2715 if (anAction == SMESH::eDisplayOnly)
2716 anAction = SMESH::eDisplay;
2721 // PAL13338 + PAL15161 -->
2722 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !checkLock(aStudy)) {
2723 SMESH::UpdateView();
2724 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2726 // PAL13338 + PAL15161 <--
2728 catch (...) { // PAL16774 (Crash after display of many groups)
2729 SMESH::OnVisuException();
2732 if (anAction == SMESH::eErase) {
2734 aSel->setSelectedObjects( l1 );
2737 aSel->setSelectedObjects( to_process );
2742 case SMESHOp::OpNode:
2744 if(checkLock(aStudy)) break;
2747 EmitSignalDeactivateDialog();
2749 ( new SMESHGUI_NodesDlg( this ) )->show();
2752 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2757 case SMESHOp::OpCreateMesh:
2758 case SMESHOp::OpCreateSubMesh:
2759 case SMESHOp::OpEditMeshOrSubMesh:
2760 case SMESHOp::OpEditMesh:
2761 case SMESHOp::OpEditSubMesh:
2762 case SMESHOp::OpCompute:
2763 case SMESHOp::OpComputeSubMesh:
2764 case SMESHOp::OpPreCompute:
2765 case SMESHOp::OpEvaluate:
2766 case SMESHOp::OpMeshOrder:
2767 startOperation( theCommandID );
2769 case SMESHOp::OpCopyMesh:
2771 if (checkLock(aStudy)) break;
2772 EmitSignalDeactivateDialog();
2773 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2776 case SMESHOp::OpBuildCompoundMesh:
2778 if (checkLock(aStudy)) break;
2779 EmitSignalDeactivateDialog();
2780 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2784 case SMESHOp::OpDiagonalInversion:
2785 case SMESHOp::OpUnionOfTwoTriangle:
2789 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2793 if ( checkLock( aStudy ) )
2796 /*Standard_Boolean aRes;
2797 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2798 if ( aMesh->_is_nil() )
2800 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2801 tr( "SMESH_BAD_SELECTION" ) );
2805 EmitSignalDeactivateDialog();
2806 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2807 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2809 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2812 case SMESHOp::OpOrientation:
2813 case SMESHOp::OpUnionOfTriangles:
2814 case SMESHOp::OpCuttingOfQuadrangles:
2815 case SMESHOp::OpSplitVolumes:
2819 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2823 if ( checkLock( aStudy ) )
2826 EmitSignalDeactivateDialog();
2827 SMESHGUI_MultiEditDlg* aDlg = NULL;
2828 if ( theCommandID == SMESHOp::OpOrientation )
2829 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2830 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2831 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2832 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2833 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2835 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2840 case SMESHOp::OpSmoothing:
2842 if(checkLock(aStudy)) break;
2844 EmitSignalDeactivateDialog();
2845 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2848 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2852 case SMESHOp::OpExtrusion:
2854 if (checkLock(aStudy)) break;
2856 EmitSignalDeactivateDialog();
2857 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2859 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2863 case SMESHOp::OpExtrusionAlongAPath:
2865 if (checkLock(aStudy)) break;
2867 EmitSignalDeactivateDialog();
2868 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2870 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2874 case SMESHOp::OpRevolution:
2876 if(checkLock(aStudy)) break;
2878 EmitSignalDeactivateDialog();
2879 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2882 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2886 case SMESHOp::OpPatternMapping:
2888 if ( checkLock( aStudy ) )
2892 EmitSignalDeactivateDialog();
2893 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2896 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2900 case SMESHOp::OpSplitBiQuadratic:
2901 case SMESHOp::OpConvertMeshToQuadratic:
2902 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2903 case SMESHOp::OpReorientFaces:
2904 case SMESHOp::OpCreateGeometryGroup:
2906 startOperation( theCommandID );
2909 case SMESHOp::OpCreateGroup:
2913 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2917 if(checkLock(aStudy)) break;
2918 EmitSignalDeactivateDialog();
2919 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2921 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2922 SALOME_ListIO selected;
2924 aSel->selectedObjects( selected );
2926 int nbSel = selected.Extent();
2928 // check if mesh is selected
2929 aMesh = SMESH::GetMeshByIO( selected.First() );
2931 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2936 case SMESHOp::OpConstructGroup:
2940 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2944 if(checkLock(aStudy)) break;
2945 EmitSignalDeactivateDialog();
2947 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2948 SALOME_ListIO selected;
2950 aSel->selectedObjects( selected );
2952 int nbSel = selected.Extent();
2954 // check if submesh is selected
2955 Handle(SALOME_InteractiveObject) IObject = selected.First();
2956 if (IObject->hasEntry()) {
2957 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2959 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2960 if (!aSubMesh->_is_nil()) {
2962 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2963 // get submesh elements list by types
2964 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2965 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2966 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2967 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2968 // create group for each type o elements
2969 QString aName = IObject->getName();
2970 QStringList anEntryList;
2971 if (aNodes->length() > 0) {
2972 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2973 aGroup->Add(aNodes.inout());
2974 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2975 anEntryList.append( aSObject->GetID().c_str() );
2977 if (aEdges->length() > 0) {
2978 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2979 aGroup->Add(aEdges.inout());
2980 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2981 anEntryList.append( aSObject->GetID().c_str() );
2983 if (aFaces->length() > 0) {
2984 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2985 aGroup->Add(aFaces.inout());
2986 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2987 anEntryList.append( aSObject->GetID().c_str() );
2989 if (aVolumes->length() > 0) {
2990 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2991 aGroup->Add(aVolumes.inout());
2992 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2993 anEntryList.append( aSObject->GetID().c_str() );
2996 anApp->browseObjects( anEntryList );
2998 catch(const SALOME::SALOME_Exception & S_ex){
2999 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3006 SUIT_MessageBox::warning(desktop(),
3007 tr("SMESH_WRN_WARNING"),
3008 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3013 case SMESHOp::OpEditGroup:
3017 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3021 if(checkLock(aStudy)) break;
3022 EmitSignalDeactivateDialog();
3024 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3025 SALOME_ListIO selected;
3027 aSel->selectedObjects( selected );
3029 SALOME_ListIteratorOfListIO It (selected);
3030 int nbSelectedGroups = 0;
3031 for ( ; It.More(); It.Next() )
3033 SMESH::SMESH_GroupBase_var aGroup =
3034 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3035 if (!aGroup->_is_nil()) {
3037 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3041 if (nbSelectedGroups == 0)
3043 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3049 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3051 if(checkLock(aStudy)) break;
3052 if (myState == 800) {
3053 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3054 if (aDlg) aDlg->onAdd();
3059 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3061 if(checkLock(aStudy)) break;
3062 if (myState == 800) {
3063 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3064 if (aDlg) aDlg->onRemove();
3069 case SMESHOp::OpEditGeomGroupAsGroup:
3073 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3077 if(checkLock(aStudy)) break;
3078 EmitSignalDeactivateDialog();
3080 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3081 SALOME_ListIO selected;
3083 aSel->selectedObjects( selected );
3085 SALOME_ListIteratorOfListIO It (selected);
3086 for ( ; It.More(); It.Next() )
3088 SMESH::SMESH_GroupOnGeom_var aGroup =
3089 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3090 if (!aGroup->_is_nil()) {
3091 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3096 SMESH::SMESH_GroupOnFilter_var aGroup =
3097 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3098 if (!aGroup->_is_nil()) {
3099 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3107 case SMESHOp::OpUnionGroups:
3108 case SMESHOp::OpIntersectGroups:
3109 case SMESHOp::OpCutGroups:
3113 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3117 if ( checkLock( aStudy ) )
3120 EmitSignalDeactivateDialog();
3122 SMESHGUI_GroupOpDlg* aDlg = 0;
3123 if ( theCommandID == SMESHOp::OpUnionGroups )
3124 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3125 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3126 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3128 aDlg = new SMESHGUI_CutGroupsDlg( this );
3135 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3137 if ( checkLock( aStudy ) )
3140 EmitSignalDeactivateDialog();
3141 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3147 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3151 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3155 if ( checkLock( aStudy ) )
3158 EmitSignalDeactivateDialog();
3160 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3164 case SMESHOp::OpMeshInformation:
3165 case SMESHOp::OpWhatIs:
3167 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3168 EmitSignalDeactivateDialog();
3169 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3170 SALOME_ListIO selected;
3172 aSel->selectedObjects( selected );
3174 if ( selected.Extent() > 1 ) { // a dlg for each IO
3175 SALOME_ListIteratorOfListIO It( selected );
3176 for ( ; It.More(); It.Next() ) {
3177 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3178 dlg->showInfo( It.Value() );
3183 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3189 case SMESHOp::OpFindElementByPoint:
3191 startOperation( theCommandID );
3195 case SMESHOp::OpEditHypothesis:
3197 if(checkLock(aStudy)) break;
3199 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3200 SALOME_ListIO selected;
3202 aSel->selectedObjects( selected );
3204 int nbSel = selected.Extent();
3207 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3208 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3210 if ( !aHypothesis->_is_nil() )
3212 SMESHGUI_GenericHypothesisCreator* aCreator =
3213 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3216 // set geometry of mesh and sub-mesh to aCreator
3217 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3218 if ( selected.Extent() == 1 )
3220 QString subGeomID, meshGeomID;
3221 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3222 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3224 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3225 aCreator->setShapeEntry( subGeomID );
3226 aCreator->setMainShapeEntry( meshGeomID );
3230 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3240 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3242 if(checkLock(aStudy)) break;
3243 SUIT_OverrideCursor wc;
3245 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3246 SALOME_ListIO selected;
3248 aSel->selectedObjects( selected, QString::null, false );
3250 SALOME_ListIteratorOfListIO It(selected);
3251 for (int i = 0; It.More(); It.Next(), i++) {
3252 Handle(SALOME_InteractiveObject) IObject = It.Value();
3253 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3256 aSel->setSelectedObjects( l1 );
3261 case SMESHOp::OpElem0D:
3262 case SMESHOp::OpBall:
3263 case SMESHOp::OpEdge:
3264 case SMESHOp::OpTriangle:
3265 case SMESHOp::OpQuadrangle:
3266 case SMESHOp::OpPolygon:
3267 case SMESHOp::OpTetrahedron:
3268 case SMESHOp::OpHexahedron:
3269 case SMESHOp::OpPentahedron:
3270 case SMESHOp::OpPyramid:
3271 case SMESHOp::OpHexagonalPrism:
3273 if(checkLock(aStudy)) break;
3275 EmitSignalDeactivateDialog();
3276 SMDSAbs_EntityType type = SMDSEntity_Edge;
3277 switch (theCommandID) {
3278 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3279 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3280 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3281 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3282 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3283 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3284 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3285 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3286 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3287 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3290 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3293 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3297 case SMESHOp::OpPolyhedron:
3299 if(checkLock(aStudy)) break;
3301 EmitSignalDeactivateDialog();
3302 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3305 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3309 case SMESHOp::OpQuadraticEdge:
3310 case SMESHOp::OpQuadraticTriangle:
3311 case SMESHOp::OpBiQuadraticTriangle:
3312 case SMESHOp::OpQuadraticQuadrangle:
3313 case SMESHOp::OpBiQuadraticQuadrangle:
3314 case SMESHOp::OpQuadraticPolygon:
3315 case SMESHOp::OpQuadraticTetrahedron:
3316 case SMESHOp::OpQuadraticPyramid:
3317 case SMESHOp::OpQuadraticPentahedron:
3318 case SMESHOp::OpBiQuadraticPentahedron:
3319 case SMESHOp::OpQuadraticHexahedron:
3320 case SMESHOp::OpTriQuadraticHexahedron:
3322 if(checkLock(aStudy)) break;
3324 EmitSignalDeactivateDialog();
3325 SMDSAbs_EntityType type = SMDSEntity_Last;
3327 switch (theCommandID) {
3328 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3329 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3330 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3331 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3332 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3333 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3334 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3335 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3336 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3337 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3338 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3339 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3342 if ( type != SMDSEntity_Last )
3343 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3346 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3347 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3351 case SMESHOp::OpRemoveNodes:
3353 if(checkLock(aStudy)) break;
3355 EmitSignalDeactivateDialog();
3356 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3359 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3360 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3364 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3366 if(checkLock(aStudy)) break;
3368 EmitSignalDeactivateDialog();
3369 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3373 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3374 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3378 case SMESHOp::OpClearMesh: {
3380 if(checkLock(aStudy)) break;
3382 SALOME_ListIO selected;
3383 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3384 aSel->selectedObjects( selected );
3386 SUIT_OverrideCursor wc;
3387 SALOME_ListIteratorOfListIO It (selected);
3388 for ( ; It.More(); It.Next() )
3390 Handle(SALOME_InteractiveObject) IOS = It.Value();
3391 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3392 if ( aMesh->_is_nil()) continue;
3395 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3396 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3397 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3398 SMESH::ModifiedMesh( aMeshSObj, false, true);
3399 // hide groups and submeshes
3400 _PTR(ChildIterator) anIter =
3401 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3402 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3404 _PTR(SObject) so = anIter->Value();
3405 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3408 catch (const SALOME::SALOME_Exception& S_ex){
3410 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3414 SMESH::UpdateView();
3418 case SMESHOp::OpRemoveOrphanNodes:
3420 if(checkLock(aStudy)) break;
3421 SALOME_ListIO selected;
3422 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3423 aSel->selectedObjects( selected );
3424 if ( selected.Extent() == 1 ) {
3425 Handle(SALOME_InteractiveObject) anIO = selected.First();
3426 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3427 if ( !aMesh->_is_nil() ) {
3428 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3429 tr( "SMESH_WARNING" ),
3430 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3431 SUIT_MessageBox::Yes |
3432 SUIT_MessageBox::No,
3433 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3436 SUIT_OverrideCursor wc;
3437 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3438 int removed = aMeshEditor->RemoveOrphanNodes();
3439 SUIT_MessageBox::information(SMESHGUI::desktop(),
3440 tr("SMESH_INFORMATION"),
3441 tr("NB_NODES_REMOVED").arg(removed));
3442 if ( removed > 0 ) {
3443 SMESH::UpdateView();
3444 SMESHGUI::Modified();
3447 catch (const SALOME::SALOME_Exception& S_ex) {
3448 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3457 case SMESHOp::OpRenumberingNodes:
3459 if(checkLock(aStudy)) break;
3461 EmitSignalDeactivateDialog();
3462 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3466 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3467 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3471 case SMESHOp::OpRenumberingElements:
3473 if(checkLock(aStudy)) break;
3475 EmitSignalDeactivateDialog();
3476 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3480 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3481 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3485 case SMESHOp::OpTranslation:
3487 if(checkLock(aStudy)) break;
3489 EmitSignalDeactivateDialog();
3490 ( new SMESHGUI_TranslationDlg( this ) )->show();
3493 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3494 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3498 case SMESHOp::OpRotation:
3500 if(checkLock(aStudy)) break;
3502 EmitSignalDeactivateDialog();
3503 ( new SMESHGUI_RotationDlg( this ) )->show();
3506 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3507 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3511 case SMESHOp::OpSymmetry:
3513 if(checkLock(aStudy)) break;
3515 EmitSignalDeactivateDialog();
3516 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3519 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3520 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3524 case SMESHOp::OpScale:
3526 if(checkLock(aStudy)) break;
3528 EmitSignalDeactivateDialog();
3529 ( new SMESHGUI_ScaleDlg( this ) )->show();
3532 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3533 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3538 case SMESHOp::OpOffset:
3540 if(checkLock(aStudy)) break;
3542 EmitSignalDeactivateDialog();
3543 ( new SMESHGUI_OffsetDlg( this ) )->show();
3546 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3547 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3552 case SMESHOp::OpSewing:
3554 if(checkLock(aStudy)) break;
3556 EmitSignalDeactivateDialog();
3557 ( new SMESHGUI_SewingDlg( this ) )->show();
3560 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3561 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3565 case SMESHOp::OpMergeNodes:
3567 if(checkLock(aStudy)) break;
3569 EmitSignalDeactivateDialog();
3570 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3573 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3574 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3578 case SMESHOp::OpMergeElements:
3580 if (checkLock(aStudy)) break;
3582 EmitSignalDeactivateDialog();
3583 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3585 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3586 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3591 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3592 startOperation( SMESHOp::OpMoveNode );
3595 case SMESHOp::OpDuplicateNodes:
3597 if(checkLock(aStudy)) break;
3599 EmitSignalDeactivateDialog();
3600 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3603 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3604 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3609 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3610 startOperation( SMESHOp::OpElem0DOnElemNodes );
3613 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3615 static QList<int> aTypes;
3616 if ( aTypes.isEmpty() )
3618 aTypes.append( SMESH::NODE );
3619 aTypes.append( SMESH::EDGE );
3620 aTypes.append( SMESH::FACE );
3621 aTypes.append( SMESH::VOLUME );
3623 if (!myFilterLibraryDlg)
3624 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3625 else if (myFilterLibraryDlg->isHidden())
3626 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3627 myFilterLibraryDlg->raise();
3631 case SMESHOp::OpFreeNode:
3632 case SMESHOp::OpEqualNode:
3633 case SMESHOp::OpNodeConnectivityNb:
3634 case SMESHOp::OpFreeEdge:
3635 case SMESHOp::OpFreeBorder:
3636 case SMESHOp::OpLength:
3637 case SMESHOp::OpConnection:
3638 case SMESHOp::OpEqualEdge:
3639 case SMESHOp::OpFreeFace:
3640 case SMESHOp::OpBareBorderFace:
3641 case SMESHOp::OpOverConstrainedFace:
3642 case SMESHOp::OpLength2D:
3643 case SMESHOp::OpDeflection2D:
3644 case SMESHOp::OpConnection2D:
3645 case SMESHOp::OpArea:
3646 case SMESHOp::OpTaper:
3647 case SMESHOp::OpAspectRatio:
3648 case SMESHOp::OpMinimumAngle:
3649 case SMESHOp::OpWarpingAngle:
3650 case SMESHOp::OpSkew:
3651 case SMESHOp::OpMaxElementLength2D:
3652 case SMESHOp::OpEqualFace:
3653 case SMESHOp::OpAspectRatio3D:
3654 case SMESHOp::OpVolume:
3655 case SMESHOp::OpMaxElementLength3D:
3656 case SMESHOp::OpBareBorderVolume:
3657 case SMESHOp::OpOverConstrainedVolume:
3658 case SMESHOp::OpEqualVolume:
3661 LightApp_SelectionMgr* mgr = selectionMgr();
3662 SALOME_ListIO selected; mgr->selectedObjects( selected );
3664 if( !selected.IsEmpty() ) {
3665 SUIT_OverrideCursor wc;
3666 ::Control( theCommandID );
3669 SUIT_MessageBox::warning(desktop(),
3670 tr( "SMESH_WRN_WARNING" ),
3671 tr( "SMESH_BAD_SELECTION" ) );
3675 SUIT_MessageBox::warning(desktop(),
3676 tr( "SMESH_WRN_WARNING" ),
3677 tr( "NOT_A_VTK_VIEWER" ) );
3680 case SMESHOp::OpOverallMeshQuality:
3681 OverallMeshQuality();
3683 case SMESHOp::OpNumberingNodes:
3685 SUIT_OverrideCursor wc;
3686 LightApp_SelectionMgr* mgr = selectionMgr();
3687 SALOME_ListIO selected; mgr->selectedObjects( selected );
3689 SALOME_ListIteratorOfListIO it(selected);
3690 for( ; it.More(); it.Next()) {
3691 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3692 if(anIObject->hasEntry()) {
3693 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3694 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3700 case SMESHOp::OpNumberingElements:
3702 SUIT_OverrideCursor wc;
3703 LightApp_SelectionMgr* mgr = selectionMgr();
3704 SALOME_ListIO selected; mgr->selectedObjects( selected );
3706 SALOME_ListIteratorOfListIO it(selected);
3707 for( ; it.More(); it.Next()) {
3708 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3709 if(anIObject->hasEntry())
3710 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3711 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3716 case SMESHOp::OpPropertiesLength:
3717 case SMESHOp::OpPropertiesArea:
3718 case SMESHOp::OpPropertiesVolume:
3719 case SMESHOp::OpMinimumDistance:
3720 case SMESHOp::OpBoundingBox:
3722 int page = SMESHGUI_MeasureDlg::MinDistance;
3723 if ( theCommandID == SMESHOp::OpBoundingBox )
3724 page = SMESHGUI_MeasureDlg::BoundingBox;
3725 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3726 page = SMESHGUI_MeasureDlg::Length;
3727 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3728 page = SMESHGUI_MeasureDlg::Area;
3729 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3730 page = SMESHGUI_MeasureDlg::Volume;
3732 EmitSignalDeactivateDialog();
3733 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3737 case SMESHOp::OpSortChild:
3743 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3744 //updateObjBrowser();
3748 //=============================================================================
3752 //=============================================================================
3753 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3758 //=============================================================================
3762 //=============================================================================
3763 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3768 //=============================================================================
3772 //=============================================================================
3773 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3778 //=============================================================================
3779 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3780 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3782 //=============================================================================
3783 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3784 SUIT_ViewWindow* wnd )
3786 if(theIO->hasEntry()){
3787 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3788 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3792 //=======================================================================
3793 // function : createSMESHAction
3795 //=======================================================================
3796 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3797 const int key, const bool toggle, const QString& shortcutAction )
3800 QWidget* parent = application()->desktop();
3801 SUIT_ResourceMgr* resMgr = resourceMgr();
3803 if ( !icon_id.isEmpty() )
3804 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3806 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3807 if ( !pix.isNull() )
3808 icon = QIcon( pix );
3810 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3811 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3812 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3814 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3815 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3818 //=======================================================================
3819 // function : createPopupItem
3821 //=======================================================================
3822 void SMESHGUI::createPopupItem( const int id,
3823 const QString& clients,
3824 const QString& types,
3825 const QString& theRule,
3828 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3829 popupMgr()->insert( action( id ), pId, 0 );
3831 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3832 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3833 QString rule = "(%1) and (%2) and (%3)";
3834 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3835 if( clients.isEmpty() )
3836 rule = rule.arg( QString( "true" ) );
3838 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3839 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3842 bool cont = myRules.contains( id );
3844 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3846 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3847 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3850 //=======================================================================
3851 // function : initialize
3853 //=======================================================================
3854 void SMESHGUI::initialize( CAM_Application* app )
3856 SalomeApp_Module::initialize( app );
3858 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3860 /* Automatic Update flag */
3861 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3863 // ----- create actions --------------
3865 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3866 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
3867 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3868 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
3870 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
3872 createSMESHAction( SMESHOp::OpImportSAUV, "IMPORT_SAUV" );
3873 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
3874 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
3875 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
3876 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
3878 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
3880 createSMESHAction( SMESHOp::OpPopupImportSAUV, "IMPORT_SAUV" );
3881 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
3883 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
3884 createSMESHAction( SMESHOp::OpExportMED, "MED" );
3885 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
3886 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
3888 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
3890 createSMESHAction( SMESHOp::OpExportSAUV, "SAUV");
3891 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
3892 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
3893 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
3894 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
3895 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
3897 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
3899 createSMESHAction( SMESHOp::OpPopupExportSAUV, "SAUV");
3900 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
3901 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
3902 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3903 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
3904 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3905 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3906 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
3907 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
3908 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
3909 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3910 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
3911 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
3912 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
3913 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3914 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
3915 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
3916 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3917 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
3918 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3919 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3920 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3921 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
3922 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
3923 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
3924 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
3925 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
3926 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
3927 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
3928 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
3929 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
3930 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3931 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
3933 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3934 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3935 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
3936 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3937 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3938 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
3939 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
3940 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3941 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3942 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3943 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3944 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3945 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
3946 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3947 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
3948 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
3949 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
3950 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
3951 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
3952 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
3953 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3954 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3955 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3956 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3957 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3958 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3959 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3960 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3961 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
3963 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
3964 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
3965 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3966 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
3967 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
3968 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3969 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
3970 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
3971 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
3972 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
3973 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
3974 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
3975 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
3976 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3977 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3978 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3979 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3980 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3981 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3982 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
3983 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3984 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3985 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3986 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
3987 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3988 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3990 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3991 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3992 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3993 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
3995 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3996 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3998 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3999 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4000 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4001 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4002 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4003 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4004 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4005 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4006 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4007 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4008 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4009 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4010 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4011 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4012 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4013 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4014 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4015 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4016 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4017 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4018 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4019 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4020 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4021 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4022 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4024 createSMESHAction( SMESHOp::OpReset, "RESET" );
4025 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4026 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4027 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4028 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4029 #ifndef DISABLE_PLOT2DVIEWER
4030 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4032 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4033 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4034 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4035 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4036 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4037 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4038 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4039 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4040 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4041 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4042 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4043 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4044 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4046 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4047 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4049 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4050 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4051 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4052 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4053 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4054 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4055 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4056 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4057 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4059 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4060 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4061 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4062 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4063 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4065 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4066 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4067 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4069 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4071 QList<int> aCtrlActions;
4072 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4073 << SMESHOp::OpNodeConnectivityNb // node controls
4074 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4075 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4076 << SMESHOp::OpDeflection2D
4077 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4078 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4079 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4080 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4081 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4082 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4083 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4084 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4085 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4086 aCtrlGroup->setExclusive( true );
4087 for( int i = 0; i < aCtrlActions.size(); i++ )
4088 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4090 // ----- create menu --------------
4091 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4092 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4093 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4094 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4095 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4096 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4097 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4098 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4100 createMenu( separator(), fileId );
4102 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4103 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4104 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4105 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4106 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4107 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4108 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4109 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4110 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4111 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4112 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4113 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4114 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4116 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4117 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4118 createMenu( SMESHOp::OpImportMED, importId, -1 );
4119 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4121 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4123 createMenu( SMESHOp::OpImportSAUV, importId, -1 );
4124 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4125 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4126 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4127 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4128 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4130 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4132 createMenu( SMESHOp::OpExportSAUV, exportId, -1 );
4133 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4134 createMenu( separator(), fileId, 10 );
4136 createMenu( SMESHOp::OpDelete, editId, -1 );
4138 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4140 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4141 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4142 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4143 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4144 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4145 createMenu( separator(), meshId, -1 );
4146 createMenu( SMESHOp::OpCompute, meshId, -1 );
4147 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4148 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4149 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4150 createMenu( separator(), meshId, -1 );
4151 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4152 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4153 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4154 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4155 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4156 createMenu( separator(), meshId, -1 );
4157 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4158 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4159 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4160 createMenu( separator(), meshId, -1 );
4161 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4162 createMenu( separator(), meshId, -1 );
4163 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4164 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4165 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4166 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4167 createMenu( separator(), meshId, -1 );
4169 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4170 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4171 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4172 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4173 createMenu( SMESHOp::OpLength, edgeId, -1 );
4174 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4175 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4176 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4177 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4178 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4179 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4180 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4181 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4182 createMenu( SMESHOp::OpArea, faceId, -1 );
4183 createMenu( SMESHOp::OpTaper, faceId, -1 );
4184 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4185 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4186 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4187 createMenu( SMESHOp::OpSkew, faceId, -1 );
4188 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4189 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4190 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4191 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4192 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4193 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4194 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4195 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4196 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4197 createMenu( separator(), ctrlId, -1 );
4198 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4199 createMenu( separator(), ctrlId, -1 );
4200 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4202 createMenu( SMESHOp::OpNode, addId, -1 );
4203 createMenu( SMESHOp::OpElem0D, addId, -1 );
4204 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4205 createMenu( SMESHOp::OpBall, addId, -1 );
4206 createMenu( SMESHOp::OpEdge, addId, -1 );
4207 createMenu( SMESHOp::OpTriangle, addId, -1 );
4208 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4209 createMenu( SMESHOp::OpPolygon, addId, -1 );
4210 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4211 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4212 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4213 createMenu( SMESHOp::OpPyramid, addId, -1 );
4214 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4215 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4216 createMenu( separator(), addId, -1 );
4217 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4218 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4219 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4220 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4221 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4222 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4223 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4224 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4225 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4226 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4227 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4228 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4230 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4231 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4232 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4233 createMenu( separator(), removeId, -1 );
4234 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4235 createMenu( separator(), removeId, -1 );
4236 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4238 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4239 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4241 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4242 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4243 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4244 createMenu( SMESHOp::OpRotation, transfId, -1 );
4245 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4246 createMenu( SMESHOp::OpScale, transfId, -1 );
4247 createMenu( SMESHOp::OpOffset, transfId, -1 );
4248 createMenu( SMESHOp::OpSewing, transfId, -1 );
4249 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4251 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4252 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4253 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4254 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4255 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4256 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4257 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4258 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4259 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4260 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4261 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4262 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4263 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4264 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4265 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4266 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4268 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4269 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4270 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4271 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4272 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4273 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4275 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4276 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4277 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4278 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4280 // ----- create toolbars --------------
4281 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ),
4282 info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ),
4283 groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ),
4284 ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ),
4285 ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ),
4286 ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ),
4287 ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ),
4288 addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ),
4289 addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ),
4290 remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ),
4291 //renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ),
4292 transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
4293 modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ),
4294 measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ),
4295 dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4297 createTool( SMESHOp::OpCreateMesh, meshTb );
4298 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4299 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4300 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4301 createTool( SMESHOp::OpCopyMesh, meshTb );
4302 createTool( separator(), meshTb );
4303 createTool( SMESHOp::OpCompute, meshTb );
4304 createTool( SMESHOp::OpPreCompute, meshTb );
4305 createTool( SMESHOp::OpEvaluate, meshTb );
4306 createTool( SMESHOp::OpMeshOrder, meshTb );
4308 createTool( SMESHOp::OpCreateGroup, groupTb );
4309 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4310 createTool( SMESHOp::OpConstructGroup, groupTb );
4311 createTool( SMESHOp::OpEditGroup, groupTb );
4313 createTool( SMESHOp::OpMeshInformation, info );
4314 //createTool( SMESHOp::OpStdInfo, meshTb );
4315 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4316 createTool( SMESHOp::OpFindElementByPoint, info );
4318 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4319 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4320 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4322 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4323 createTool( SMESHOp::OpLength, ctrl1dTb );
4324 createTool( SMESHOp::OpConnection, ctrl1dTb );
4325 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4327 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4328 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4329 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4330 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4331 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4332 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4333 createTool( SMESHOp::OpArea, ctrl2dTb );
4334 createTool( SMESHOp::OpTaper, ctrl2dTb );
4335 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4336 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4337 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4338 createTool( SMESHOp::OpSkew, ctrl2dTb );
4339 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4340 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4341 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4343 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4344 createTool( SMESHOp::OpVolume, ctrl3dTb );
4345 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4346 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4347 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4348 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4350 createTool( SMESHOp::OpNode, addElemTb );
4351 createTool( SMESHOp::OpElem0D, addElemTb );
4352 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4353 createTool( SMESHOp::OpBall, addElemTb );
4354 createTool( SMESHOp::OpEdge, addElemTb );
4355 createTool( SMESHOp::OpTriangle, addElemTb );
4356 createTool( SMESHOp::OpQuadrangle, addElemTb );
4357 createTool( SMESHOp::OpPolygon, addElemTb );
4358 createTool( SMESHOp::OpTetrahedron, addElemTb );
4359 createTool( SMESHOp::OpHexahedron, addElemTb );
4360 createTool( SMESHOp::OpPentahedron, addElemTb );
4361 createTool( SMESHOp::OpPyramid, addElemTb );
4362 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4363 createTool( SMESHOp::OpPolyhedron, addElemTb );
4365 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4366 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4367 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4368 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4369 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4370 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4371 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4372 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4373 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4374 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4375 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4376 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4378 createTool( SMESHOp::OpRemoveNodes, remTb );
4379 createTool( SMESHOp::OpRemoveElements, remTb );
4380 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4381 createTool( SMESHOp::OpClearMesh, remTb );
4383 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4384 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4386 createTool( SMESHOp::OpMergeNodes, transformTb );
4387 createTool( SMESHOp::OpMergeElements, transformTb );
4388 createTool( SMESHOp::OpTranslation, transformTb );
4389 createTool( SMESHOp::OpRotation, transformTb );
4390 createTool( SMESHOp::OpSymmetry, transformTb );
4391 createTool( SMESHOp::OpScale, transformTb );
4392 createTool( SMESHOp::OpOffset, transformTb );
4393 createTool( SMESHOp::OpSewing, transformTb );
4394 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4396 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4397 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4398 createTool( SMESHOp::OpExtrusion, modifyTb );
4399 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4400 createTool( SMESHOp::OpRevolution, modifyTb );
4401 createTool( SMESHOp::OpOrientation, modifyTb );
4402 createTool( SMESHOp::OpReorientFaces, modifyTb );
4403 createTool( SMESHOp::OpMoveNode, modifyTb );
4404 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4405 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4406 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4407 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4408 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4409 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4410 createTool( SMESHOp::OpSmoothing, modifyTb );
4411 createTool( SMESHOp::OpPatternMapping, modifyTb );
4413 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4415 createTool( SMESHOp::OpUpdate, dispModeTb );
4417 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4418 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4422 OB = "'ObjectBrowser'",
4423 View = "'" + SVTK_Viewer::Type() + "'",
4425 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4426 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4427 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4428 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4429 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4430 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4431 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4432 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4433 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4434 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4435 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4436 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4438 mesh_part = mesh + " " + subMesh + " " + group,
4439 mesh_group = mesh + " " + group,
4440 mesh_submesh = mesh + " " + subMesh,
4441 hyp_alg = hypo + " " + algo;
4443 // popup for object browser
4445 isInvisible("not( isVisible )"),
4446 isEmpty("numberOfNodes = 0"),
4447 isNotEmpty("numberOfNodes <> 0"),
4449 // has nodes, edges, etc in VISIBLE! actor
4450 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4451 hasElems("(count( elemTypes ) > 0)"),
4452 hasDifferentElems("(count( elemTypes ) > 1)"),
4453 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4454 hasBalls("({'BallElem'} in elemTypes)"),
4455 hasElems0d("({'Elem0d'} in elemTypes)"),
4456 hasEdges("({'Edge'} in elemTypes)"),
4457 hasFaces("({'Face'} in elemTypes)"),
4458 hasVolumes("({'Volume'} in elemTypes)"),
4459 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4461 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4462 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4463 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4464 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4465 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4466 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4468 popupMgr()->insert( separator(), -1, 0 );
4469 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && isComputable" );
4470 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && isComputable" );
4471 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && isPreComputable" );
4472 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && isComputable" );
4473 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && isComputable && hasGeomReference" );
4474 createPopupItem( SMESHOp::OpUpdate, OB, mesh_part );
4475 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4476 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1" );
4477 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4478 popupMgr()->insert( separator(), -1, 0 );
4479 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4480 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4481 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4482 popupMgr()->insert( separator(), -1, 0 );
4483 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4484 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4485 popupMgr()->insert( separator(), -1, 0 );
4486 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh );
4487 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4488 popupMgr()->insert( separator(), -1, 0 );
4489 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4490 //popupMgr()->insert( separator(), -1, 0 );
4492 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4493 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4494 QString only_one_2D = only_one_non_empty + " && dim>1";
4496 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4497 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4498 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4499 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4501 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4503 createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
4504 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4505 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4506 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4507 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4509 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4510 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4511 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4512 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4514 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4516 createPopupItem( SMESHOp::OpPopupImportSAUV, OB, smesh, "", anId );
4517 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4518 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4519 popupMgr()->insert( separator(), -1, 0 );
4522 createPopupItem( SMESHOp::OpEditGroup, View, group );
4523 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4524 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4526 popupMgr()->insert( separator(), -1, 0 );
4527 createPopupItem( SMESHOp::OpUpdate, View, mesh_part );
4528 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4529 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4530 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
4531 popupMgr()->insert( separator(), -1, 0 );
4533 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4534 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4535 popupMgr()->insert( separator(), -1, 0 );
4537 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4538 QString aType = QString( "%1type in {%2}" ).arg( lc );
4539 aType = aType.arg( mesh_part );
4540 QString aMeshInVTK = aClient + "&&" + aType;
4542 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4543 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4544 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4546 //-------------------------------------------------
4548 //-------------------------------------------------
4549 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4551 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4552 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4553 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4555 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4556 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4557 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4559 popupMgr()->insert( separator(), -1, -1 );
4561 //-------------------------------------------------
4563 //-------------------------------------------------
4564 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4566 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4567 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4568 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4570 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4571 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4572 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4574 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4575 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4576 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4578 popupMgr()->insert( separator(), anId, -1 );
4580 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4581 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4582 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4584 //-------------------------------------------------
4586 //-------------------------------------------------
4587 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4589 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4591 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4592 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4593 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4595 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4596 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4597 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4599 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4600 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4601 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4603 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4604 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4605 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4607 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4608 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4609 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4611 popupMgr()->insert( separator(), anId, -1 );
4613 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4614 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4616 popupMgr()->insert( separator(), anId, -1 );
4618 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4619 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4622 //-------------------------------------------------
4623 // Representation of the 2D Quadratic elements
4624 //-------------------------------------------------
4625 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4626 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4627 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4628 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4630 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4631 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4632 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4634 //-------------------------------------------------
4635 // Orientation of faces
4636 //-------------------------------------------------
4637 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4638 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4639 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4641 //-------------------------------------------------
4643 //-------------------------------------------------
4644 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4645 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4647 //-------------------------------------------------
4649 //-------------------------------------------------
4650 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4651 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4653 //-------------------------------------------------
4655 //-------------------------------------------------
4657 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4658 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4659 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4660 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4662 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4664 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4665 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4667 popupMgr()->insert( separator(), anId, -1 );
4669 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4671 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4672 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4673 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4675 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4676 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4677 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4679 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4680 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4681 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4683 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4685 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4686 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4687 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4689 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4690 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4691 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4693 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4694 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4695 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4696 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4697 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4698 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4700 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4702 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4703 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4704 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4706 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4707 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4708 QtxPopupMgr::VisibleRule );
4709 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4711 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4712 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4713 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4715 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4716 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4717 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4719 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4720 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4721 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4723 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4724 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4725 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4727 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4728 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4729 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4731 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4732 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4733 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4735 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4736 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4737 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4739 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4740 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4741 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4743 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4744 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4745 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4747 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4748 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4749 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4751 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4752 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4753 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4755 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4756 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4757 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4759 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
4760 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
4761 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
4763 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4765 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4766 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4767 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4769 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4770 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4771 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4773 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4774 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4775 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4777 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
4778 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4779 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4781 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
4782 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4783 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4785 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
4786 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4787 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4789 popupMgr()->insert( separator(), anId, -1 );
4791 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
4792 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4793 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
4794 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
4795 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4797 popupMgr()->insert( separator(), anId, -1 );
4799 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4801 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
4802 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4804 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
4805 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4806 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
4808 #ifndef DISABLE_PLOT2DVIEWER
4809 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
4810 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4813 //-------------------------------------------------
4815 //-------------------------------------------------
4816 popupMgr()->insert( separator(), -1, -1 );
4817 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4818 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4819 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
4820 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4822 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
4823 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4825 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
4826 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4828 popupMgr()->insert( separator(), -1, -1 );
4830 //-------------------------------------------------
4832 //-------------------------------------------------
4833 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
4834 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4836 popupMgr()->insert( separator(), -1, -1 );
4838 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
4839 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4840 popupMgr()->insert( separator(), -1, -1 );
4842 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4843 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4845 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4846 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4849 //================================================================================
4851 * \brief Return true if SMESH or GEOM objects are selected.
4852 * Is called form LightApp_Module::activateModule() which clear selection if
4853 * not isSelectionCompatible()
4855 //================================================================================
4857 bool SMESHGUI::isSelectionCompatible()
4859 bool isCompatible = true;
4860 SALOME_ListIO selected;
4861 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4862 Sel->selectedObjects( selected );
4864 SALOME_ListIteratorOfListIO It( selected );
4865 for ( ; isCompatible && It.More(); It.Next())
4867 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4868 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4870 return isCompatible;
4874 bool SMESHGUI::reusableOperation( const int id )
4876 // compute, evaluate and precompute are not reusable operations
4877 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
4880 bool SMESHGUI::activateModule( SUIT_Study* study )
4882 bool res = SalomeApp_Module::activateModule( study );
4884 setMenuShown( true );
4885 setToolShown( true );
4887 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4888 PyGILState_STATE gstate = PyGILState_Ensure();
4889 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4890 if ( !pluginsmanager ) {
4894 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
4899 PyGILState_Release(gstate);
4900 // end of SMESH plugins loading
4902 // Reset actions accelerator keys
4903 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
4905 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4906 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4907 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study )) {
4908 if ( _PTR(Study) aStudy = s->studyDS() )
4909 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4912 // get all view currently opened in the study and connect their signals to
4913 // the corresponding slots of the class.
4914 SUIT_Desktop* aDesk = study->application()->desktop();
4916 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4917 SUIT_ViewWindow* wnd;
4918 foreach ( wnd, wndList )
4922 Py_XDECREF(pluginsmanager);
4926 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4928 setMenuShown( false );
4929 setToolShown( false );
4931 EmitSignalCloseAllDialogs();
4933 // Unset actions accelerator keys
4934 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
4936 return SalomeApp_Module::deactivateModule( study );
4939 void SMESHGUI::studyClosed( SUIT_Study* s )
4943 SMESH::RemoveVisuData( s->id() );
4944 SalomeApp_Module::studyClosed( s );
4947 void SMESHGUI::OnGUIEvent()
4949 const QObject* obj = sender();
4950 if ( !obj || !obj->inherits( "QAction" ) )
4952 int id = actionId((QAction*)obj);
4957 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4959 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4960 if ( CORBA::is_nil( myComponentSMESH ) )
4962 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4964 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4965 return aGUI.myComponentSMESH;
4968 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4969 return myComponentSMESH;
4972 QString SMESHGUI::engineIOR() const
4974 CORBA::ORB_var anORB = getApp()->orb();
4975 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4976 return QString( anIOR.in() );
4979 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4981 SalomeApp_Module::contextMenuPopup( client, menu, title );
4983 selectionMgr()->selectedObjects( lst );
4984 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4985 Handle(SALOME_InteractiveObject) io = lst.First();
4986 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4987 _PTR(Study) study = appStudy->studyDS();
4988 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4990 QString aName = QString( SMESH::fromUtf8(obj->GetName()) );
4991 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4992 aName.remove( (aName.length() - 1), 1 );
4998 LightApp_Selection* SMESHGUI::createSelection() const
5000 return new SMESHGUI_Selection();
5003 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5005 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5006 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5007 #ifndef DISABLE_PYCONSOLE
5008 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5012 void SMESHGUI::viewManagers( QStringList& list ) const
5014 list.append( SVTK_Viewer::Type() );
5017 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5019 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5020 SMESH::UpdateSelectionProp( this );
5022 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5023 for(int i = 0; i < aViews.count() ; i++){
5024 SUIT_ViewWindow *sf = aViews[i];
5027 EmitSignalActivatedViewManager();
5031 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5033 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5034 myClippingPlaneInfoMap.erase( theViewManager );
5037 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5039 theActor->AddObserver( SMESH::DeleteActorEvent,
5040 myEventCallbackCommand.GetPointer(),
5044 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5045 unsigned long theEvent,
5046 void* theClientData,
5049 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5050 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5051 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5052 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5053 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5054 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5055 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5056 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5057 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5058 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5059 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5060 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5061 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5062 if( anActor == *anIter3 ) {
5063 anActorList.erase( anIter3 );
5074 void SMESHGUI::createPreferences()
5076 // General tab ------------------------------------------------------------------------
5077 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5079 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5080 setPreferenceProperty( autoUpdate, "columns", 2 );
5081 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5082 setPreferenceProperty( lim, "min", 0 );
5083 setPreferenceProperty( lim, "max", 100000000 );
5084 setPreferenceProperty( lim, "step", 1000 );
5085 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5086 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5088 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5089 setPreferenceProperty( dispgroup, "columns", 2 );
5090 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5092 modes.append( tr("MEN_WIRE") );
5093 modes.append( tr("MEN_SHADE") );
5094 modes.append( tr("MEN_NODES") );
5095 modes.append( tr("MEN_SHRINK") );
5096 QList<QVariant> indices;
5097 indices.append( 0 );
5098 indices.append( 1 );
5099 indices.append( 2 );
5100 indices.append( 3 );
5101 setPreferenceProperty( dispmode, "strings", modes );
5102 setPreferenceProperty( dispmode, "indexes", indices );
5104 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5105 setPreferenceProperty( arcgroup, "columns", 2 );
5106 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5107 QStringList quadraticModes;
5108 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5109 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5111 indices.append( 0 );
5112 indices.append( 1 );
5113 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5114 setPreferenceProperty( quadraticmode, "indexes", indices );
5116 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5117 "SMESH", "max_angle" );
5118 setPreferenceProperty( maxAngle, "min", 1 );
5119 setPreferenceProperty( maxAngle, "max", 90 );
5121 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5122 setPreferenceProperty( qaGroup, "columns", 2 );
5123 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5124 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5125 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5126 setPreferenceProperty( prec, "min", 0 );
5127 setPreferenceProperty( prec, "max", 100 );
5128 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5129 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5130 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5131 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5132 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5135 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5136 setPreferenceProperty( exportgroup, "columns", 2 );
5137 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5138 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5139 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5141 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5142 setPreferenceProperty( computeGroup, "columns", 2 );
5143 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5145 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5146 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5147 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5149 indices.append( 0 );
5150 indices.append( 1 );
5151 indices.append( 2 );
5152 setPreferenceProperty( notifyMode, "strings", modes );
5153 setPreferenceProperty( notifyMode, "indexes", indices );
5155 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5156 setPreferenceProperty( infoGroup, "columns", 2 );
5157 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5159 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5160 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5162 indices.append( 0 );
5163 indices.append( 1 );
5164 setPreferenceProperty( elemInfo, "strings", modes );
5165 setPreferenceProperty( elemInfo, "indexes", indices );
5166 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5167 setPreferenceProperty( nodesLim, "min", 0 );
5168 setPreferenceProperty( nodesLim, "max", 10000000 );
5169 setPreferenceProperty( nodesLim, "step", 10000 );
5170 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5171 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5172 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5173 setPreferenceProperty( ctrlLim, "min", 0 );
5174 setPreferenceProperty( ctrlLim, "max", 10000000 );
5175 setPreferenceProperty( ctrlLim, "step", 1000 );
5176 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5177 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5178 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5179 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5180 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5182 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5183 setPreferenceProperty( segGroup, "columns", 2 );
5184 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5185 "SMESH", "segmentation" );
5186 setPreferenceProperty( segLen, "min", 1 );
5187 setPreferenceProperty( segLen, "max", 10000000 );
5188 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5189 "SMESH", "nb_segments_per_edge" );
5190 setPreferenceProperty( nbSeg, "min", 1 );
5191 setPreferenceProperty( nbSeg, "max", 10000000 );
5193 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5194 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5195 "SMESH", "forget_mesh_on_hyp_modif" );
5198 // Quantities with individual precision settings
5199 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5200 setPreferenceProperty( precGroup, "columns", 2 );
5202 const int nbQuantities = 6;
5203 int precs[nbQuantities], ii = 0;
5204 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5205 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5206 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5207 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5208 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5209 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5210 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5211 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5212 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5213 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5214 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5215 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5217 // Set property for precision value for spinboxes
5218 for ( ii = 0; ii < nbQuantities; ii++ ){
5219 setPreferenceProperty( precs[ii], "min", -14 );
5220 setPreferenceProperty( precs[ii], "max", 14 );
5221 setPreferenceProperty( precs[ii], "precision", 2 );
5224 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5225 setPreferenceProperty( previewGroup, "columns", 2 );
5226 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5227 setPreferenceProperty( chunkSize, "min", 1 );
5228 setPreferenceProperty( chunkSize, "max", 1000 );
5229 setPreferenceProperty( chunkSize, "step", 50 );
5231 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5232 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5234 // Mesh tab ------------------------------------------------------------------------
5235 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5236 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5237 setPreferenceProperty( nodeGroup, "columns", 3 );
5239 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5241 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5243 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5244 QList<QVariant> aMarkerTypeIndicesList;
5245 QList<QVariant> aMarkerTypeIconsList;
5246 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5247 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5248 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5249 aMarkerTypeIndicesList << i;
5250 aMarkerTypeIconsList << pixmap;
5252 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5253 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5255 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5257 QList<QVariant> aMarkerScaleIndicesList;
5258 QStringList aMarkerScaleValuesList;
5259 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5260 aMarkerScaleIndicesList << i;
5261 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5262 aMarkerScaleValuesList << QString::number( i );
5264 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5265 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5267 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5268 //setPreferenceProperty( elemGroup, "columns", 2 );
5270 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5271 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5272 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5273 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5274 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5275 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5276 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5277 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5278 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5281 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5282 setPreferenceProperty( grpGroup, "columns", 2 );
5284 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5285 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5287 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5288 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5289 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5290 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5291 double ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5292 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5293 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5294 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5295 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5296 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5297 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5298 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5299 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5300 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5302 setPreferenceProperty( size0d, "min", 1 );
5303 setPreferenceProperty( size0d, "max", 10 );
5305 // setPreferenceProperty( ballSize, "min", 1 );
5306 // setPreferenceProperty( ballSize, "max", 10 );
5308 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5309 setPreferenceProperty( ballDiameter, "max", 1e9 );
5310 setPreferenceProperty( ballDiameter, "step", 0.1 );
5312 setPreferenceProperty( ballScale, "min", 1e-2 );
5313 setPreferenceProperty( ballScale, "max", 1e7 );
5314 setPreferenceProperty( ballScale, "step", 0.5 );
5316 setPreferenceProperty( elemW, "min", 1 );
5317 setPreferenceProperty( elemW, "max", 5 );
5319 setPreferenceProperty( outW, "min", 1 );
5320 setPreferenceProperty( outW, "max", 5 );
5322 setPreferenceProperty( shrink, "min", 0 );
5323 setPreferenceProperty( shrink, "max", 100 );
5325 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5326 setPreferenceProperty( numGroup, "columns", 2 );
5328 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5329 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5331 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5332 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5334 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5335 setPreferenceProperty( orientGroup, "columns", 1 );
5337 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5338 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5340 setPreferenceProperty( orientScale, "min", 0.05 );
5341 setPreferenceProperty( orientScale, "max", 0.5 );
5342 setPreferenceProperty( orientScale, "step", 0.05 );
5344 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5346 // Selection tab ------------------------------------------------------------------------
5347 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5349 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5350 setPreferenceProperty( selGroup, "columns", 2 );
5352 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5353 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5355 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5356 setPreferenceProperty( preGroup, "columns", 2 );
5358 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5360 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5361 setPreferenceProperty( precSelGroup, "columns", 2 );
5363 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5364 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5365 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5367 // Scalar Bar tab ------------------------------------------------------------------------
5368 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5369 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5370 setPreferenceProperty( fontGr, "columns", 2 );
5372 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5373 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5375 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5376 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5378 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5379 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5381 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5382 setPreferenceProperty( numcol, "min", 2 );
5383 setPreferenceProperty( numcol, "max", 256 );
5385 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5386 setPreferenceProperty( numlab, "min", 2 );
5387 setPreferenceProperty( numlab, "max", 65 );
5389 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5390 setPreferenceProperty( orientGr, "columns", 2 );
5391 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5392 QStringList orients;
5393 orients.append( tr( "SMESH_VERTICAL" ) );
5394 orients.append( tr( "SMESH_HORIZONTAL" ) );
5395 indices.clear(); indices.append( 0 ); indices.append( 1 );
5396 setPreferenceProperty( orient, "strings", orients );
5397 setPreferenceProperty( orient, "indexes", indices );
5399 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5400 setPreferenceProperty( posVSizeGr, "columns", 2 );
5401 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5402 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5403 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5404 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5405 setPreferenceProperty( xv, "step", 0.1 );
5406 setPreferenceProperty( xv, "min", 0.0 );
5407 setPreferenceProperty( xv, "max", 1.0 );
5408 setPreferenceProperty( yv, "step", 0.1 );
5409 setPreferenceProperty( yv, "min", 0.0 );
5410 setPreferenceProperty( yv, "max", 1.0 );
5411 setPreferenceProperty( wv, "step", 0.1 );
5412 setPreferenceProperty( wv, "min", 0.0 );
5413 setPreferenceProperty( wv, "max", 1.0 );
5414 setPreferenceProperty( hv, "min", 0.0 );
5415 setPreferenceProperty( hv, "max", 1.0 );
5416 setPreferenceProperty( hv, "step", 0.1 );
5418 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5419 setPreferenceProperty( posHSizeGr, "columns", 2 );
5420 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5421 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5422 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5423 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5424 setPreferenceProperty( xv, "min", 0.0 );
5425 setPreferenceProperty( xv, "max", 1.0 );
5426 setPreferenceProperty( xv, "step", 0.1 );
5427 setPreferenceProperty( xh, "min", 0.0 );
5428 setPreferenceProperty( xh, "max", 1.0 );
5429 setPreferenceProperty( xh, "step", 0.1 );
5430 setPreferenceProperty( yh, "min", 0.0 );
5431 setPreferenceProperty( yh, "max", 1.0 );
5432 setPreferenceProperty( yh, "step", 0.1 );
5433 setPreferenceProperty( wh, "min", 0.0 );
5434 setPreferenceProperty( wh, "max", 1.0 );
5435 setPreferenceProperty( wh, "step", 0.1 );
5436 setPreferenceProperty( hh, "min", 0.0 );
5437 setPreferenceProperty( hh, "max", 1.0 );
5438 setPreferenceProperty( hh, "step", 0.1 );
5440 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5441 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5442 setPreferenceProperty( distributionGr, "columns", 3 );
5444 types.append( tr( "SMESH_MONOCOLOR" ) );
5445 types.append( tr( "SMESH_MULTICOLOR" ) );
5446 indices.clear(); indices.append( 0 ); indices.append( 1 );
5447 setPreferenceProperty( coloringType, "strings", types );
5448 setPreferenceProperty( coloringType, "indexes", indices );
5449 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5453 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5455 if ( sect=="SMESH" ) {
5456 float sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5457 float aTol = 1.00000009999999;
5458 std::string aWarning;
5459 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5461 if ( name== "selection_object_color" ||
5462 name=="selection_element_color" ||
5463 name== "highlight_color" ||
5464 name=="selection_precision_node" ||
5465 name=="selection_precision_element" ||
5466 name=="selection_precision_object" )
5468 SMESH::UpdateSelectionProp( this );
5470 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5472 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5473 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5474 if ( sbX1+sbW > aTol ) {
5475 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5478 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5479 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5482 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5484 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5485 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5486 if ( sbY1 + sbH > aTol ) {
5487 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5488 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5489 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5492 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5494 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5495 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5496 if ( sbX1 + sbW > aTol ) {
5497 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5500 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5501 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5504 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5506 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5507 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5508 if ( sbY1 + sbH > aTol ) {
5509 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5512 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5513 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5516 else if ( name == "segmentation" )
5518 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5519 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5521 else if ( name == "nb_segments_per_edge" )
5523 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5524 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5526 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5528 QString val = aResourceMgr->stringValue( "SMESH", name );
5529 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5531 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5533 SMESH::UpdateFontProp( this );
5535 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5537 SMESH::UpdateFontProp( this );
5540 if ( aWarning.size() != 0 ) {
5541 aWarning += "The default values are applied instead.";
5542 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5543 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5544 QObject::tr(aWarning.c_str()));
5549 //================================================================================
5551 * \brief Update something in accordance with update flags
5552 * \param theFlags - update flags
5554 * Update viewer or/and object browser etc. in accordance with update flags ( see
5555 * LightApp_UpdateFlags enumeration ).
5557 //================================================================================
5558 void SMESHGUI::update( const int flags )
5560 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5561 SMESH::UpdateView();
5563 SalomeApp_Module::update( flags );
5566 //================================================================================
5568 * \brief Set default selection mode
5570 * SLOT called when operation committed. Sets default selection mode
5572 //================================================================================
5573 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5575 SVTK_ViewWindow* vtkWnd =
5576 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5578 vtkWnd->SetSelectionMode( ActorSelection );
5581 //================================================================================
5583 * \brief Set default selection mode
5585 * SLOT called when operation aborted. Sets default selection mode
5587 //================================================================================
5588 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5590 SVTK_ViewWindow* vtkWnd =
5591 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5593 vtkWnd->SetSelectionMode( ActorSelection );
5596 //================================================================================
5598 * \brief Creates operation with given identifier
5599 * \param id - identifier of operation to be started
5600 * \return Pointer on created operation or NULL if operation is not created
5602 * Virtual method redefined from the base class creates operation with given id.
5603 * It is called called automatically from startOperation method of base class.
5605 //================================================================================
5606 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5608 LightApp_Operation* op = 0;
5609 // to do : create operation here
5612 case SMESHOp::OpSplitBiQuadratic:
5613 op = new SMESHGUI_SplitBiQuadOp();
5615 case SMESHOp::OpConvertMeshToQuadratic:
5616 op = new SMESHGUI_ConvToQuadOp();
5618 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5619 op = new SMESHGUI_Make2DFrom3DOp();
5621 case SMESHOp::OpReorientFaces:
5622 op = new SMESHGUI_ReorientFacesOp();
5624 case SMESHOp::OpCreateMesh:
5625 op = new SMESHGUI_MeshOp( true, true );
5627 case SMESHOp::OpCreateSubMesh:
5628 op = new SMESHGUI_MeshOp( true, false );
5630 case SMESHOp::OpEditMeshOrSubMesh:
5631 case SMESHOp::OpEditMesh:
5632 case SMESHOp::OpEditSubMesh:
5633 op = new SMESHGUI_MeshOp( false );
5635 case SMESHOp::OpCompute:
5636 case SMESHOp::OpComputeSubMesh:
5637 op = new SMESHGUI_ComputeOp();
5639 case SMESHOp::OpPreCompute:
5640 op = new SMESHGUI_PrecomputeOp();
5642 case SMESHOp::OpEvaluate:
5643 op = new SMESHGUI_EvaluateOp();
5645 case SMESHOp::OpMeshOrder:
5646 op = new SMESHGUI_MeshOrderOp();
5648 case SMESHOp::OpCreateGeometryGroup:
5649 op = new SMESHGUI_GroupOnShapeOp();
5651 case SMESHOp::OpFindElementByPoint:
5652 op = new SMESHGUI_FindElemByPointOp();
5654 case SMESHOp::OpMoveNode: // Make mesh pass through point
5655 op = new SMESHGUI_MakeNodeAtPointOp();
5657 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5658 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5665 op = SalomeApp_Module::createOperation( id );
5669 //================================================================================
5671 * \brief Stops current operations and starts a given one
5672 * \param id - The id of the operation to start
5674 //================================================================================
5676 void SMESHGUI::switchToOperation(int id)
5678 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5679 activeStudy()->abortAllOperations();
5680 startOperation( id );
5683 LightApp_Displayer* SMESHGUI::displayer()
5686 myDisplayer = new SMESHGUI_Displayer( getApp() );
5690 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5693 int aTolerance = 64;
5694 int anIterations = 0;
5700 if( anIterations % aPeriod == 0 )
5703 if( aTolerance < 1 )
5707 aHue = (int)( 360.0 * rand() / RAND_MAX );
5710 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5711 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5712 for( ; it != itEnd; ++it )
5714 SALOMEDS::Color anAutoColor = *it;
5715 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5718 aQColor.getHsv( &h, &s, &v );
5719 if( abs( h - aHue ) < aTolerance )
5731 aColor.setHsv( aHue, 255, 255 );
5733 SALOMEDS::Color aSColor;
5734 aSColor.R = aColor.redF();
5735 aSColor.G = aColor.greenF();
5736 aSColor.B = aColor.blueF();
5741 const char* gSeparator = "_"; // character used to separate parameter names
5742 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5743 const char* gPathSep = "|"; // character used to separate paths
5746 * \brief Store visual parameters
5748 * This method is called just before the study document is saved.
5749 * Store visual parameters in AttributeParameter attribue(s)
5751 void SMESHGUI::storeVisualParameters (int savePoint)
5754 Kernel_Utils::Localizer loc;
5756 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5757 if (!appStudy || !appStudy->studyDS())
5759 _PTR(Study) studyDS = appStudy->studyDS();
5761 // componentName is used for encoding of entries when storing them in IParameters
5762 std::string componentName = myComponentSMESH->ComponentDataType();
5763 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5764 //if (!aSComponent) return;
5767 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5768 componentName.c_str(),
5770 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5772 // store map of custom markers
5773 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5774 if( !aMarkerMap.empty() )
5776 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5777 for( ; anIter != aMarkerMap.end(); anIter++ )
5779 int anId = anIter->first;
5780 VTK::MarkerData aMarkerData = anIter->second;
5781 std::string aMarkerFileName = aMarkerData.first;
5782 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5783 if( aMarkerTexture.size() < 3 )
5784 continue; // should contain at least width, height and the first value
5786 QString aPropertyName( "texture" );
5787 aPropertyName += gSeparator;
5788 aPropertyName += QString::number( anId );
5790 QString aPropertyValue = aMarkerFileName.c_str();
5791 aPropertyValue += gPathSep;
5793 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5794 ushort aWidth = *aTextureIter++;
5795 ushort aHeight = *aTextureIter++;
5796 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5797 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5798 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5799 aPropertyValue += QString::number( *aTextureIter );
5801 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5805 // viewers counters are used for storing view_numbers in IParameters
5808 // main cycle to store parameters of displayed objects
5809 QList<SUIT_ViewManager*> lst;
5810 QList<SUIT_ViewManager*>::Iterator it;
5811 getApp()->viewManagers(lst);
5812 for (it = lst.begin(); it != lst.end(); it++)
5814 SUIT_ViewManager* vman = *it;
5815 QString vType = vman->getType();
5817 // saving VTK actors properties
5818 if (vType == SVTK_Viewer::Type())
5820 // store the clipping planes attached to the view manager
5821 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5822 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5823 if( anIter != myClippingPlaneInfoMap.end() )
5824 aClippingPlaneInfoList = anIter->second;
5826 if( !aClippingPlaneInfoList.empty() ) {
5827 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5828 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5830 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5831 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5833 QString aPropertyName( "ClippingPlane" );
5834 aPropertyName += gSeparator;
5835 aPropertyName += QString::number( vtkViewers );
5836 aPropertyName += gSeparator;
5837 aPropertyName += QString::number( anId );
5839 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5840 aPropertyValue += gDigitsSep;
5841 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5842 aPropertyValue += gDigitsSep;
5843 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5844 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5845 aPropertyValue += gDigitsSep;
5846 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5847 aPropertyValue += gDigitsSep;
5848 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5849 aPropertyValue += gDigitsSep;
5850 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5851 aPropertyValue += gDigitsSep;
5852 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5853 aPropertyValue += gDigitsSep;
5854 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5855 aPropertyValue += gDigitsSep;
5856 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5858 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5859 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5860 aPropertyValue += gDigitsSep;
5861 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5862 aPropertyValue += gDigitsSep;
5863 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5864 aPropertyValue += gDigitsSep;
5865 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5868 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5872 QVector<SUIT_ViewWindow*> views = vman->getViews();
5873 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5875 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5877 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5878 vtkActorCollection* allActors = aCopy.GetActors();
5879 allActors->InitTraversal();
5880 while (vtkActor* actor = allActors->GetNextActor())
5882 if (actor->GetVisibility()) // store only visible actors
5884 SMESH_Actor* aSmeshActor = 0;
5885 if (actor->IsA("SMESH_Actor"))
5886 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5887 if (aSmeshActor && aSmeshActor->hasIO())
5889 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5892 // entry is "encoded" = it does NOT contain component address,
5893 // since it is a subject to change on next component loading
5894 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5896 std::string param, vtkParam = vType.toLatin1().data();
5897 vtkParam += gSeparator;
5898 vtkParam += QString::number(vtkViewers).toLatin1().data();
5899 vtkParam += gSeparator;
5902 param = vtkParam + "Visibility";
5903 ip->setParameter(entry, param, "On");
5906 param = vtkParam + "Representation";
5907 ip->setParameter(entry, param, QString::number
5908 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5911 param = vtkParam + "IsShrunk";
5912 ip->setParameter(entry, param, QString::number
5913 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5915 // Displayed entities
5916 unsigned int aMode = aSmeshActor->GetEntityMode();
5917 bool isE = aMode & SMESH_Actor::eEdges;
5918 bool isF = aMode & SMESH_Actor::eFaces;
5919 bool isV = aMode & SMESH_Actor::eVolumes;
5920 bool is0d = aMode & SMESH_Actor::e0DElements;
5921 bool isB = aMode & SMESH_Actor::eBallElem;
5923 QString modeStr ("e");
5924 modeStr += gDigitsSep; modeStr += QString::number(isE);
5925 modeStr += gDigitsSep; modeStr += "f";
5926 modeStr += gDigitsSep; modeStr += QString::number(isF);
5927 modeStr += gDigitsSep; modeStr += "v";
5928 modeStr += gDigitsSep; modeStr += QString::number(isV);
5929 modeStr += gDigitsSep; modeStr += "0d";
5930 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5931 modeStr += gDigitsSep; modeStr += "b";
5932 modeStr += gDigitsSep; modeStr += QString::number(isB);
5934 param = vtkParam + "Entities";
5935 ip->setParameter(entry, param, modeStr.toLatin1().data());
5941 aSmeshActor->GetSufaceColor(r, g, b, delta);
5942 QStringList colorStr;
5943 colorStr << "surface";
5944 colorStr << QString::number(r);
5945 colorStr << QString::number(g);
5946 colorStr << QString::number(b);
5948 colorStr << "backsurface";
5949 colorStr << QString::number(delta);
5951 aSmeshActor->GetVolumeColor(r, g, b, delta);
5952 colorStr << "volume";
5953 colorStr << QString::number(r);
5954 colorStr << QString::number(g);
5955 colorStr << QString::number(b);
5956 colorStr << QString::number(delta);
5958 aSmeshActor->GetEdgeColor(r, g, b);
5960 colorStr << QString::number(r);
5961 colorStr << QString::number(g);
5962 colorStr << QString::number(b);
5964 aSmeshActor->GetNodeColor(r, g, b);
5966 colorStr << QString::number(r);
5967 colorStr << QString::number(g);
5968 colorStr << QString::number(b);
5970 aSmeshActor->GetOutlineColor(r, g, b);
5971 colorStr << "outline";
5972 colorStr << QString::number(r);
5973 colorStr << QString::number(g);
5974 colorStr << QString::number(b);
5976 aSmeshActor->Get0DColor(r, g, b);
5977 colorStr << "elem0d";
5978 colorStr << QString::number(r);
5979 colorStr << QString::number(g);
5980 colorStr << QString::number(b);
5982 aSmeshActor->GetBallColor(r, g, b);
5984 colorStr << QString::number(r);
5985 colorStr << QString::number(g);
5986 colorStr << QString::number(b);
5988 aSmeshActor->GetFacesOrientationColor(r, g, b);
5989 colorStr << "orientation";
5990 colorStr << QString::number(r);
5991 colorStr << QString::number(g);
5992 colorStr << QString::number(b);
5994 param = vtkParam + "Colors";
5995 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5998 QStringList sizeStr;
6000 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6001 sizeStr << "outline";
6002 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6003 sizeStr << "elem0d";
6004 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6006 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6007 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6008 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6009 sizeStr << "shrink";
6010 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6011 sizeStr << "orientation";
6012 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6013 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6015 param = vtkParam + "Sizes";
6016 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6021 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6022 if( aMarkerType == VTK::MT_USER ) {
6023 markerStr += "custom";
6024 markerStr += gDigitsSep;
6025 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6029 markerStr += gDigitsSep;
6030 markerStr += QString::number( (int)aMarkerType );
6031 markerStr += gDigitsSep;
6032 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6035 param = vtkParam + "PointMarker";
6036 ip->setParameter(entry, param, markerStr.toLatin1().data());
6039 param = vtkParam + "Opacity";
6040 ip->setParameter(entry, param,
6041 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6044 param = vtkParam + "ClippingPlane";
6046 if( !aClippingPlaneInfoList.empty() ) {
6047 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6048 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6050 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6051 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6052 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6053 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6054 if( aSmeshActor == *anIter2 ) {
6055 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6056 QString::number( anId ).toLatin1().constData() );
6063 ip->setParameter( entry, param, "Off" );
6064 } // if (io->hasEntry())
6065 } // SMESH_Actor && hasIO
6067 } // while.. actors traversal
6071 } // if (SVTK view model)
6072 } // for (viewManagers)
6075 // data structures for clipping planes processing
6079 bool isOpenGLClipping;
6080 vtkIdType RelativeOrientation;
6083 int AbsoluteOrientation;
6084 double X, Y, Z, Dx, Dy, Dz;
6086 typedef std::list<TPlaneData> TPlaneDataList;
6087 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6089 typedef std::list<vtkActor*> TActorList;
6092 TActorList ActorList;
6093 SUIT_ViewManager* ViewManager;
6095 typedef std::list<TPlaneInfo> TPlaneInfoList;
6096 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6099 * \brief Restore visual parameters
6101 * This method is called after the study document is opened.
6102 * Restore visual parameters from AttributeParameter attribue(s)
6104 void SMESHGUI::restoreVisualParameters (int savePoint)
6107 Kernel_Utils::Localizer loc;
6109 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6110 if (!appStudy || !appStudy->studyDS())
6112 _PTR(Study) studyDS = appStudy->studyDS();
6114 // componentName is used for encoding of entries when storing them in IParameters
6115 std::string componentName = myComponentSMESH->ComponentDataType();
6116 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
6117 //if (!aSComponent) return;
6120 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6121 componentName.c_str(),
6123 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6125 // restore map of custom markers and map of clipping planes
6126 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
6127 TPlaneDataMap aPlaneDataMap;
6129 std::vector<std::string> properties = ip->getProperties();
6130 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6132 std::string property = *propIt;
6133 QString aPropertyName( property.c_str() );
6134 QString aPropertyValue( ip->getProperty( property ).c_str() );
6136 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6137 if( aPropertyNameList.isEmpty() )
6140 QString aPropertyType = aPropertyNameList[0];
6141 if( aPropertyType == "texture" )
6143 if( aPropertyNameList.size() != 2 )
6147 int anId = aPropertyNameList[1].toInt( &ok );
6148 if( !ok || anId < 1 )
6151 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6152 if( aPropertyValueList.size() != 2 )
6155 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6156 QString aMarkerTextureString = aPropertyValueList[1];
6157 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6158 if( aMarkerTextureStringList.size() != 3 )
6162 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6167 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6171 VTK::MarkerTexture aMarkerTexture;
6172 aMarkerTexture.push_back( aWidth );
6173 aMarkerTexture.push_back( aHeight );
6175 QString aMarkerTextureData = aMarkerTextureStringList[2];
6176 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6178 QChar aChar = aMarkerTextureData.at( i );
6179 if( aChar.isDigit() )
6180 aMarkerTexture.push_back( aChar.digitValue() );
6183 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6185 else if( aPropertyType == "ClippingPlane" )
6187 if( aPropertyNameList.size() != 3 )
6191 int aViewId = aPropertyNameList[1].toInt( &ok );
6192 if( !ok || aViewId < 0 )
6196 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6197 if( !ok || aClippingPlaneId < 0 )
6200 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6201 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6204 TPlaneData aPlaneData;
6205 aPlaneData.AbsoluteOrientation = false;
6206 aPlaneData.RelativeOrientation = 0;
6207 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6208 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6209 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6211 aPlaneData.Id = aClippingPlaneId;
6214 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6219 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6223 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6226 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6231 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6236 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6241 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6246 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6251 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6256 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6260 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6262 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6267 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6272 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6277 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6282 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6283 aPlaneDataList.push_back( aPlaneData );
6287 TPlaneInfoMap aPlaneInfoMap;
6289 std::vector<std::string> entries = ip->getEntries();
6291 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6293 // entry is a normal entry - it should be "decoded" (setting base address of component)
6294 QString entry (ip->decodeEntry(*entIt).c_str());
6296 // Check that the entry corresponds to a real object in the Study
6297 // as the object may be deleted or modified after the visual state is saved.
6298 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6299 if (!so) continue; //Skip the not existent entry
6301 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6302 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6304 std::vector<std::string>::iterator namesIt = paramNames.begin();
6305 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6307 // actors are stored in a map after displaying of them for
6308 // quicker access in the future: map < viewID to actor >
6309 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6311 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6313 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6314 // '_' is used as separator and should not be used in viewer type or parameter names.
6315 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6316 if (lst.size() != 3)
6319 QString viewerTypStr = lst[0];
6320 QString viewIndexStr = lst[1];
6321 QString paramNameStr = lst[2];
6324 int viewIndex = viewIndexStr.toUInt(&ok);
6325 if (!ok) // bad conversion of view index to integer
6329 if (viewerTypStr == SVTK_Viewer::Type())
6331 SMESH_Actor* aSmeshActor = 0;
6332 if (vtkActors.IsBound(viewIndex))
6333 aSmeshActor = vtkActors.Find(viewIndex);
6335 QList<SUIT_ViewManager*> lst;
6336 getApp()->viewManagers(viewerTypStr, lst);
6338 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6339 SUIT_ViewManager* vman = NULL;
6340 if (viewIndex >= 0 && viewIndex < lst.count())
6341 vman = lst.at(viewIndex);
6343 if (paramNameStr == "Visibility")
6345 if (!aSmeshActor && displayer() && vman)
6347 SUIT_ViewModel* vmodel = vman->getViewModel();
6348 // SVTK view model can be casted to SALOME_View
6349 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6351 // store displayed actor in a temporary map for quicker
6352 // access later when restoring other parameters
6353 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6354 vtkRenderer* Renderer = vtkView->getRenderer();
6355 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6356 vtkActorCollection* theActors = aCopy.GetActors();
6357 theActors->InitTraversal();
6358 bool isFound = false;
6359 vtkActor *ac = theActors->GetNextActor();
6360 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6361 if (ac->IsA("SMESH_Actor")) {
6362 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6363 if (aGeomAc->hasIO()) {
6364 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6365 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6367 vtkActors.Bind(viewIndex, aGeomAc);
6373 } // if (paramNameStr == "Visibility")
6376 // the rest properties "work" with SMESH_Actor
6379 QString val ((*valuesIt).c_str());
6382 if (paramNameStr == "Representation") {
6383 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6386 else if (paramNameStr == "IsShrunk") {
6388 if (!aSmeshActor->IsShrunk())
6389 aSmeshActor->SetShrink();
6392 if (aSmeshActor->IsShrunk())
6393 aSmeshActor->UnShrink();
6396 // Displayed entities
6397 else if (paramNameStr == "Entities") {
6398 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6399 int aEntityMode = SMESH_Actor::eAllEntity;
6400 for ( int i = 0; i < mode.count(); i+=2 ) {
6401 if ( i < mode.count()-1 ) {
6402 QString type = mode[i];
6403 bool val = mode[i+1].toInt();
6404 if ( type == "e" && !val )
6405 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6406 else if ( type == "f" && !val )
6407 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6408 else if ( type == "v" && !val )
6409 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6410 else if ( type == "0d" && !val )
6411 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6412 else if ( type == "b" && !val )
6413 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6416 aSmeshActor->SetEntityMode( aEntityMode );
6419 else if (paramNameStr == "Colors") {
6420 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6427 QColor outlineColor;
6428 QColor orientationColor;
6434 // below lines are required to get default values for delta coefficients
6435 // of backface color for faces and color of reversed volumes
6436 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6437 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6438 for ( int i = 0; i < colors.count(); i++ ) {
6439 QString type = colors[i];
6440 if ( type == "surface" ) {
6441 // face color is set by 3 values r:g:b, where
6442 // - r,g,b - is rgb color components
6443 if ( i+1 >= colors.count() ) break; // format error
6444 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6445 if ( i+2 >= colors.count() ) break; // format error
6446 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6447 if ( i+3 >= colors.count() ) break; // format error
6448 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6449 faceColor.setRgbF( r, g, b );
6452 else if ( type == "backsurface" ) {
6453 // backface color can be defined in several ways
6454 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6455 // - in latest versions, it is set as delta coefficient
6456 bool rgbOk = false, deltaOk;
6457 if ( i+1 >= colors.count() ) break; // format error
6458 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6459 int delta = colors[i+1].toInt( &deltaOk );
6461 if ( i+1 < colors.count() ) // index is shifted to 1
6462 g = colors[i+1].toDouble( &rgbOk );
6463 if ( rgbOk ) i++; // shift index
6464 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6465 b = colors[i+1].toDouble( &rgbOk );
6467 // - as currently there's no way to set directly backsurface color as it was before,
6468 // we ignore old dump where r,g,b triple was set
6469 // - also we check that delta parameter is set properly
6470 if ( !rgbOk && deltaOk )
6473 else if ( type == "volume" ) {
6474 // volume color is set by 4 values r:g:b:delta, where
6475 // - r,g,b - is a normal volume rgb color components
6476 // - delta - is a reversed volume color delta coefficient
6477 if ( i+1 >= colors.count() ) break; // format error
6478 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6479 if ( i+2 >= colors.count() ) break; // format error
6480 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6481 if ( i+3 >= colors.count() ) break; // format error
6482 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6483 if ( i+4 >= colors.count() ) break; // format error
6484 int delta = colors[i+4].toInt( &bOk );
6485 if ( !bOk ) break; // format error
6486 volumeColor.setRgbF( r, g, b );
6490 else if ( type == "edge" ) {
6491 // edge color is set by 3 values r:g:b, where
6492 // - r,g,b - is rgb color components
6493 if ( i+1 >= colors.count() ) break; // format error
6494 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6495 if ( i+2 >= colors.count() ) break; // format error
6496 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6497 if ( i+3 >= colors.count() ) break; // format error
6498 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6499 edgeColor.setRgbF( r, g, b );
6502 else if ( type == "node" ) {
6503 // node color is set by 3 values r:g:b, where
6504 // - r,g,b - is rgb color components
6505 if ( i+1 >= colors.count() ) break; // format error
6506 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6507 if ( i+2 >= colors.count() ) break; // format error
6508 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6509 if ( i+3 >= colors.count() ) break; // format error
6510 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6511 nodeColor.setRgbF( r, g, b );
6514 else if ( type == "elem0d" ) {
6515 // 0d element color is set by 3 values r:g:b, where
6516 // - r,g,b - is rgb color components
6517 if ( i+1 >= colors.count() ) break; // format error
6518 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6519 if ( i+2 >= colors.count() ) break; // format error
6520 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6521 if ( i+3 >= colors.count() ) break; // format error
6522 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6523 elem0dColor.setRgbF( r, g, b );
6526 else if ( type == "ball" ) {
6527 // ball color is set by 3 values r:g:b, where
6528 // - r,g,b - is rgb color components
6529 if ( i+1 >= colors.count() ) break; // format error
6530 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6531 if ( i+2 >= colors.count() ) break; // format error
6532 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6533 if ( i+3 >= colors.count() ) break; // format error
6534 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6535 ballColor.setRgbF( r, g, b );
6538 else if ( type == "outline" ) {
6539 // outline color is set by 3 values r:g:b, where
6540 // - r,g,b - is rgb color components
6541 if ( i+1 >= colors.count() ) break; // format error
6542 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6543 if ( i+2 >= colors.count() ) break; // format error
6544 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6545 if ( i+3 >= colors.count() ) break; // format error
6546 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6547 outlineColor.setRgbF( r, g, b );
6550 else if ( type == "orientation" ) {
6551 // orientation color is set by 3 values r:g:b, where
6552 // - r,g,b - is rgb color components
6553 if ( i+1 >= colors.count() ) break; // format error
6554 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6555 if ( i+2 >= colors.count() ) break; // format error
6556 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6557 if ( i+3 >= colors.count() ) break; // format error
6558 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6559 orientationColor.setRgbF( r, g, b );
6564 if ( nodeColor.isValid() )
6565 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6567 if ( edgeColor.isValid() )
6568 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6570 if ( faceColor.isValid() )
6571 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6573 if ( volumeColor.isValid() )
6574 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6575 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6576 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6578 if ( elem0dColor.isValid() )
6579 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6581 if ( ballColor.isValid() )
6582 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6584 if ( outlineColor.isValid() )
6585 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6586 // orientation color
6587 if ( orientationColor.isValid() )
6588 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6591 else if (paramNameStr == "Sizes") {
6592 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6595 int outlineWidth = -1;
6596 int elem0dSize = -1;
6597 //int ballSize = -1;
6598 double ballDiameter = -1.0;
6599 double ballScale = -1.0;
6600 double shrinkSize = -1;
6601 double orientationSize = -1;
6602 bool orientation3d = false;
6603 for ( int i = 0; i < sizes.count(); i++ ) {
6604 QString type = sizes[i];
6605 if ( type == "line" ) {
6606 // line (wireframe) width is given as single integer value
6607 if ( i+1 >= sizes.count() ) break; // format error
6608 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6612 if ( type == "outline" ) {
6613 // outline width is given as single integer value
6614 if ( i+1 >= sizes.count() ) break; // format error
6615 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6619 else if ( type == "elem0d" ) {
6620 // 0d element size is given as single integer value
6621 if ( i+1 >= sizes.count() ) break; // format error
6622 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6626 else if ( type == "ball" ) {
6627 // balls are specified by two values: size:scale, where
6628 // - size - is a integer value specifying size
6629 // - scale - is a double value specifying scale factor
6630 if ( i+1 >= sizes.count() ) break; // format error
6631 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6632 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6633 if ( i+2 >= sizes.count() ) break; // format error
6634 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6640 else if ( type == "shrink" ) {
6641 // shrink factor is given as single floating point value
6642 if ( i+1 >= sizes.count() ) break; // format error
6643 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6647 else if ( type == "orientation" ) {
6648 // orientation vectors are specified by two values size:3d, where
6649 // - size - is a floating point value specifying scale factor
6650 // - 3d - is a boolean
6651 if ( i+1 >= sizes.count() ) break; // format error
6652 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6653 if ( i+2 >= sizes.count() ) break; // format error
6654 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6655 orientationSize = v1;
6656 orientation3d = (bool)v2;
6660 // line (wireframe) width
6661 if ( lineWidth > 0 )
6662 aSmeshActor->SetLineWidth( lineWidth );
6664 if ( outlineWidth > 0 )
6665 aSmeshActor->SetOutlineWidth( outlineWidth );
6666 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6667 aSmeshActor->SetOutlineWidth( lineWidth );
6669 if ( elem0dSize > 0 )
6670 aSmeshActor->Set0DSize( elem0dSize );
6672 /*if ( ballSize > 0 )
6673 aSmeshActor->SetBallSize( ballSize );*/
6675 if ( ballDiameter > 0 )
6676 aSmeshActor->SetBallSize( ballDiameter );
6678 if ( ballScale > 0.0 )
6679 aSmeshActor->SetBallScale( ballScale );
6681 if ( shrinkSize > 0 )
6682 aSmeshActor->SetShrinkFactor( shrinkSize );
6683 // orientation vectors
6684 if ( orientationSize > 0 ) {
6685 aSmeshActor->SetFacesOrientationScale( orientationSize );
6686 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6690 else if (paramNameStr == "PointMarker") {
6691 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6692 if( data.count() >= 2 ) {
6694 int aParam1 = data[1].toInt( &ok );
6696 if( data[0] == "std" && data.count() == 3 ) {
6697 int aParam2 = data[2].toInt( &ok );
6698 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6700 else if( data[0] == "custom" ) {
6701 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6702 if( markerIt != aMarkerMap.end() ) {
6703 VTK::MarkerData aMarkerData = markerIt->second;
6704 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6711 else if (paramNameStr == "Opacity") {
6712 aSmeshActor->SetOpacity(val.toFloat());
6715 else if (paramNameStr.startsWith("ClippingPlane")) {
6716 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6717 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6718 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6719 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6720 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6721 // new format - val looks like "Off" or "0" (plane id)
6722 // (note: in new format "Off" value is used only for consistency,
6723 // so it is processed together with values in old format)
6724 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6725 if( anIsOldFormat ) {
6726 if (paramNameStr == "ClippingPlane1" || val == "Off")
6727 aSmeshActor->RemoveAllClippingPlanes();
6729 QList<SUIT_ViewManager*> lst;
6730 getApp()->viewManagers(viewerTypStr, lst);
6731 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6732 if (viewIndex >= 0 && viewIndex < lst.count()) {
6733 SUIT_ViewManager* vman = lst.at(viewIndex);
6734 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6736 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6738 SMESH::TActorList anActorList;
6739 anActorList.push_back( aSmeshActor );
6740 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6741 aPlane->myViewWindow = vtkView;
6742 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6743 aPlane->PlaneMode = aMode;
6744 bool isOpenGLClipping = ( bool )vals[1].toInt();
6745 aPlane->IsOpenGLClipping = isOpenGLClipping;
6746 if ( aMode == SMESH::Absolute ) {
6747 aPlane->myAbsoluteOrientation = vals[2].toInt();
6748 aPlane->X = vals[3].toFloat();
6749 aPlane->Y = vals[4].toFloat();
6750 aPlane->Z = vals[5].toFloat();
6751 aPlane->Dx = vals[6].toFloat();
6752 aPlane->Dy = vals[7].toFloat();
6753 aPlane->Dz = vals[8].toFloat();
6755 else if ( aMode == SMESH::Relative ) {
6756 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6757 aPlane->myDistance = vals[3].toFloat();
6758 aPlane->myAngle[0] = vals[4].toFloat();
6759 aPlane->myAngle[1] = vals[5].toFloat();
6763 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6764 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6765 aClippingPlaneInfo.Plane = aPlane;
6766 aClippingPlaneInfo.ActorList = anActorList;
6767 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6775 int aPlaneId = val.toInt( &ok );
6776 if( ok && aPlaneId >= 0 ) {
6777 bool anIsDefinedPlane = false;
6778 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6779 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6780 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6781 TPlaneInfo& aPlaneInfo = *anIter;
6782 if( aPlaneInfo.PlaneId == aPlaneId ) {
6783 aPlaneInfo.ActorList.push_back( aSmeshActor );
6784 anIsDefinedPlane = true;
6788 if( !anIsDefinedPlane ) {
6789 TPlaneInfo aPlaneInfo;
6790 aPlaneInfo.PlaneId = aPlaneId;
6791 aPlaneInfo.ActorList.push_back( aSmeshActor );
6792 aPlaneInfo.ViewManager = vman;
6794 // to make the list sorted by plane id
6795 anIter = aPlaneInfoList.begin();
6796 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6797 const TPlaneInfo& aPlaneInfoRef = *anIter;
6798 if( aPlaneInfoRef.PlaneId > aPlaneId )
6801 aPlaneInfoList.insert( anIter, aPlaneInfo );
6806 } // if (aSmeshActor)
6807 } // other parameters than Visibility
6809 } // for names/parameters iterator
6810 } // for entries iterator
6812 // take into account planes with empty list of actors referred to them
6813 QList<SUIT_ViewManager*> aVMList;
6814 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6816 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6817 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6818 int aViewId = aPlaneDataIter->first;
6819 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6820 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6822 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6824 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6825 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6826 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6827 const TPlaneData& aPlaneData = *anIter2;
6828 int aPlaneId = aPlaneData.Id;
6830 bool anIsFound = false;
6831 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6832 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6833 const TPlaneInfo& aPlaneInfo = *anIter3;
6834 if( aPlaneInfo.PlaneId == aPlaneId ) {
6841 TPlaneInfo aPlaneInfo; // ActorList field is empty
6842 aPlaneInfo.PlaneId = aPlaneId;
6843 aPlaneInfo.ViewManager = aViewManager;
6845 // to make the list sorted by plane id
6846 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6847 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6848 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6849 if( aPlaneInfoRef.PlaneId > aPlaneId )
6852 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6858 // add clipping planes to actors according to the restored parameters
6859 // and update the clipping plane map
6860 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6861 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6862 int aViewId = anIter1->first;
6863 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6865 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6866 if( anIter2 == aPlaneDataMap.end() )
6868 const TPlaneDataList& aPlaneDataList = anIter2->second;
6870 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6871 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6872 const TPlaneInfo& aPlaneInfo = *anIter3;
6873 int aPlaneId = aPlaneInfo.PlaneId;
6874 const TActorList& anActorList = aPlaneInfo.ActorList;
6875 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6879 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6883 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6885 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6886 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6887 const TPlaneData& aPlaneData = *anIter4;
6888 if( aPlaneData.Id == aPlaneId ) {
6889 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6890 aPlane->myViewWindow = aViewWindow;
6891 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6892 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6893 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6894 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6895 aPlane->X = aPlaneData.X;
6896 aPlane->Y = aPlaneData.Y;
6897 aPlane->Z = aPlaneData.Z;
6898 aPlane->Dx = aPlaneData.Dx;
6899 aPlane->Dy = aPlaneData.Dy;
6900 aPlane->Dz = aPlaneData.Dz;
6902 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6903 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6904 aPlane->myDistance = aPlaneData.Distance;
6905 aPlane->myAngle[0] = aPlaneData.Angle[0];
6906 aPlane->myAngle[1] = aPlaneData.Angle[1];
6909 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6910 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6911 aClippingPlaneInfo.Plane = aPlane;
6912 aClippingPlaneInfo.ActorList = anActorList;
6913 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6924 // update all VTK views
6925 QList<SUIT_ViewManager*> lst;
6926 getApp()->viewManagers(lst);
6927 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6928 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6929 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6930 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6931 // set OpenGL clipping planes
6932 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6933 vtkActorCollection* anAllActors = aCopy.GetActors();
6934 anAllActors->InitTraversal();
6935 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6936 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6937 anActor->SetOpenGLClippingPlane();
6939 vtkView->getRenderer()->ResetCameraClippingRange();
6946 \brief Adds preferences for dfont of VTK viewer
6948 \param pIf group identifier
6949 \param param parameter
6950 \return identifier of preferences
6952 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6954 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6956 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6959 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6960 fam.append( tr( "SMESH_FONT_COURIER" ) );
6961 fam.append( tr( "SMESH_FONT_TIMES" ) );
6963 setPreferenceProperty( tfont, "fonts", fam );
6965 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6966 if ( needSize ) f = f | QtxFontEdit::Size;
6967 setPreferenceProperty( tfont, "features", f );
6973 \brief Actions after hypothesis edition
6974 Updates object browser after hypothesis edition
6976 void SMESHGUI::onHypothesisEdit( int result )
6979 SMESHGUI::Modified();
6980 updateObjBrowser( true );
6984 \brief Actions after choosing menu of control modes
6985 Updates control mode actions according to current selection
6987 void SMESHGUI::onUpdateControlActions()
6989 SALOME_ListIO selected;
6990 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
6991 aSel->selectedObjects( selected );
6993 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
6994 if ( selected.Extent() ) {
6995 if ( selected.First()->hasEntry() ) {
6996 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
6997 aControl = anActor->GetControlMode();
6998 SALOME_ListIteratorOfListIO it(selected);
6999 for ( it.Next(); it.More(); it.Next() ) {
7000 Handle(SALOME_InteractiveObject) anIO = it.Value();
7001 if ( anIO->hasEntry() ) {
7002 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7003 if ( aControl != anActor->GetControlMode() ) {
7004 aControl = SMESH_Actor::eNone;
7014 int anAction = ActionToControl( aControl, true );
7016 action( anAction )->setChecked( true );
7018 QMenu* send = (QMenu*)sender();
7019 QList<QAction*> actions = send->actions();
7020 for ( int i = 0; i < actions.size(); i++ )
7021 actions[i]->setChecked( false );
7027 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7028 \param pview view being closed
7030 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7031 #ifndef DISABLE_PLOT2DVIEWER
7032 //Crear all Plot2d Viewers if need.
7033 SMESH::ClearPlot2Viewers(pview);
7035 EmitSignalCloseView();
7038 void SMESHGUI::message( const QString& msg )
7041 QStringList data = msg.split("/");
7042 if ( data.count() > 0 ) {
7043 if ( data.first() == "mesh_loading" ) {
7045 QString entry = data.count() > 1 ? data[1] : QString();
7046 if ( entry.isEmpty() )
7049 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7051 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
7054 name = SMESH::fromUtf8(obj->GetName());
7055 if ( name.isEmpty() )
7058 if ( data.last() == "stop" )
7059 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7061 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7062 QApplication::processEvents();
7068 \brief Connects or disconnects signals about activating and cloning view on the module slots
7069 \param pview view which is connected/disconnected
7071 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7075 SUIT_ViewManager* viewMgr = pview->getViewManager();
7077 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7078 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7080 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7081 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7086 \brief Return \c true if object can be renamed
7088 bool SMESHGUI::renameAllowed( const QString& entry) const {
7089 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7093 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7097 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7102 if(appStudy->isComponent(entry) || obj->isReference())
7105 // check type to prevent renaming of inappropriate objects
7106 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
7107 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7108 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7109 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7110 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7111 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7118 Rename object by entry.
7119 \param entry entry of the object
7120 \param name new name of the object
7121 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7123 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7125 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7129 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7134 _PTR(Study) aStudy = appStudy->studyDS();
7139 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7141 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7146 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7147 _PTR(GenericAttribute) anAttr;
7148 _PTR(AttributeName) aName;
7150 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7152 // check type to prevent renaming of inappropriate objects
7153 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
7154 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7155 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7156 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7157 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7158 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7159 if ( !name.isEmpty() ) {
7160 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
7162 // update name of group object and its actor
7163 Handle(SALOME_InteractiveObject) IObject =
7164 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7166 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7167 if( !aGroupObject->_is_nil() ) {
7168 aGroupObject->SetName( qPrintable(name) );
7169 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7170 anActor->setName( qPrintable(name) );
7180 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7182 static QList<QColor> colors;
7184 if ( colors.isEmpty() ) {
7186 for (int s = 0; s < 2 ; s++)
7188 for (int v = 100; v >= 40; v = v - 20)
7190 for (int h = 0; h < 359 ; h = h + 60)
7192 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7197 static int currentColor = randomize( colors.size() );
7199 SALOMEDS::Color color;
7200 color.R = (double)colors[currentColor].red() / 255.0;
7201 color.G = (double)colors[currentColor].green() / 255.0;
7202 color.B = (double)colors[currentColor].blue() / 255.0;
7204 currentColor = (currentColor+1) % colors.count();