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)
149 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
150 #include <QApplication>
152 #include <QTextStream>
157 #include <QDialogButtonBox>
160 #include <boost/shared_ptr.hpp>
163 #include <vtkCallbackCommand.h>
164 #include <vtkCamera.h>
165 #include <vtkLookupTable.h>
166 #include <vtkPlane.h>
167 #include <vtkRenderer.h>
169 // SALOME KERNEL includes
170 #include <SALOMEDSClient_ClientFactory.hxx>
171 #include <SALOMEDSClient_IParameters.hxx>
172 #include <SALOMEDSClient_SComponent.hxx>
173 #include <SALOMEDSClient_StudyBuilder.hxx>
174 #include <SALOMEDS_Study.hxx>
175 #include <SALOMEDS_SObject.hxx>
176 #include "utilities.h"
179 #include <Standard_ErrorHandler.hxx>
180 #include <NCollection_DataMap.hxx>
181 #include <NCollection_DoubleMap.hxx>
183 #include <Basics_Utils.hxx>
185 // Below macro, when uncommented, switches on simplified (more performant) algorithm
186 // of auto-color picking up
187 #define SIMPLE_AUTOCOLOR
192 //=============================================================
193 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
196 void ExportMeshToFile(int theCommandID);
198 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
200 void SetDisplayEntity(int theCommandID);
202 int ActionToControl( int theID, bool theReversed = false );
204 void Control( int theCommandID );
207 //================================================================================
209 * \brief Reads meshes from file
211 //================================================================================
213 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
217 std::string myExtension;
219 if ( theCommandID == SMESHOp::OpImportMED ) {
220 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
221 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
223 else if ( theCommandID == SMESHOp::OpImportUNV ) {
224 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
226 else if ( theCommandID == SMESHOp::OpImportDAT ) {
227 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
229 else if ( theCommandID == SMESHOp::OpImportSTL ) {
230 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
233 else if ( theCommandID == SMESHOp::OpImportCGNS ) {
234 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
237 else if ( theCommandID == SMESHOp::OpImportSAUV ) {
238 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
239 filter.append( QObject::tr( "All files (*)" ) );
241 else if ( theCommandID == SMESHOp::OpImportGMF ) {
242 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
243 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
246 QString anInitialPath = "";
247 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
248 anInitialPath = QDir::currentPath();
250 QStringList filenames;
251 bool toCreateGroups = true;
253 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
254 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
255 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
256 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
257 // fd->setNameFilters( filter );
258 // fd->SetChecked( true );
260 // filenames << fd->selectedFile();
261 // toCreateGroups = fd->IsChecked();
267 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
270 QObject::tr( "SMESH_IMPORT_MESH" ) );
272 if ( filenames.count() > 0 )
274 SUIT_OverrideCursor wc;
275 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
278 QStringList anEntryList;
279 bool isEmpty = false;
280 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
282 QString filename = *it;
283 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
285 switch ( theCommandID ) {
286 case SMESHOp::OpImportDAT:
288 // DAT format (currently unsupported)
289 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
290 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
293 case SMESHOp::OpImportUNV:
296 aMeshes->length( 1 );
297 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
298 if ( aMeshes[0]->_is_nil() )
299 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
300 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
303 case SMESHOp::OpImportMED:
306 SMESH::DriverMED_ReadStatus res;
307 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
308 if ( res != SMESH::DRS_OK ) {
309 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
310 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
314 case SMESHOp::OpImportSTL:
317 aMeshes->length( 1 );
318 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
319 if ( aMeshes[0]->_is_nil() ) {
320 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
321 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
326 case SMESHOp::OpImportCGNS:
329 SMESH::DriverMED_ReadStatus res;
330 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
331 if ( res != SMESH::DRS_OK ) {
332 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
333 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
338 case SMESHOp::OpImportSAUV:
341 SMESH::DriverMED_ReadStatus res;
342 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
343 if ( res != SMESH::DRS_OK ) {
344 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
345 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
349 case SMESHOp::OpImportGMF:
352 SMESH::ComputeError_var res;
353 aMeshes->length( 1 );
354 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
357 if ( res->code != SMESH::DRS_OK ) {
358 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
359 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
360 if ( strlen( res->comment.in() ) > 0 ) {
361 errors.back() += ": ";
362 errors.back() += res->comment.in();
369 catch ( const SALOME::SALOME_Exception& S_ex ) {
370 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
371 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
374 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
376 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
378 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
379 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
380 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
381 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
382 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
384 anEntryList.append( aMeshSO->GetID().c_str() );
392 // update Object browser
393 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
395 // browse to the published meshes
396 if( LightApp_Application* anApp =
397 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
398 anApp->browseObjects( anEntryList );
400 // show Error message box if there were errors
401 if ( errors.count() > 0 ) {
402 SUIT_MessageBox::critical( SMESHGUI::desktop(),
403 QObject::tr( "SMESH_ERROR" ),
404 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
407 // show warning message box, if some imported mesh is empty
409 SUIT_MessageBox::warning( SMESHGUI::desktop(),
410 QObject::tr( "SMESH_WRN_WARNING" ),
411 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
416 //================================================================================
418 * \brief Export selected meshes or groups into a file
420 //================================================================================
422 void ExportMeshToFile( int theCommandID )
424 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
425 SALOME_ListIO selected;
427 aSel->selectedObjects( selected );
429 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
430 theCommandID == SMESHOp::OpPopupExportDAT );
431 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
432 theCommandID == SMESHOp::OpPopupExportMED );
433 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
434 theCommandID == SMESHOp::OpPopupExportUNV );
435 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
436 theCommandID == SMESHOp::OpPopupExportSTL );
438 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
439 theCommandID == SMESHOp::OpPopupExportCGNS );
441 const bool isCGNS= false;
443 const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV ||
444 theCommandID == SMESHOp::OpPopupExportSAUV );
445 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
446 theCommandID == SMESHOp::OpPopupExportGMF );
448 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
449 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
451 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
452 bool aCheckWarn = true;
454 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
455 // get mesh object from selection and check duplication of their names
456 bool hasDuplicatedMeshNames = false;
457 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
458 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
459 SALOME_ListIteratorOfListIO It( selected );
460 for( ; It.More(); It.Next() )
462 Handle(SALOME_InteractiveObject) anIObject = It.Value();
463 SMESH::SMESH_IDSource_var aMeshItem =
464 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
465 if ( aMeshItem->_is_nil() ) {
466 SUIT_MessageBox::warning( SMESHGUI::desktop(),
467 QObject::tr( "SMESH_WRN_WARNING" ),
468 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
471 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
472 if ( aCheckWarn && !aGroup->_is_nil() ) {
473 QMessageBox msgBox(SUIT_MessageBox::Warning,QObject::tr("SMESH_WRN_WARNING"),
474 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),QMessageBox::StandardButton::NoButton, SMESHGUI::desktop());
475 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
476 msgBox.addButton(QMessageBox::Ok);
477 msgBox.addButton(QMessageBox::Cancel);
478 msgBox.setDefaultButton(QMessageBox::Cancel);
479 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
480 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
481 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
482 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
483 if(msgBox.exec() == QMessageBox::Ok)
485 if(dontShowCheckBox.checkState() == Qt::Checked)
488 resMgr->setValue( "SMESH", "show_warning", false);
496 QString aMeshName = anIObject->getName();
498 // check for name duplications
499 if ( !hasDuplicatedMeshNames )
500 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
501 if( aMeshName == (*aMeshIter).second ) {
502 hasDuplicatedMeshNames = true;
507 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
510 if( hasDuplicatedMeshNames && isMED ) {
511 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
512 QObject::tr("SMESH_WRN_WARNING"),
513 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
514 QObject::tr("SMESH_BUT_YES"),
515 QObject::tr("SMESH_BUT_NO"), 0, 1);
520 aMeshIter = aMeshList.begin();
521 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
522 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
523 QString aMeshName = (*aMeshIter).second;
525 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
527 // check for equal group names within each mesh
528 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
529 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
530 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
531 int aRet = SUIT_MessageBox::warning
532 (SMESHGUI::desktop(),
533 QObject::tr("SMESH_WRN_WARNING"),
534 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
535 QObject::tr("SMESH_BUT_YES"),
536 QObject::tr("SMESH_BUT_NO"), 0, 1);
543 // Warn the user about presence of not supported elements
545 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
549 notSupportedElemTypes.push_back( SMESH::Entity_0D );
550 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
555 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
556 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
557 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
558 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
559 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
560 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
561 notSupportedElemTypes.push_back( SMESH::Entity_0D );
562 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
567 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
568 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
569 notSupportedElemTypes.push_back( SMESH::Entity_0D );
570 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
575 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
580 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
581 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
582 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
583 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
584 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
585 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
586 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
587 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
592 notSupportedElemTypes.push_back( SMESH::Entity_0D );
593 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
594 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
595 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
596 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
597 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
598 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
599 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
600 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
602 if ( ! notSupportedElemTypes.empty() )
604 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
605 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
606 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
607 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
609 if ( !presentNotSupported.empty() )
612 const char* typeMsg[] = {
613 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
614 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
615 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
616 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
617 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
618 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
619 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
620 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
622 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
623 const int nbTypes = sizeof( typeMsg ) / sizeof( const char* );
624 int _assert[( nbTypes == SMESH::Entity_Last ) ? 2 : -1 ]; _assert[0]=_assert[1];
626 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
627 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
628 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
629 if ( iType != presentNotSupported.size() - 1 )
630 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
632 int aRet = SUIT_MessageBox::warning
633 (SMESHGUI::desktop(),
634 QObject::tr("SMESH_WRN_WARNING"),
635 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
636 QObject::tr("SMESH_BUT_YES"),
637 QObject::tr("SMESH_BUT_NO"), 0, 1);
642 // Get parameters of export operation
645 SMESH::MED_VERSION aFormat = SMESH::MED_V2_2;
646 // Init the parameters with the default values
647 bool aIsASCII_STL = true;
648 bool toCreateGroups = false;
650 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
651 bool toOverwrite = true;
652 bool toFindOutDim = true;
654 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
655 QString anInitialPath = "";
656 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
657 anInitialPath = QDir::currentPath();
659 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
661 // Get a file name to write in and additional otions
662 if ( isUNV || isDAT || isGMF ) // Export w/o options
665 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
667 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
669 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
670 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
671 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
672 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
673 anInitialPath + QString("/") + aMeshName,
674 aFilter, aTitle, false);
676 else if ( isCGNS )// Export to CGNS
678 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
679 fd->setWindowTitle( aTitle );
680 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
681 if ( !anInitialPath.isEmpty() )
682 fd->setDirectory( anInitialPath );
683 fd->selectFile(aMeshName);
684 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
685 fd->setValidator( fv );
688 aFilename = fd->selectedFile();
689 toOverwrite = fv->isOverwrite();
693 else if ( isSTL ) // Export to STL
695 QMap<QString, int> aFilterMap;
696 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
697 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
700 QMap<QString, int>::const_iterator it = aFilterMap.begin();
701 for ( ; it != aFilterMap.end(); ++it )
702 filters.push_back( it.key() );
704 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
705 fd->setWindowTitle( aTitle );
706 fd->setNameFilters( filters );
707 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
708 if ( !anInitialPath.isEmpty() )
709 fd->setDirectory( anInitialPath );
710 fd->selectFile(aMeshName);
714 aFilename = fd->selectedFile();
715 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
720 else if ( isMED || isSAUV ) // Export to MED or SAUV
722 QMap<QString, SMESH::MED_VERSION> aFilterMap;
723 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
725 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
726 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
727 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
730 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
731 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
732 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
736 QString aDefaultFilter;
737 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
738 for ( ; it != aFilterMap.end(); ++it ) {
739 filters.push_back( it.key() );
740 if (it.value() == SMESH::MED_V2_2)
741 aDefaultFilter = it.key();
743 QStringList checkBoxes;
744 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
746 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
747 QList< QWidget* > wdgList;
748 if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList ))
749 wdgList.append( fieldSelWdg );
751 SalomeApp_CheckFileDlg* fd =
752 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
753 fd->setWindowTitle( aTitle );
754 fd->setNameFilters( filters );
755 fd->selectNameFilter( aDefaultFilter );
756 fd->SetChecked( toCreateGroups, 0 );
757 fd->SetChecked( toFindOutDim, 1 );
758 if ( !anInitialPath.isEmpty() )
759 fd->setDirectory( anInitialPath );
760 fd->selectFile(aMeshName);
763 QListView *lview = fd->findChild<QListView*>("listView");
765 lview->setMinimumHeight(200);
767 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
769 tview->setMinimumHeight(200);
772 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
773 fd->setValidator( fv );
778 aFilename = fd->selectedFile();
780 aFilename = QString::null;
783 aFormat = aFilterMap[fd->selectedNameFilter()];
784 toOverwrite = fv->isOverwrite();
786 if ( !aFilename.isEmpty() ) {
787 // med-2.1 does not support poly elements
788 if ( aFormat==SMESH::MED_V2_1 )
789 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
790 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
791 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
792 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
793 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
795 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
796 QObject::tr("SMESH_WRN_WARNING"),
797 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
798 QObject::tr("SMESH_BUT_YES"),
799 QObject::tr("SMESH_BUT_NO"), 0, 1);
807 // can't append to an existing using other format
808 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
809 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
810 if( !isVersionOk || aVersion != aFormat ) {
811 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
812 QObject::tr("SMESH_WRN_WARNING"),
813 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
814 QObject::tr("SMESH_BUT_YES"),
815 QObject::tr("SMESH_BUT_NO"), 0, 1);
822 QStringList aMeshNamesCollisionList;
823 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
824 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
825 QString anExistingMeshName( aMeshNames[ i ] );
826 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
827 QString anExportMeshName = (*aMeshIter).second;
828 if( anExportMeshName == anExistingMeshName ) {
829 aMeshNamesCollisionList.append( anExportMeshName );
834 if( !aMeshNamesCollisionList.isEmpty() ) {
835 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
836 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
837 QObject::tr("SMESH_WRN_WARNING"),
838 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
839 QObject::tr("SMESH_BUT_YES"),
840 QObject::tr("SMESH_BUT_NO"),
841 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
850 toCreateGroups = fd->IsChecked(0);
851 toFindOutDim = fd->IsChecked(1);
852 fieldSelWdg->GetSelectedFeilds();
853 if ( !fieldSelWdg->parent() )
864 if ( !aFilename.isEmpty() ) {
865 // Check whether the file already exists and delete it if yes
866 QFile aFile( aFilename );
867 if ( aFile.exists() && toOverwrite )
869 SUIT_OverrideCursor wc;
872 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
873 // bool Renumber = false;
874 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
876 // Renumber= resMgr->booleanValue("renumbering");
878 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
879 // aMeshEditor->RenumberNodes();
880 // aMeshEditor->RenumberElements();
881 // if ( SMESHGUI::automaticUpdate() )
882 // SMESH::UpdateView();
886 aMeshIter = aMeshList.begin();
887 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
889 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
890 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
891 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
892 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
893 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
894 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
895 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
896 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
898 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
899 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
900 fields, geoAssFields.toLatin1().data() );
905 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
907 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
908 if( !aMeshItem->_is_nil() )
909 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
914 if ( aMeshOrGroup->_is_equivalent( aMesh ))
915 aMesh->ExportDAT( aFilename.toUtf8().data() );
917 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
921 if ( aMeshOrGroup->_is_equivalent( aMesh ))
922 aMesh->ExportUNV( aFilename.toUtf8().data() );
924 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
928 if ( aMeshOrGroup->_is_equivalent( aMesh ))
929 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
931 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
935 aMeshIter = aMeshList.begin();
936 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
938 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
939 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
940 aMeshItem->ExportCGNS( aMeshOrGroup,
941 aFilename.toUtf8().data(),
942 toOverwrite && aMeshIndex == 0 );
947 toCreateGroups = true;
948 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
951 catch (const SALOME::SALOME_Exception& S_ex){
953 SUIT_MessageBox::warning(SMESHGUI::desktop(),
954 QObject::tr("SMESH_WRN_WARNING"),
955 QObject::tr("SMESH_EXPORT_FAILED"));
961 inline void InverseEntityMode(unsigned int& theOutputMode,
962 unsigned int theMode)
964 bool anIsNotPresent = ~theOutputMode & theMode;
966 theOutputMode |= theMode;
968 theOutputMode &= ~theMode;
971 void SetDisplayEntity(int theCommandID)
973 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
974 SALOME_ListIO selected;
976 aSel->selectedObjects( selected );
978 if ( selected.Extent() >= 1 ) {
979 SUIT_OverrideCursor wc;
980 SALOME_ListIteratorOfListIO It( selected );
981 for( ; It.More(); It.Next()){
982 Handle(SALOME_InteractiveObject) IObject = It.Value();
983 if(IObject->hasEntry()){
984 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
985 unsigned int aMode = anActor->GetEntityMode();
986 switch(theCommandID){
987 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
988 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
989 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
990 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
991 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
992 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
995 anActor->SetEntityMode(aMode);
1004 SalomeApp_Application* app =
1005 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1009 LightApp_SelectionMgr* aSel = app->selectionMgr();
1010 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1011 if ( !aSel || !appStudy )
1014 SALOME_ListIO selected;
1015 aSel->selectedObjects( selected );
1016 if ( selected.IsEmpty() )
1019 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1021 _PTR(Study) aStudy = appStudy->studyDS();
1022 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1023 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1024 if ( aMainObject->_is_nil() )
1027 SUIT_OverrideCursor wc;
1029 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1031 QList<SALOMEDS::Color> aReservedColors;
1033 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1034 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1036 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1038 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1039 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1040 #else // old algorithm for auto-colors
1041 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1042 aReservedColors.append( aColor );
1043 #endif // SIMPLE_AUTOCOLOR
1044 aGroupObject->SetColor( aColor );
1046 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1047 if ( aGroupSObject ) {
1050 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1051 switch ( aGroupObject->GetType ()) {
1053 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1055 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1057 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1059 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1061 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1062 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1065 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1066 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1072 SMESH::RepaintCurrentView();
1075 void OverallMeshQuality()
1077 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1078 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1079 SALOME_ListIO selected;
1081 aSel->selectedObjects( selected );
1083 if ( selected.IsEmpty() ) return;
1084 SALOME_ListIteratorOfListIO It( selected );
1085 for ( ; It.More(); It.Next() ) {
1086 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1087 ctrlDlg->showInfo( It.Value() );
1092 QString functorToString( SMESH::Controls::FunctorPtr f )
1094 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1095 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1096 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1097 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1098 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1099 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1100 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1101 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1102 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1103 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1104 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1105 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1106 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1107 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1108 type = QObject::tr( "WARP_ELEMENTS" );
1109 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1110 type = QObject::tr( "TAPER_ELEMENTS" );
1111 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1112 type = QObject::tr( "SKEW_ELEMENTS" );
1113 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1114 type = QObject::tr( "AREA_ELEMENTS" );
1115 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1116 type = QObject::tr( "LENGTH_EDGES" );
1117 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1118 type = QObject::tr( "LENGTH2D_EDGES" );
1119 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1120 type = QObject::tr( "DEFLECTION2D_FACES" );
1121 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1122 type = QObject::tr( "MULTI_BORDERS" );
1123 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1124 type = QObject::tr( "MULTI2D_BORDERS" );
1125 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1126 type = QObject::tr( "FREE_NODES" );
1127 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1128 type = QObject::tr( "FREE_EDGES" );
1129 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1130 type = QObject::tr( "FREE_BORDERS" );
1131 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1132 type = QObject::tr( "FREE_FACES" );
1133 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1134 type = QObject::tr( "BARE_BORDER_VOLUME" );
1135 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1136 type = QObject::tr( "BARE_BORDER_FACE" );
1137 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1138 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1139 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1140 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1141 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1142 type = QObject::tr( "EQUAL_NODE" );
1143 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1144 type = QObject::tr( "EQUAL_EDGE" );
1145 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1146 type = QObject::tr( "EQUAL_FACE" );
1147 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1148 type = QObject::tr( "EQUAL_VOLUME" );
1149 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1150 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1154 void SaveDistribution()
1156 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1157 SALOME_ListIO selected;
1159 aSel->selectedObjects( selected );
1161 if ( selected.Extent() == 1 ) {
1162 Handle(SALOME_InteractiveObject) anIO = selected.First();
1163 if ( anIO->hasEntry() ) {
1164 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1166 anActor->GetScalarBarActor() &&
1167 anActor->GetControlMode() != SMESH_Actor::eNone )
1169 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1170 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1171 if ( aScalarBarActor && aFunctor ) {
1172 SMESH::Controls::NumericalFunctor* aNumFun =
1173 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1175 std::vector<int> elements;
1176 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1177 if ( mesh->_is_nil() ) {
1178 SMESH::SMESH_IDSource_var idSource =
1179 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1180 if ( !idSource->_is_nil() )
1182 SMESH::long_array_var ids = idSource->GetIDs();
1183 elements.resize( ids->length() );
1184 for ( unsigned i = 0; i < elements.size(); ++i )
1185 elements[i] = ids[i];
1188 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1189 vtkLookupTable* lookupTable =
1190 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1191 double * minmax = lookupTable->GetRange();
1192 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1193 std::vector<int> nbEvents;
1194 std::vector<double> funValues;
1195 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1196 elements, minmax, isLogarithmic );
1197 QString anInitialPath = "";
1198 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1199 anInitialPath = QDir::currentPath();
1200 QString aMeshName = anIO->getName();
1202 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1203 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1204 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1205 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1206 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1209 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1211 if ( !aFilename.isEmpty() ) {
1212 QFile f( aFilename );
1213 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1214 QTextStream out( &f );
1215 out << "# Mesh: " << aMeshName << endl;
1216 out << "# Control: " << functorToString( aFunctor ) << endl;
1218 out.setFieldWidth( 10 );
1219 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1220 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1231 void ShowElement( int theCommandID )
1233 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1234 SALOME_ListIO selected;
1236 aSel->selectedObjects( selected );
1238 if ( selected.Extent() == 1 ) {
1239 Handle(SALOME_InteractiveObject) anIO = selected.First();
1240 if ( anIO->hasEntry() ) {
1241 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1243 anActor->GetScalarBarActor() &&
1244 anActor->GetControlMode() != SMESH_Actor::eNone )
1246 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1247 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1248 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1250 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1251 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1258 #ifndef DISABLE_PLOT2DVIEWER
1259 void PlotDistribution()
1261 SalomeApp_Application* app =
1262 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1266 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1267 SALOME_ListIO selected;
1269 aSel->selectedObjects( selected );
1271 if ( selected.Extent() == 1 ) {
1272 Handle(SALOME_InteractiveObject) anIO = selected.First();
1273 if ( anIO->hasEntry() ) {
1274 //Find Actor by entry before getting Plot2d viewer,
1275 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1276 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1278 SUIT_ViewManager* aViewManager =
1279 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1283 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1287 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1291 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1293 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1294 QString functorName = functorToString( anActor->GetFunctor());
1295 QString aHistogramName("%1 : %2");
1296 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1297 aHistogram->setName(aHistogramName);
1298 aHistogram->setHorTitle(functorName);
1299 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1300 aPlot->displayObject(aHistogram, true);
1305 #endif //DISABLE_PLOT2DVIEWER
1307 void DisableAutoColor()
1309 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1310 SALOME_ListIO selected;
1312 aSel->selectedObjects( selected );
1314 if ( selected.Extent() ) {
1315 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1316 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1317 if ( !aMesh->_is_nil() ) {
1318 aMesh->SetAutoColor( false );
1325 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1326 SALOME_ListIO selected;
1328 aSel->selectedObjects( selected );
1329 if ( selected.Extent() )
1331 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1332 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1333 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1335 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1336 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1343 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1345 SALOME_ListIO selected;
1346 SalomeApp_Application* app =
1347 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1351 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1352 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1353 if ( !aSel || !appStudy )
1356 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1357 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1358 aModule->EmitSignalDeactivateDialog();
1359 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1360 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1365 _PTR(Study) aStudy = appStudy->studyDS();
1367 aSel->selectedObjects( selected );
1369 if ( selected.Extent() >= 1 )
1371 switch ( theCommandID ) {
1372 case SMESHOp::OpTransparency:
1374 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1375 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1378 case SMESHOp::OpProperties:
1381 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1382 QColor orientationColor, outlineColor, volumeColor;
1383 int deltaF = 0, deltaV = 0;
1386 double ballScale = 1.0;
1388 int outlineWidth = 1;
1389 double shrinkCoef = 0.0;
1390 double orientationScale = 0.0;
1391 bool orientation3d = false;
1392 VTK::MarkerType markerType = VTK::MT_NONE;
1393 VTK::MarkerScale markerScale = VTK::MS_NONE;
1395 bool hasNodes = false;
1396 int presentEntities = 0;
1397 bool firstTime = true;
1399 SALOME_ListIteratorOfListIO It( selected );
1400 for ( ; It.More(); It.Next() ) {
1401 Handle(SALOME_InteractiveObject) IObject = It.Value();
1402 if ( !IObject->hasEntry() ) continue;
1403 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1404 if ( !anActor || !anActor->GetObject() ) continue;
1407 // nodes: color, marker
1408 anActor->GetNodeColor( color[0], color[1], color[2] );
1409 nodeColor.setRgbF( color[0], color[1], color[2] );
1410 markerType = anActor->GetMarkerType();
1411 markerScale = anActor->GetMarkerScale();
1412 markerId = anActor->GetMarkerTexture();
1413 // edges: color, width
1414 anActor->GetEdgeColor( color[0], color[1], color[2] );
1415 edgeColor.setRgbF( color[0], color[1], color[2] );
1416 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1417 // faces: front color, back color (delta)
1418 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1419 faceColor.setRgbF( color[0], color[1], color[2] );
1420 // faces: front color, back color (delta)
1421 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1422 volumeColor.setRgbF( color[0], color[1], color[2] );
1423 // 0d elements: color, size
1424 anActor->Get0DColor( color[0], color[1], color[2] );
1425 elem0dColor.setRgbF( color[0], color[1], color[2] );
1426 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1427 // balls: color, size
1428 anActor->GetBallColor( color[0], color[1], color[2] );
1429 ballColor.setRgbF( color[0], color[1], color[2] );
1430 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1431 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1433 anActor->GetOutlineColor( color[0], color[1], color[2] );
1434 outlineColor.setRgbF( color[0], color[1], color[2] );
1435 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1436 // orientation vectors: color, scale, 3d flag
1437 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1438 orientationColor.setRgbF( color[0], color[1], color[2] );
1439 orientationScale = anActor->GetFacesOrientationScale();
1440 orientation3d = anActor->GetFacesOrientation3DVectors();
1442 shrinkCoef = anActor->GetShrinkFactor();
1445 firstTime = false; // we only take properties from first object (for performance reasons)
1448 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1449 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1450 presentEntities = presentEntities | SMESH_Actor::eEdges;
1451 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1452 presentEntities = presentEntities | SMESH_Actor::eFaces;
1453 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1454 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1455 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1456 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1457 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1458 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1460 // as we know that all types of elements are present, we can exit the loop
1461 if ( presentEntities == SMESH_Actor::eAllEntity )
1465 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1466 // nodes: color, marker
1467 dlg.setNodeColor( nodeColor );
1468 if( markerType != VTK::MT_USER )
1469 dlg.setNodeMarker( markerType, markerScale );
1471 dlg.setNodeCustomMarker( markerId );
1472 // edges: color, line width
1473 dlg.setEdgeColor( edgeColor );
1474 dlg.setEdgeWidth( edgeWidth );
1475 // faces: front color, back color
1476 dlg.setFaceColor( faceColor, deltaF );
1477 // volumes: normal color, reversed color
1478 dlg.setVolumeColor( volumeColor, deltaV );
1479 // outlines: color, line width
1480 dlg.setOutlineColor( outlineColor );
1481 dlg.setOutlineWidth( outlineWidth );
1482 // 0d elements: color, size
1483 dlg.setElem0dColor( elem0dColor );
1484 dlg.setElem0dSize( elem0dSize );
1485 // balls: color, size
1486 dlg.setBallColor( ballColor );
1487 //dlg.setBallSize( ballSize );
1488 dlg.setBallScale( ballScale );
1489 // orientation: color, scale, 3d flag
1490 dlg.setOrientationColor( orientationColor );
1491 dlg.setOrientationSize( int( orientationScale * 100. ) );
1492 dlg.setOrientation3d( orientation3d );
1493 // shrink: scale factor
1494 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1495 // hide unused controls
1496 dlg.showControls( presentEntities, hasNodes );
1499 nodeColor = dlg.nodeColor();
1500 markerType = dlg.nodeMarkerType();
1501 markerScale = dlg.nodeMarkerScale();
1502 markerId = dlg.nodeMarkerId();
1503 edgeColor = dlg.edgeColor();
1504 edgeWidth = dlg.edgeWidth();
1505 faceColor = dlg.faceColor();
1506 deltaF = dlg.faceColorDelta();
1507 volumeColor = dlg.volumeColor();
1508 deltaV = dlg.volumeColorDelta();
1509 outlineColor = dlg.outlineColor();
1510 outlineWidth = dlg.outlineWidth();
1511 elem0dColor = dlg.elem0dColor();
1512 elem0dSize = dlg.elem0dSize();
1513 ballColor = dlg.ballColor();
1514 // ballSize = dlg.ballSize();
1515 ballScale = dlg.ballScale();
1516 orientationColor = dlg.orientationColor();
1517 orientationScale = dlg.orientationSize() / 100.;
1518 orientation3d = dlg.orientation3d();
1519 shrinkCoef = dlg.shrinkCoef() / 100.;
1521 // store point markers map that might be changed by the user
1522 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1524 // set properties from dialog box to the presentations
1525 SALOME_ListIteratorOfListIO It( selected );
1526 for ( ; It.More(); It.Next() ) {
1527 Handle(SALOME_InteractiveObject) IObject = It.Value();
1528 if ( !IObject->hasEntry() ) continue;
1529 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1530 if ( !anActor ) continue;
1532 // nodes: color, marker
1533 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1534 if ( markerType != VTK::MT_USER ) {
1535 anActor->SetMarkerStd( markerType, markerScale );
1538 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1539 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1540 if ( iter != markerMap.end() )
1541 anActor->SetMarkerTexture( markerId, iter->second.second );
1543 // volumes: normal color, reversed color (delta)
1544 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1545 // faces: front color, back color (delta)
1546 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1547 // edges: color, width
1548 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1549 anActor->SetLineWidth( edgeWidth );
1551 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1552 anActor->SetOutlineWidth( outlineWidth );
1553 // 0D elements: color, size
1554 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1555 anActor->Set0DSize( elem0dSize );
1556 // balls: color, size
1557 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1558 // anActor->SetBallSize( ballSize );
1559 anActor->SetBallScale( ballScale );
1560 // orientation: color, scale, 3d flag
1561 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1562 anActor->SetFacesOrientationScale( orientationScale );
1563 anActor->SetFacesOrientation3DVectors( orientation3d );
1565 anActor->SetShrinkFactor( shrinkCoef );
1567 // for groups, set also proper color
1568 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1569 if ( !aGroupObject->_is_nil() ) {
1570 SMESH::ElementType anElementType = aGroupObject->GetType();
1572 switch( anElementType ) {
1574 aColor = nodeColor; break;
1576 aColor = edgeColor; break;
1578 aColor = faceColor; break;
1580 aColor = volumeColor; break;
1582 aColor = elem0dColor; break;
1584 aColor = ballColor; break;
1588 if ( aColor.isValid() ) {
1589 SALOMEDS::Color aGroupColor;
1590 aGroupColor.R = aColor.redF();
1591 aGroupColor.G = aColor.greenF();
1592 aGroupColor.B = aColor.blueF();
1593 aGroupObject->SetColor( aGroupColor );
1595 } // if ( !aGroupObject->_is_nil() )
1596 } // for ( ; It.More(); It.Next() )
1597 SMESH::RepaintCurrentView();
1598 } // if ( dlg.exec() )
1600 } // case SMESHOp::OpProperties:
1601 } // switch(theCommandID)
1602 SUIT_OverrideCursor wc;
1603 SALOME_ListIteratorOfListIO It( selected );
1604 for( ; It.More(); It.Next()){
1605 Handle(SALOME_InteractiveObject) IObject = It.Value();
1606 if(IObject->hasEntry()){
1607 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1608 switch(theCommandID){
1609 case SMESHOp::OpDMWireframe:
1610 anActor->SetRepresentation(SMESH_Actor::eEdge);
1612 case SMESHOp::OpDMShading:
1613 anActor->SetRepresentation(SMESH_Actor::eSurface);
1615 case SMESHOp::OpDMShrink:
1616 if(anActor->IsShrunk())
1617 anActor->UnShrink();
1619 anActor->SetShrink();
1621 case SMESHOp::OpDMNodes:
1622 anActor->SetRepresentation(SMESH_Actor::ePoint);
1624 case SMESHOp::OpRepresentationLines:
1625 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1626 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1628 case SMESHOp::OpRepresentationArcs:
1629 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1630 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1636 SMESH::RepaintCurrentView();
1640 int ActionToControl( int theID, bool theReversed )
1642 NCollection_DoubleMap<int,int> ActionControl;
1643 ActionControl.Bind( 0, SMESH_Actor::eNone );
1644 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1645 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1646 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1647 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1648 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1649 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1650 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1651 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1652 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1653 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1654 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1655 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1656 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1657 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1658 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1659 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1660 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1661 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1662 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1663 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1664 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1665 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1666 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1667 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1668 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1669 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1670 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1671 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1673 return theReversed ? ActionControl.Find2( theID ) : ActionControl.Find1( theID );
1676 void Control( int theCommandID )
1678 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1679 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1681 SALOME_ListIO selected;
1682 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1683 aSel->selectedObjects( selected );
1685 if ( !selected.IsEmpty() ) {
1686 SALOME_ListIteratorOfListIO It(selected);
1687 for ( ; It.More(); It.Next())
1689 Handle(SALOME_InteractiveObject) anIO = It.Value();
1690 if ( !anIO.IsNull() ) {
1691 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1693 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1694 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1695 if ( !anIDSrc->_is_nil() ) {
1696 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1697 if (( !anActor && selected.Extent() == 1 ) &&
1698 ( anActor = SMESH::CreateActor( aStudy, anIO->getEntry() )))
1700 anActor->SetControlMode( aControl );
1701 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1702 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1706 if ( anActor->GetControlMode() != aControl )
1707 anActor->SetControlMode( aControl );
1708 QString functorName = functorToString( anActor->GetFunctor() );
1709 int anEntitiesCount = anActor->GetNumberControlEntities();
1710 if (anEntitiesCount >= 0)
1711 functorName = functorName + ": " + QString::number(anEntitiesCount);
1712 anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
1713 SMESH::RepaintCurrentView();
1714 #ifndef DISABLE_PLOT2DVIEWER
1715 if ( anActor->GetPlot2Histogram() ) {
1716 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1717 QString aHistogramName("%1 : %2");
1718 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1719 aHistogram->setName( aHistogramName );
1720 aHistogram->setHorTitle( functorName );
1721 SMESH::ProcessIn2DViewers( anActor );
1733 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1734 SMESH::MeshObjectType theType,
1735 const QString theInTypeName,
1736 QString & theOutTypeName)
1738 SMESH_TypeFilter aTypeFilter( theType );
1740 if ( !theIO.IsNull() )
1742 entry = theIO->getEntry();
1743 LightApp_DataOwner owner( entry );
1744 if ( aTypeFilter.isOk( &owner )) {
1745 theOutTypeName = theInTypeName;
1753 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1755 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1756 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1758 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1759 CORBA::String_var anID = aSComp->GetID().c_str();
1760 if ( !strcmp(anID.in(),theIO->getEntry()) )
1766 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1767 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1768 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1769 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1770 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1778 // QString CheckHomogeneousSelection()
1780 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1781 // SALOME_ListIO selected;
1783 // aSel->selectedObjects( selected );
1785 // QString RefType = CheckTypeObject(selected.First());
1786 // SALOME_ListIteratorOfListIO It(selected);
1787 // for ( ; It.More(); It.Next())
1789 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1790 // QString Type = CheckTypeObject(IObject);
1791 // if ( Type.compare(RefType) != 0 )
1792 // return "Heterogeneous Selection";
1798 uint randomize( uint size )
1800 static bool initialized = false;
1801 if ( !initialized ) {
1802 qsrand( QDateTime::currentDateTime().toTime_t() );
1806 v = uint( (double)( v ) / RAND_MAX * size );
1807 v = qMax( uint(0), qMin ( v, size-1 ) );
1813 void SMESHGUI::OnEditDelete()
1815 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1816 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1817 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1819 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1820 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1821 _PTR(GenericAttribute) anAttr;
1822 _PTR(AttributeIOR) anIOR;
1824 int objectCount = 0;
1826 QString aParentComponent = QString::null;
1827 Handle(SALOME_InteractiveObject) anIO;
1828 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1830 anIO = anIt.Value();
1831 QString cur = anIO->getComponentDataType();
1832 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1834 // check if object is reference
1835 _PTR(SObject) aRefSObj;
1836 aNameList.append("\n - ");
1837 if ( aSO->ReferencedObject( aRefSObj ) ) {
1838 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1839 aNameList.append( aRefName );
1840 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1843 aNameList.append(anIO->getName());
1847 if( aParentComponent.isNull() )
1848 aParentComponent = cur;
1849 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1850 aParentComponent = "";
1853 if ( objectCount == 0 )
1854 return; // No Valid Objects Selected
1856 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1857 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1858 QObject::tr("ERR_ERROR"),
1859 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1862 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1863 if (SUIT_MessageBox::warning
1864 (SMESHGUI::desktop(),
1865 QObject::tr("SMESH_WRN_WARNING"),
1866 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1867 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1868 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1871 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1873 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1874 // then treat them all starting from the deepest objects (at list back)
1875 std::list< _PTR(SObject) > listSO;
1876 SALOME_ListIteratorOfListIO It(selected);
1877 for( ; It.More(); It.Next()) // loop on selected IO's
1879 Handle(SALOME_InteractiveObject) IObject = It.Value();
1880 if(IObject->hasEntry()) {
1881 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1883 // disable removal of "SMESH" component object
1884 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1886 if ( engineIOR() == anIOR->Value().c_str() )
1889 //Check the referenced object
1890 _PTR(SObject) aRefSObject;
1891 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1892 aSO = aRefSObject; // Delete main Object instead of reference
1894 listSO.push_back( aSO );
1895 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1896 for ( ; itSO != listSO.end(); ++itSO ) {
1897 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1898 for (it->InitEx(false); it->More(); it->Next())
1899 listSO.push_back( it->Value() );
1903 // Check if none of objects to delete is referred from outside
1904 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1905 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1907 _PTR(SObject) SO = *ritSO;
1908 if ( !SO ) continue;
1909 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1910 for (size_t i = 0; i < aReferences.size(); i++) {
1911 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1912 std::string type = aComponent->ComponentDataType();
1913 if ( type != "SMESH" )
1915 SUIT_MessageBox::warning( anApp->desktop(),
1916 QObject::tr("WRN_WARNING"),
1917 QObject::tr("DEP_OBJECT") );
1918 return; // outside SMESH, there is an object depending on a SMESH object
1923 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1924 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1926 Handle(SALOME_InteractiveObject) IObject = It.Value();
1927 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1928 if ( !mesh->_is_nil() )
1932 // Treat SO's in the list starting from the back
1933 aStudyBuilder->NewCommand(); // There is a transaction
1934 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1936 _PTR(SObject) SO = *ritSO;
1937 if ( !SO ) continue;
1938 std::string anEntry = SO->GetID();
1940 /** Erase graphical object and remove all its data **/
1941 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1942 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1944 /** Remove an object from data structures **/
1945 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1946 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1947 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1948 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1949 aMesh->RemoveGroup( aGroup );
1951 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1952 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1953 aMesh->RemoveSubMesh( aSubMesh );
1955 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1957 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1960 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1961 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1962 QString objType = CheckTypeObject(IObject);
1963 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1964 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1965 aStudyBuilder->RemoveObjectWithChildren( SO );
1967 else {// default action: remove SObject from the study
1968 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1969 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1971 aStudyBuilder->RemoveObjectWithChildren( SO );
1975 } /* listSO back loop */
1977 aStudyBuilder->CommitCommand();
1979 /* Clear any previous selection */
1981 aSel->setSelectedObjects( l1 );
1983 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1987 SMESHGUI_EXPORT CAM_Module* createModule()
1989 return new SMESHGUI();
1992 SMESHGUI_EXPORT char* getModuleVersion() {
1993 return (char*)SMESH_VERSION_STR;
1997 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1999 //=============================================================================
2003 //=============================================================================
2004 SMESHGUI::SMESHGUI() :
2005 SalomeApp_Module( "SMESH" )
2007 if ( CORBA::is_nil( myComponentSMESH ) )
2009 CORBA::Boolean anIsEmbeddedMode;
2010 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2011 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2013 // 0019923: EDF 765 SMESH : default values of hypothesis
2014 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2015 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2016 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2017 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2018 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2020 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2021 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2022 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2024 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2025 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2029 myActiveDialogBox = 0;
2030 myFilterLibraryDlg = 0;
2034 myEventCallbackCommand = vtkCallbackCommand::New();
2035 myEventCallbackCommand->Delete();
2036 myEventCallbackCommand->SetClientData( this );
2037 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2040 /* load resources for all available meshers */
2041 SMESH::InitAvailableHypotheses();
2044 //=============================================================================
2048 //=============================================================================
2049 SMESHGUI::~SMESHGUI()
2053 //=============================================================================
2057 //=============================================================================
2058 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2060 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2062 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2067 //=============================================================================
2071 //=============================================================================
2072 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2074 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2078 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2079 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2080 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2081 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2082 return autoUpdate && !exceeded;
2085 //=============================================================================
2089 //=============================================================================
2090 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2091 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2093 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2097 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2098 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2099 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2101 SMESH::long_array_var info = theMesh->GetMeshInfo();
2102 long nbOdElems = info[SMDSEntity_0D];
2103 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2104 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2105 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2106 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2107 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2108 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2109 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2110 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] +
2111 info[SMDSEntity_Polyhedra] +
2112 info[SMDSEntity_Hexagonal_Prism];
2113 long nbBalls = info[SMDSEntity_Ball];
2115 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2116 *nbElements = requestedSize;
2118 *entities = SMESH_Actor::eAllEntity;
2121 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2123 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2125 if ( incrementalLimit ) {
2128 if ( nbOdElems > 0 ) {
2129 if ( total + nbOdElems > updateLimit ) {
2130 *entities = *entities & ~SMESH_Actor::e0DElements;
2131 *hidden = *hidden | SMESH_Actor::e0DElements;
2138 if ( nbEdges > 0 ) {
2139 if ( total + nbEdges > updateLimit ) {
2140 *entities = *entities & ~SMESH_Actor::eEdges;
2141 *hidden = *hidden | SMESH_Actor::eEdges;
2148 if ( nbFaces > 0 ) {
2149 if ( total + nbFaces > updateLimit ) {
2150 *entities = *entities & ~SMESH_Actor::eFaces;
2151 *hidden = *hidden | SMESH_Actor::eFaces;
2158 if ( nbVolumes > 0 ) {
2159 if ( total + nbVolumes > updateLimit ) {
2160 *entities = *entities & ~SMESH_Actor::eVolumes;
2161 *hidden = *hidden | SMESH_Actor::eVolumes;
2168 if ( nbBalls > 0 ) {
2169 if ( total + nbBalls > updateLimit ) {
2170 *entities = *entities & ~SMESH_Actor::eBallElem;
2171 *hidden = *hidden | SMESH_Actor::eBallElem;
2179 return autoUpdate && !exceeded;
2182 //=============================================================================
2186 //=============================================================================
2187 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2189 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2192 //=============================================================================
2196 //=============================================================================
2197 SMESHGUI* SMESHGUI::GetSMESHGUI()
2199 SMESHGUI* smeshMod = 0;
2200 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2203 CAM_Module* module = app->module( "Mesh" );
2204 smeshMod = dynamic_cast<SMESHGUI*>( module );
2207 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2209 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2212 _PTR(Study) aStudy = study->studyDS();
2214 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2223 Standard_EXPORT SMESHGUI* GetComponentGUI()
2225 return SMESHGUI::GetSMESHGUI();
2229 //=============================================================================
2233 //=============================================================================
2234 void SMESHGUI::SetState(int aState)
2239 //=============================================================================
2243 //=============================================================================
2244 void SMESHGUI::ResetState()
2249 //=============================================================================
2253 //=============================================================================
2254 void SMESHGUI::EmitSignalDeactivateDialog()
2256 emit SignalDeactivateActiveDialog();
2259 //=============================================================================
2263 //=============================================================================
2264 void SMESHGUI::EmitSignalStudyFrameChanged()
2266 emit SignalStudyFrameChanged();
2269 //=============================================================================
2273 //=============================================================================
2274 void SMESHGUI::EmitSignalCloseAllDialogs()
2276 emit SignalCloseAllDialogs();
2279 //=============================================================================
2283 //=============================================================================
2284 void SMESHGUI::EmitSignalVisibilityChanged()
2286 emit SignalVisibilityChanged();
2289 //=============================================================================
2293 //=============================================================================
2294 void SMESHGUI::EmitSignalCloseView()
2296 emit SignalCloseView();
2299 //=============================================================================
2303 //=============================================================================
2304 void SMESHGUI::EmitSignalActivatedViewManager()
2306 emit SignalActivatedViewManager();
2309 //=============================================================================
2313 //=============================================================================
2314 QDialog *SMESHGUI::GetActiveDialogBox()
2316 return myActiveDialogBox;
2319 //=============================================================================
2323 //=============================================================================
2324 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2326 myActiveDialogBox = (QDialog *) aDlg;
2330 //=============================================================================
2334 //=============================================================================
2335 SUIT_Desktop* SMESHGUI::desktop()
2337 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2339 return app->desktop();
2344 //=============================================================================
2348 //=============================================================================
2349 SalomeApp_Study* SMESHGUI::activeStudy()
2351 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2353 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2358 //=============================================================================
2362 //=============================================================================
2363 void SMESHGUI::Modified( bool theIsUpdateActions )
2365 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2366 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2367 appStudy->Modified();
2368 if( theIsUpdateActions )
2369 app->updateActions();
2374 //=============================================================================
2378 //=============================================================================
2379 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2381 /* Here the position is on the bottom right corner - 10 */
2382 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2384 SUIT_Desktop *PP = desktop();
2385 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2386 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2390 //=============================================================================
2394 //=============================================================================
2395 static int isStudyLocked(_PTR(Study) theStudy){
2396 return theStudy->GetProperties()->IsLocked();
2399 static bool checkLock(_PTR(Study) theStudy) {
2400 if (isStudyLocked(theStudy)) {
2401 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2402 QObject::tr("WRN_WARNING"),
2403 QObject::tr("WRN_STUDY_LOCKED") );
2409 //=======================================================================
2410 //function : CheckActiveStudyLocked
2412 //=======================================================================
2414 bool SMESHGUI::isActiveStudyLocked()
2416 _PTR(Study) aStudy = activeStudy()->studyDS();
2417 return checkLock( aStudy );
2420 //=============================================================================
2424 //=============================================================================
2425 bool SMESHGUI::OnGUIEvent( int theCommandID )
2427 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2431 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2432 SUIT_ResourceMgr* mgr = resourceMgr();
2436 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2437 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2440 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2441 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2443 //QAction* act = action( theCommandID );
2445 switch (theCommandID) {
2446 case SMESHOp::OpDelete:
2447 if(checkLock(aStudy)) break;
2450 case SMESHOp::OpImportDAT:
2451 case SMESHOp::OpImportUNV:
2452 case SMESHOp::OpImportMED:
2453 case SMESHOp::OpImportSTL:
2455 case SMESHOp::OpImportCGNS:
2457 case SMESHOp::OpImportSAUV:
2458 case SMESHOp::OpImportGMF:
2460 if(checkLock(aStudy)) break;
2461 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2465 case SMESHOp::OpFileInformation:
2467 SALOME_ListIO selected;
2468 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2470 aSel->selectedObjects( selected );
2471 if( selected.Extent() )
2473 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2474 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2475 if ( !aMesh->_is_nil() )
2477 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2483 case SMESHOp::OpExportDAT:
2484 case SMESHOp::OpExportMED:
2485 case SMESHOp::OpExportUNV:
2486 case SMESHOp::OpExportSTL:
2488 case SMESHOp::OpExportCGNS:
2490 case SMESHOp::OpExportSAUV:
2491 case SMESHOp::OpExportGMF:
2492 case SMESHOp::OpPopupExportDAT:
2493 case SMESHOp::OpPopupExportMED:
2494 case SMESHOp::OpPopupExportUNV:
2495 case SMESHOp::OpPopupExportSTL:
2497 case SMESHOp::OpPopupExportCGNS:
2499 case SMESHOp::OpPopupExportSAUV:
2500 case SMESHOp::OpPopupExportGMF:
2502 ::ExportMeshToFile(theCommandID);
2506 case SMESHOp::OpReset: // SCALAR BAR
2508 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2509 SALOME_ListIO selected;
2511 aSel->selectedObjects( selected );
2513 SALOME_ListIteratorOfListIO it(selected);
2514 for( ; it.More(); it.Next()) {
2515 Handle(SALOME_InteractiveObject) anIO = it.Value();
2516 if( anIO->hasEntry() ) {
2517 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2518 anActor->SetControlMode( SMESH_Actor::eNone );
2519 #ifndef DISABLE_PLOT2DVIEWER
2520 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2525 SMESH::UpdateView();
2528 case SMESHOp::OpScalarBarProperties:
2530 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2533 case SMESHOp::OpShowScalarBar:
2535 // show/hide scalar bar
2536 ::ShowElement(theCommandID);
2539 case SMESHOp::OpSaveDistribution:
2541 // dump control distribution data to the text file
2542 ::SaveDistribution();
2546 case SMESHOp::OpShowDistribution:
2548 // show/hide distribution
2549 ::ShowElement(theCommandID);
2553 #ifndef DISABLE_PLOT2DVIEWER
2554 case SMESHOp::OpPlotDistribution:
2556 // plot distribution
2557 ::PlotDistribution();
2563 case SMESHOp::OpAutoColor:
2567 case SMESHOp::OpDisableAutoColor:
2568 ::DisableAutoColor();
2571 case SMESHOp::OpClipping:
2572 case SMESHOp::OpTransparency:
2573 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2576 case SMESHOp::OpDMWireframe:
2577 case SMESHOp::OpDMShading:
2578 case SMESHOp::OpDMNodes:
2579 case SMESHOp::OpDMShrink:
2580 ::SetDisplayMode(theCommandID, myMarkerMap);
2583 //2D quadratic representation
2584 case SMESHOp::OpRepresentationLines:
2585 case SMESHOp::OpRepresentationArcs:
2586 ::SetDisplayMode(theCommandID, myMarkerMap);
2590 case SMESHOp::OpDE0DElements:
2591 case SMESHOp::OpDEEdges:
2592 case SMESHOp::OpDEFaces:
2593 case SMESHOp::OpDEVolumes:
2594 case SMESHOp::OpDEBalls:
2595 case SMESHOp::OpDEAllEntity:
2596 ::SetDisplayEntity(theCommandID);
2599 // Choose entities to be displayed
2600 case SMESHOp::OpDEChoose:
2602 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2606 case SMESHOp::OpOrientationOnFaces:
2608 SUIT_OverrideCursor wc;
2609 LightApp_SelectionMgr* mgr = selectionMgr();
2610 SALOME_ListIO selected; mgr->selectedObjects( selected );
2612 SALOME_ListIteratorOfListIO it(selected);
2613 for( ; it.More(); it.Next()) {
2614 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2615 if(anIObject->hasEntry()) {
2616 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2617 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2624 case SMESHOp::OpUpdate:
2626 if(checkLock(aStudy)) break;
2627 SUIT_OverrideCursor wc;
2629 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2632 SMESH::UpdateView();
2634 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2635 SMESH::OnVisuException();
2637 catch (...) { // PAL16774 (Crash after display of many groups)
2638 SMESH::OnVisuException();
2642 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2643 aSel->selectedObjects( l );
2644 aSel->setSelectedObjects( l );
2648 case SMESHOp::OpHide:
2649 case SMESHOp::OpShow:
2650 case SMESHOp::OpShowOnly:
2652 SUIT_OverrideCursor wc;
2653 SMESH::EDisplaing anAction;
2654 switch (theCommandID) {
2655 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2656 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2657 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2660 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2661 SALOME_ListIO sel_objects, to_process;
2663 aSel->selectedObjects( sel_objects );
2665 if ( theCommandID==SMESHOp::OpShowOnly )
2667 //MESSAGE("anAction = SMESH::eDisplayOnly");
2668 startOperation( myEraseAll );
2671 extractContainers( sel_objects, to_process );
2674 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2678 SALOME_ListIteratorOfListIO It( to_process );
2679 for ( ; It.More(); It.Next())
2681 Handle(SALOME_InteractiveObject) IOS = It.Value();
2682 if ( IOS->hasEntry() )
2684 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2685 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2686 break; // PAL16774 (Crash after display of many groups)
2688 if (anAction == SMESH::eDisplayOnly)
2689 anAction = SMESH::eDisplay;
2694 // PAL13338 + PAL15161 -->
2695 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !checkLock(aStudy)) {
2696 SMESH::UpdateView();
2697 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2699 // PAL13338 + PAL15161 <--
2701 catch (...) { // PAL16774 (Crash after display of many groups)
2702 SMESH::OnVisuException();
2705 if (anAction == SMESH::eErase) {
2707 aSel->setSelectedObjects( l1 );
2710 aSel->setSelectedObjects( to_process );
2715 case SMESHOp::OpNode:
2717 if(checkLock(aStudy)) break;
2720 EmitSignalDeactivateDialog();
2722 ( new SMESHGUI_NodesDlg( this ) )->show();
2725 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2730 case SMESHOp::OpCreateMesh:
2731 case SMESHOp::OpCreateSubMesh:
2732 case SMESHOp::OpEditMeshOrSubMesh:
2733 case SMESHOp::OpEditMesh:
2734 case SMESHOp::OpEditSubMesh:
2735 case SMESHOp::OpCompute:
2736 case SMESHOp::OpComputeSubMesh:
2737 case SMESHOp::OpPreCompute:
2738 case SMESHOp::OpEvaluate:
2739 case SMESHOp::OpMeshOrder:
2740 startOperation( theCommandID );
2742 case SMESHOp::OpCopyMesh:
2744 if (checkLock(aStudy)) break;
2745 EmitSignalDeactivateDialog();
2746 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2749 case SMESHOp::OpBuildCompoundMesh:
2751 if (checkLock(aStudy)) break;
2752 EmitSignalDeactivateDialog();
2753 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2757 case SMESHOp::OpDiagonalInversion:
2758 case SMESHOp::OpUnionOfTwoTriangle:
2762 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2766 if ( checkLock( aStudy ) )
2769 /*Standard_Boolean aRes;
2770 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2771 if ( aMesh->_is_nil() )
2773 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2774 tr( "SMESH_BAD_SELECTION" ) );
2778 EmitSignalDeactivateDialog();
2779 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2780 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2782 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2785 case SMESHOp::OpOrientation:
2786 case SMESHOp::OpUnionOfTriangles:
2787 case SMESHOp::OpCuttingOfQuadrangles:
2788 case SMESHOp::OpSplitVolumes:
2792 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2796 if ( checkLock( aStudy ) )
2799 EmitSignalDeactivateDialog();
2800 SMESHGUI_MultiEditDlg* aDlg = NULL;
2801 if ( theCommandID == SMESHOp::OpOrientation )
2802 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2803 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2804 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2805 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2806 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2808 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2813 case SMESHOp::OpSmoothing:
2815 if(checkLock(aStudy)) break;
2817 EmitSignalDeactivateDialog();
2818 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2821 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2825 case SMESHOp::OpExtrusion:
2827 if (checkLock(aStudy)) break;
2829 EmitSignalDeactivateDialog();
2830 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2832 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2836 case SMESHOp::OpExtrusionAlongAPath:
2838 if (checkLock(aStudy)) break;
2840 EmitSignalDeactivateDialog();
2841 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2843 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2847 case SMESHOp::OpRevolution:
2849 if(checkLock(aStudy)) break;
2851 EmitSignalDeactivateDialog();
2852 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2855 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2859 case SMESHOp::OpPatternMapping:
2861 if ( checkLock( aStudy ) )
2865 EmitSignalDeactivateDialog();
2866 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2869 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2873 case SMESHOp::OpSplitBiQuadratic:
2874 case SMESHOp::OpConvertMeshToQuadratic:
2875 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2876 case SMESHOp::OpReorientFaces:
2877 case SMESHOp::OpCreateGeometryGroup:
2879 startOperation( theCommandID );
2882 case SMESHOp::OpCreateGroup:
2886 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2890 if(checkLock(aStudy)) break;
2891 EmitSignalDeactivateDialog();
2892 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2894 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2895 SALOME_ListIO selected;
2897 aSel->selectedObjects( selected );
2899 int nbSel = selected.Extent();
2901 // check if mesh is selected
2902 aMesh = SMESH::GetMeshByIO( selected.First() );
2904 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2909 case SMESHOp::OpConstructGroup:
2913 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2917 if(checkLock(aStudy)) break;
2918 EmitSignalDeactivateDialog();
2920 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2921 SALOME_ListIO selected;
2923 aSel->selectedObjects( selected );
2925 int nbSel = selected.Extent();
2927 // check if submesh is selected
2928 Handle(SALOME_InteractiveObject) IObject = selected.First();
2929 if (IObject->hasEntry()) {
2930 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2932 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2933 if (!aSubMesh->_is_nil()) {
2935 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2936 // get submesh elements list by types
2937 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2938 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2939 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2940 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2941 // create group for each type o elements
2942 QString aName = IObject->getName();
2943 QStringList anEntryList;
2944 if (aNodes->length() > 0) {
2945 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2946 aGroup->Add(aNodes.inout());
2947 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2948 anEntryList.append( aSObject->GetID().c_str() );
2950 if (aEdges->length() > 0) {
2951 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2952 aGroup->Add(aEdges.inout());
2953 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2954 anEntryList.append( aSObject->GetID().c_str() );
2956 if (aFaces->length() > 0) {
2957 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2958 aGroup->Add(aFaces.inout());
2959 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2960 anEntryList.append( aSObject->GetID().c_str() );
2962 if (aVolumes->length() > 0) {
2963 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2964 aGroup->Add(aVolumes.inout());
2965 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2966 anEntryList.append( aSObject->GetID().c_str() );
2969 anApp->browseObjects( anEntryList );
2971 catch(const SALOME::SALOME_Exception & S_ex){
2972 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2979 SUIT_MessageBox::warning(desktop(),
2980 tr("SMESH_WRN_WARNING"),
2981 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2986 case SMESHOp::OpEditGroup:
2990 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2994 if(checkLock(aStudy)) break;
2995 EmitSignalDeactivateDialog();
2997 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2998 SALOME_ListIO selected;
3000 aSel->selectedObjects( selected );
3002 SALOME_ListIteratorOfListIO It (selected);
3003 int nbSelectedGroups = 0;
3004 for ( ; It.More(); It.Next() )
3006 SMESH::SMESH_GroupBase_var aGroup =
3007 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3008 if (!aGroup->_is_nil()) {
3010 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3014 if (nbSelectedGroups == 0)
3016 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3022 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3024 if(checkLock(aStudy)) break;
3025 if (myState == 800) {
3026 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3027 if (aDlg) aDlg->onAdd();
3032 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3034 if(checkLock(aStudy)) break;
3035 if (myState == 800) {
3036 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3037 if (aDlg) aDlg->onRemove();
3042 case SMESHOp::OpEditGeomGroupAsGroup:
3046 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3050 if(checkLock(aStudy)) break;
3051 EmitSignalDeactivateDialog();
3053 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3054 SALOME_ListIO selected;
3056 aSel->selectedObjects( selected );
3058 SALOME_ListIteratorOfListIO It (selected);
3059 for ( ; It.More(); It.Next() )
3061 SMESH::SMESH_GroupOnGeom_var aGroup =
3062 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3063 if (!aGroup->_is_nil()) {
3064 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3069 SMESH::SMESH_GroupOnFilter_var aGroup =
3070 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3071 if (!aGroup->_is_nil()) {
3072 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3080 case SMESHOp::OpUnionGroups:
3081 case SMESHOp::OpIntersectGroups:
3082 case SMESHOp::OpCutGroups:
3086 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3090 if ( checkLock( aStudy ) )
3093 EmitSignalDeactivateDialog();
3095 SMESHGUI_GroupOpDlg* aDlg = 0;
3096 if ( theCommandID == SMESHOp::OpUnionGroups )
3097 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3098 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3099 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3101 aDlg = new SMESHGUI_CutGroupsDlg( this );
3108 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3110 if ( checkLock( aStudy ) )
3113 EmitSignalDeactivateDialog();
3114 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3120 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3124 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3128 if ( checkLock( aStudy ) )
3131 EmitSignalDeactivateDialog();
3133 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3137 case SMESHOp::OpMeshInformation:
3138 case SMESHOp::OpWhatIs:
3140 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3141 EmitSignalDeactivateDialog();
3142 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3143 SALOME_ListIO selected;
3145 aSel->selectedObjects( selected );
3147 if ( selected.Extent() > 1 ) { // a dlg for each IO
3148 SALOME_ListIteratorOfListIO It( selected );
3149 for ( ; It.More(); It.Next() ) {
3150 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3151 dlg->showInfo( It.Value() );
3156 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3162 case SMESHOp::OpFindElementByPoint:
3164 startOperation( theCommandID );
3168 case SMESHOp::OpEditHypothesis:
3170 if(checkLock(aStudy)) break;
3172 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3173 SALOME_ListIO selected;
3175 aSel->selectedObjects( selected );
3177 int nbSel = selected.Extent();
3180 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3181 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3183 if ( !aHypothesis->_is_nil() )
3185 SMESHGUI_GenericHypothesisCreator* aCreator =
3186 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3189 // set geometry of mesh and sub-mesh to aCreator
3190 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3191 if ( selected.Extent() == 1 )
3193 QString subGeomID, meshGeomID;
3194 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3195 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3197 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3198 aCreator->setShapeEntry( subGeomID );
3199 aCreator->setMainShapeEntry( meshGeomID );
3203 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3213 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3215 if(checkLock(aStudy)) break;
3216 SUIT_OverrideCursor wc;
3218 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3219 SALOME_ListIO selected;
3221 aSel->selectedObjects( selected, QString::null, false );
3223 SALOME_ListIteratorOfListIO It(selected);
3224 for (int i = 0; It.More(); It.Next(), i++) {
3225 Handle(SALOME_InteractiveObject) IObject = It.Value();
3226 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3229 aSel->setSelectedObjects( l1 );
3234 case SMESHOp::OpElem0D:
3235 case SMESHOp::OpBall:
3236 case SMESHOp::OpEdge:
3237 case SMESHOp::OpTriangle:
3238 case SMESHOp::OpQuadrangle:
3239 case SMESHOp::OpPolygon:
3240 case SMESHOp::OpTetrahedron:
3241 case SMESHOp::OpHexahedron:
3242 case SMESHOp::OpPentahedron:
3243 case SMESHOp::OpPyramid:
3244 case SMESHOp::OpHexagonalPrism:
3246 if(checkLock(aStudy)) break;
3248 EmitSignalDeactivateDialog();
3249 SMDSAbs_EntityType type = SMDSEntity_Edge;
3250 switch (theCommandID) {
3251 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3252 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3253 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3254 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3255 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3256 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3257 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3258 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3259 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3260 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3263 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3266 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3270 case SMESHOp::OpPolyhedron:
3272 if(checkLock(aStudy)) break;
3274 EmitSignalDeactivateDialog();
3275 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3278 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3282 case SMESHOp::OpQuadraticEdge:
3283 case SMESHOp::OpQuadraticTriangle:
3284 case SMESHOp::OpBiQuadraticTriangle:
3285 case SMESHOp::OpQuadraticQuadrangle:
3286 case SMESHOp::OpBiQuadraticQuadrangle:
3287 case SMESHOp::OpQuadraticPolygon:
3288 case SMESHOp::OpQuadraticTetrahedron:
3289 case SMESHOp::OpQuadraticPyramid:
3290 case SMESHOp::OpQuadraticPentahedron:
3291 case SMESHOp::OpQuadraticHexahedron:
3292 case SMESHOp::OpTriQuadraticHexahedron:
3294 if(checkLock(aStudy)) break;
3296 EmitSignalDeactivateDialog();
3297 SMDSAbs_EntityType type = SMDSEntity_Last;
3299 switch (theCommandID) {
3300 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3301 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3302 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3303 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3304 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3305 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3306 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3307 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3308 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3309 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3310 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3313 if ( type != SMDSEntity_Last )
3314 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3317 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3318 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3322 case SMESHOp::OpRemoveNodes:
3324 if(checkLock(aStudy)) break;
3326 EmitSignalDeactivateDialog();
3327 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3330 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3331 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3335 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3337 if(checkLock(aStudy)) break;
3339 EmitSignalDeactivateDialog();
3340 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3344 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3345 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3349 case SMESHOp::OpClearMesh: {
3351 if(checkLock(aStudy)) break;
3353 SALOME_ListIO selected;
3354 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3355 aSel->selectedObjects( selected );
3357 SUIT_OverrideCursor wc;
3358 SALOME_ListIteratorOfListIO It (selected);
3359 for ( ; It.More(); It.Next() )
3361 Handle(SALOME_InteractiveObject) IOS = It.Value();
3362 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3363 if ( aMesh->_is_nil()) continue;
3366 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3367 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3368 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3369 SMESH::ModifiedMesh( aMeshSObj, false, true);
3370 // hide groups and submeshes
3371 _PTR(ChildIterator) anIter =
3372 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3373 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3375 _PTR(SObject) so = anIter->Value();
3376 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3379 catch (const SALOME::SALOME_Exception& S_ex){
3381 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3385 SMESH::UpdateView();
3389 case SMESHOp::OpRemoveOrphanNodes:
3391 if(checkLock(aStudy)) break;
3392 SALOME_ListIO selected;
3393 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3394 aSel->selectedObjects( selected );
3395 if ( selected.Extent() == 1 ) {
3396 Handle(SALOME_InteractiveObject) anIO = selected.First();
3397 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3398 if ( !aMesh->_is_nil() ) {
3399 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3400 tr( "SMESH_WARNING" ),
3401 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3402 SUIT_MessageBox::Yes |
3403 SUIT_MessageBox::No,
3404 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3407 SUIT_OverrideCursor wc;
3408 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3409 int removed = aMeshEditor->RemoveOrphanNodes();
3410 SUIT_MessageBox::information(SMESHGUI::desktop(),
3411 tr("SMESH_INFORMATION"),
3412 tr("NB_NODES_REMOVED").arg(removed));
3413 if ( removed > 0 ) {
3414 SMESH::UpdateView();
3415 SMESHGUI::Modified();
3418 catch (const SALOME::SALOME_Exception& S_ex) {
3419 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3428 case SMESHOp::OpRenumberingNodes:
3430 if(checkLock(aStudy)) break;
3432 EmitSignalDeactivateDialog();
3433 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3437 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3438 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3442 case SMESHOp::OpRenumberingElements:
3444 if(checkLock(aStudy)) break;
3446 EmitSignalDeactivateDialog();
3447 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3451 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3452 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3456 case SMESHOp::OpTranslation:
3458 if(checkLock(aStudy)) break;
3460 EmitSignalDeactivateDialog();
3461 ( new SMESHGUI_TranslationDlg( this ) )->show();
3464 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3465 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3469 case SMESHOp::OpRotation:
3471 if(checkLock(aStudy)) break;
3473 EmitSignalDeactivateDialog();
3474 ( new SMESHGUI_RotationDlg( this ) )->show();
3477 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3478 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3482 case SMESHOp::OpSymmetry:
3484 if(checkLock(aStudy)) break;
3486 EmitSignalDeactivateDialog();
3487 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3490 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3491 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3495 case SMESHOp::OpScale:
3497 if(checkLock(aStudy)) break;
3499 EmitSignalDeactivateDialog();
3500 ( new SMESHGUI_ScaleDlg( this ) )->show();
3503 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3504 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3509 case SMESHOp::OpOffset:
3511 if(checkLock(aStudy)) break;
3513 EmitSignalDeactivateDialog();
3514 ( new SMESHGUI_OffsetDlg( this ) )->show();
3517 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3518 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3523 case SMESHOp::OpSewing:
3525 if(checkLock(aStudy)) break;
3527 EmitSignalDeactivateDialog();
3528 ( new SMESHGUI_SewingDlg( this ) )->show();
3531 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3532 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3536 case SMESHOp::OpMergeNodes:
3538 if(checkLock(aStudy)) break;
3540 EmitSignalDeactivateDialog();
3541 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3544 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3545 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3549 case SMESHOp::OpMergeElements:
3551 if (checkLock(aStudy)) break;
3553 EmitSignalDeactivateDialog();
3554 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3556 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3557 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3562 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3563 startOperation( SMESHOp::OpMoveNode );
3566 case SMESHOp::OpDuplicateNodes:
3568 if(checkLock(aStudy)) break;
3570 EmitSignalDeactivateDialog();
3571 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3574 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3575 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3580 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3581 startOperation( SMESHOp::OpElem0DOnElemNodes );
3584 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3586 static QList<int> aTypes;
3587 if ( aTypes.isEmpty() )
3589 aTypes.append( SMESH::NODE );
3590 aTypes.append( SMESH::EDGE );
3591 aTypes.append( SMESH::FACE );
3592 aTypes.append( SMESH::VOLUME );
3594 if (!myFilterLibraryDlg)
3595 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3596 else if (myFilterLibraryDlg->isHidden())
3597 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3598 myFilterLibraryDlg->raise();
3602 case SMESHOp::OpFreeNode:
3603 case SMESHOp::OpEqualNode:
3604 case SMESHOp::OpNodeConnectivityNb:
3605 case SMESHOp::OpFreeEdge:
3606 case SMESHOp::OpFreeBorder:
3607 case SMESHOp::OpLength:
3608 case SMESHOp::OpConnection:
3609 case SMESHOp::OpEqualEdge:
3610 case SMESHOp::OpFreeFace:
3611 case SMESHOp::OpBareBorderFace:
3612 case SMESHOp::OpOverConstrainedFace:
3613 case SMESHOp::OpLength2D:
3614 case SMESHOp::OpDeflection2D:
3615 case SMESHOp::OpConnection2D:
3616 case SMESHOp::OpArea:
3617 case SMESHOp::OpTaper:
3618 case SMESHOp::OpAspectRatio:
3619 case SMESHOp::OpMinimumAngle:
3620 case SMESHOp::OpWarpingAngle:
3621 case SMESHOp::OpSkew:
3622 case SMESHOp::OpMaxElementLength2D:
3623 case SMESHOp::OpEqualFace:
3624 case SMESHOp::OpAspectRatio3D:
3625 case SMESHOp::OpVolume:
3626 case SMESHOp::OpMaxElementLength3D:
3627 case SMESHOp::OpBareBorderVolume:
3628 case SMESHOp::OpOverConstrainedVolume:
3629 case SMESHOp::OpEqualVolume:
3632 LightApp_SelectionMgr* mgr = selectionMgr();
3633 SALOME_ListIO selected; mgr->selectedObjects( selected );
3635 if( !selected.IsEmpty() ) {
3636 SUIT_OverrideCursor wc;
3637 ::Control( theCommandID );
3640 SUIT_MessageBox::warning(desktop(),
3641 tr( "SMESH_WRN_WARNING" ),
3642 tr( "SMESH_BAD_SELECTION" ) );
3646 SUIT_MessageBox::warning(desktop(),
3647 tr( "SMESH_WRN_WARNING" ),
3648 tr( "NOT_A_VTK_VIEWER" ) );
3651 case SMESHOp::OpOverallMeshQuality:
3652 OverallMeshQuality();
3654 case SMESHOp::OpNumberingNodes:
3656 SUIT_OverrideCursor wc;
3657 LightApp_SelectionMgr* mgr = selectionMgr();
3658 SALOME_ListIO selected; mgr->selectedObjects( selected );
3660 SALOME_ListIteratorOfListIO it(selected);
3661 for( ; it.More(); it.Next()) {
3662 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3663 if(anIObject->hasEntry()) {
3664 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3665 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3671 case SMESHOp::OpNumberingElements:
3673 SUIT_OverrideCursor wc;
3674 LightApp_SelectionMgr* mgr = selectionMgr();
3675 SALOME_ListIO selected; mgr->selectedObjects( selected );
3677 SALOME_ListIteratorOfListIO it(selected);
3678 for( ; it.More(); it.Next()) {
3679 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3680 if(anIObject->hasEntry())
3681 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3682 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3687 case SMESHOp::OpPropertiesLength:
3688 case SMESHOp::OpPropertiesArea:
3689 case SMESHOp::OpPropertiesVolume:
3690 case SMESHOp::OpMinimumDistance:
3691 case SMESHOp::OpBoundingBox:
3693 int page = SMESHGUI_MeasureDlg::MinDistance;
3694 if ( theCommandID == SMESHOp::OpBoundingBox )
3695 page = SMESHGUI_MeasureDlg::BoundingBox;
3696 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3697 page = SMESHGUI_MeasureDlg::Length;
3698 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3699 page = SMESHGUI_MeasureDlg::Area;
3700 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3701 page = SMESHGUI_MeasureDlg::Volume;
3703 EmitSignalDeactivateDialog();
3704 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3708 case SMESHOp::OpSortChild:
3714 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3715 //updateObjBrowser();
3719 //=============================================================================
3723 //=============================================================================
3724 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3729 //=============================================================================
3733 //=============================================================================
3734 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3739 //=============================================================================
3743 //=============================================================================
3744 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3749 //=============================================================================
3750 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3751 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3753 //=============================================================================
3754 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3755 SUIT_ViewWindow* wnd )
3757 if(theIO->hasEntry()){
3758 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3759 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3763 //=======================================================================
3764 // function : createSMESHAction
3766 //=======================================================================
3767 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3768 const int key, const bool toggle, const QString& shortcutAction )
3771 QWidget* parent = application()->desktop();
3772 SUIT_ResourceMgr* resMgr = resourceMgr();
3774 if ( !icon_id.isEmpty() )
3775 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3777 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3778 if ( !pix.isNull() )
3779 icon = QIcon( pix );
3781 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3782 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3783 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3785 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3786 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3789 //=======================================================================
3790 // function : createPopupItem
3792 //=======================================================================
3793 void SMESHGUI::createPopupItem( const int id,
3794 const QString& clients,
3795 const QString& types,
3796 const QString& theRule,
3799 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3800 popupMgr()->insert( action( id ), pId, 0 );
3802 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3803 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3804 QString rule = "(%1) and (%2) and (%3)";
3805 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3806 if( clients.isEmpty() )
3807 rule = rule.arg( QString( "true" ) );
3809 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3810 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3813 bool cont = myRules.contains( id );
3815 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3817 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3818 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3821 //=======================================================================
3822 // function : initialize
3824 //=======================================================================
3825 void SMESHGUI::initialize( CAM_Application* app )
3827 SalomeApp_Module::initialize( app );
3829 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3831 /* Automatic Update flag */
3832 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3834 // ----- create actions --------------
3836 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3837 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
3838 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3839 //createSMESHAction( 114, "NUM" );
3840 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
3842 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
3844 createSMESHAction( SMESHOp::OpImportSAUV, "IMPORT_SAUV" );
3845 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
3846 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
3847 createSMESHAction( SMESHOp::OpExportMED, "MED" );
3848 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
3849 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
3851 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
3853 createSMESHAction( SMESHOp::OpExportSAUV, "SAUV");
3854 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
3855 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
3856 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
3857 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
3858 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
3860 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
3862 createSMESHAction( SMESHOp::OpPopupExportSAUV, "SAUV");
3863 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
3864 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
3865 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3866 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
3867 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3868 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3869 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
3870 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
3871 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
3872 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3873 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
3874 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
3875 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
3876 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3877 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
3878 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
3879 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3880 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
3881 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3882 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3883 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3884 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
3885 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
3886 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
3887 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
3888 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD" );
3889 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE" );
3890 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
3891 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
3892 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
3893 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3894 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
3896 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3897 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3898 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
3899 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3900 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3901 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
3902 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
3903 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3904 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3905 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3906 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3907 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3908 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
3909 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3910 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
3911 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
3912 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
3913 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
3914 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
3915 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
3916 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3917 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3918 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3919 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3920 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3921 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3922 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3923 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3924 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY" );
3926 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
3927 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
3928 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3929 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
3930 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
3931 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3932 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
3933 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
3934 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
3935 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
3936 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
3937 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
3938 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
3939 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3940 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3941 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3942 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3943 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3944 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3945 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
3946 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3947 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3948 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3949 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3950 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3952 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3953 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3954 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3955 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
3957 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3958 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3960 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3961 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
3962 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3963 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
3964 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
3965 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3966 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
3967 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3968 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3969 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3970 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
3971 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
3972 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3973 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
3974 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
3975 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
3976 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3977 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
3978 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
3979 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
3980 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3981 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
3982 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
3983 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3984 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3986 createSMESHAction( SMESHOp::OpReset, "RESET" );
3987 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
3988 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
3989 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
3990 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
3991 #ifndef DISABLE_PLOT2DVIEWER
3992 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
3994 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
3995 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
3996 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
3997 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
3998 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
3999 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4000 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4001 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4002 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4003 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4004 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4005 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4006 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4008 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4009 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4011 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4012 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4013 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4014 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4015 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4016 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4017 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4018 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4019 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4021 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4022 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4023 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4024 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4025 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4027 createSMESHAction( SMESHOp::OpHide, "HIDE" );
4028 createSMESHAction( SMESHOp::OpShow, "SHOW" );
4029 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4031 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4033 QList<int> aCtrlActions;
4034 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4035 << SMESHOp::OpNodeConnectivityNb // node controls
4036 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4037 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4038 << SMESHOp::OpDeflection2D
4039 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4040 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4041 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4042 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4043 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4044 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4045 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4046 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4047 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4048 aCtrlGroup->setExclusive( true );
4049 for( int i = 0; i < aCtrlActions.size(); i++ )
4050 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4052 // ----- create menu --------------
4053 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4054 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4055 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4056 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4057 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4058 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4059 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4060 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4062 createMenu( separator(), fileId );
4064 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4065 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4066 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4067 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4068 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4069 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4070 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4071 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4072 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4073 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4074 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4075 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4076 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4078 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4079 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4080 createMenu( SMESHOp::OpImportMED, importId, -1 );
4081 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4083 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4085 createMenu( SMESHOp::OpImportSAUV, importId, -1 );
4086 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4087 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4088 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4089 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4090 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4092 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4094 createMenu( SMESHOp::OpExportSAUV, exportId, -1 );
4095 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4096 createMenu( separator(), fileId, 10 );
4098 createMenu( SMESHOp::OpDelete, editId, -1 );
4100 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4102 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4103 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4104 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4105 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4106 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4107 createMenu( separator(), meshId, -1 );
4108 createMenu( SMESHOp::OpCompute, meshId, -1 );
4109 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4110 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4111 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4112 createMenu( separator(), meshId, -1 );
4113 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4114 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4115 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4116 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4117 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4118 createMenu( separator(), meshId, -1 );
4119 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4120 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4121 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4122 createMenu( separator(), meshId, -1 );
4123 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4124 createMenu( separator(), meshId, -1 );
4125 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4126 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4127 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4128 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4129 createMenu( separator(), meshId, -1 );
4131 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4132 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4133 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4134 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4135 createMenu( SMESHOp::OpLength, edgeId, -1 );
4136 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4137 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4138 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4139 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4140 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4141 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4142 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4143 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4144 createMenu( SMESHOp::OpArea, faceId, -1 );
4145 createMenu( SMESHOp::OpTaper, faceId, -1 );
4146 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4147 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4148 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4149 createMenu( SMESHOp::OpSkew, faceId, -1 );
4150 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4151 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4152 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4153 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4154 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4155 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4156 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4157 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4158 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4159 createMenu( separator(), ctrlId, -1 );
4160 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4161 createMenu( separator(), ctrlId, -1 );
4162 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4164 createMenu( SMESHOp::OpNode, addId, -1 );
4165 createMenu( SMESHOp::OpElem0D, addId, -1 );
4166 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4167 createMenu( SMESHOp::OpBall, addId, -1 );
4168 createMenu( SMESHOp::OpEdge, addId, -1 );
4169 createMenu( SMESHOp::OpTriangle, addId, -1 );
4170 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4171 createMenu( SMESHOp::OpPolygon, addId, -1 );
4172 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4173 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4174 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4175 createMenu( SMESHOp::OpPyramid, addId, -1 );
4176 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4177 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4178 createMenu( separator(), addId, -1 );
4179 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4180 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4181 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4182 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4183 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4184 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4185 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4186 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4187 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4188 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4189 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4191 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4192 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4193 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4194 createMenu( separator(), removeId, -1 );
4195 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4196 createMenu( separator(), removeId, -1 );
4197 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4199 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4200 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4202 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4203 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4204 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4205 createMenu( SMESHOp::OpRotation, transfId, -1 );
4206 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4207 createMenu( SMESHOp::OpScale, transfId, -1 );
4208 createMenu( SMESHOp::OpOffset, transfId, -1 );
4209 createMenu( SMESHOp::OpSewing, transfId, -1 );
4210 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4212 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4213 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4214 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4215 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4216 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4217 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4218 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4219 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4220 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4221 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4222 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4223 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4224 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4225 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4226 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4227 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4229 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4230 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4231 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4232 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4233 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4234 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4236 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4237 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4238 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4239 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4241 // ----- create toolbars --------------
4242 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ),
4243 info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ),
4244 groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ),
4245 ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ),
4246 ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ),
4247 ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ),
4248 ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ),
4249 addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ),
4250 addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ),
4251 remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ),
4252 //renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ),
4253 transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
4254 modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ),
4255 measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ),
4256 dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4258 createTool( SMESHOp::OpCreateMesh, meshTb );
4259 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4260 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4261 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4262 createTool( SMESHOp::OpCopyMesh, meshTb );
4263 createTool( separator(), meshTb );
4264 createTool( SMESHOp::OpCompute, meshTb );
4265 createTool( SMESHOp::OpPreCompute, meshTb );
4266 createTool( SMESHOp::OpEvaluate, meshTb );
4267 createTool( SMESHOp::OpMeshOrder, meshTb );
4269 createTool( SMESHOp::OpCreateGroup, groupTb );
4270 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4271 createTool( SMESHOp::OpConstructGroup, groupTb );
4272 createTool( SMESHOp::OpEditGroup, groupTb );
4274 createTool( SMESHOp::OpMeshInformation, info );
4275 //createTool( SMESHOp::OpStdInfo, meshTb );
4276 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4277 createTool( SMESHOp::OpFindElementByPoint, info );
4279 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4280 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4281 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4283 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4284 createTool( SMESHOp::OpLength, ctrl1dTb );
4285 createTool( SMESHOp::OpConnection, ctrl1dTb );
4286 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4288 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4289 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4290 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4291 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4292 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4293 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4294 createTool( SMESHOp::OpArea, ctrl2dTb );
4295 createTool( SMESHOp::OpTaper, ctrl2dTb );
4296 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4297 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4298 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4299 createTool( SMESHOp::OpSkew, ctrl2dTb );
4300 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4301 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4302 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4304 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4305 createTool( SMESHOp::OpVolume, ctrl3dTb );
4306 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4307 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4308 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4309 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4311 createTool( SMESHOp::OpNode, addElemTb );
4312 createTool( SMESHOp::OpElem0D, addElemTb );
4313 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4314 createTool( SMESHOp::OpBall, addElemTb );
4315 createTool( SMESHOp::OpEdge, addElemTb );
4316 createTool( SMESHOp::OpTriangle, addElemTb );
4317 createTool( SMESHOp::OpQuadrangle, addElemTb );
4318 createTool( SMESHOp::OpPolygon, addElemTb );
4319 createTool( SMESHOp::OpTetrahedron, addElemTb );
4320 createTool( SMESHOp::OpHexahedron, addElemTb );
4321 createTool( SMESHOp::OpPentahedron, addElemTb );
4322 createTool( SMESHOp::OpPyramid, addElemTb );
4323 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4324 createTool( SMESHOp::OpPolyhedron, addElemTb );
4326 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4327 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4328 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4329 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4330 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4331 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4332 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4333 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4334 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4335 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4336 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4338 createTool( SMESHOp::OpRemoveNodes, remTb );
4339 createTool( SMESHOp::OpRemoveElements, remTb );
4340 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4341 createTool( SMESHOp::OpClearMesh, remTb );
4343 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4344 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4346 createTool( SMESHOp::OpMergeNodes, transformTb );
4347 createTool( SMESHOp::OpMergeElements, transformTb );
4348 createTool( SMESHOp::OpTranslation, transformTb );
4349 createTool( SMESHOp::OpRotation, transformTb );
4350 createTool( SMESHOp::OpSymmetry, transformTb );
4351 createTool( SMESHOp::OpScale, transformTb );
4352 createTool( SMESHOp::OpOffset, transformTb );
4353 createTool( SMESHOp::OpSewing, transformTb );
4354 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4356 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4357 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4358 createTool( SMESHOp::OpExtrusion, modifyTb );
4359 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4360 createTool( SMESHOp::OpRevolution, modifyTb );
4361 createTool( SMESHOp::OpOrientation, modifyTb );
4362 createTool( SMESHOp::OpReorientFaces, modifyTb );
4363 createTool( SMESHOp::OpMoveNode, modifyTb );
4364 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4365 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4366 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4367 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4368 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4369 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4370 createTool( SMESHOp::OpSmoothing, modifyTb );
4371 createTool( SMESHOp::OpPatternMapping, modifyTb );
4373 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4375 createTool( SMESHOp::OpUpdate, dispModeTb );
4377 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4378 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4382 OB = "'ObjectBrowser'",
4383 View = "'" + SVTK_Viewer::Type() + "'",
4385 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4386 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4387 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4388 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4389 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4390 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4391 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4392 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4393 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4394 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4395 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4397 mesh_part = mesh + " " + subMesh + " " + group,
4398 mesh_group = mesh + " " + group,
4399 mesh_submesh = mesh + " " + subMesh,
4400 hyp_alg = hypo + " " + algo;
4402 // popup for object browser
4404 isInvisible("not( isVisible )"),
4405 isEmpty("numberOfNodes = 0"),
4406 isNotEmpty("numberOfNodes <> 0"),
4408 // has nodes, edges, etc in VISIBLE! actor
4409 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4410 hasElems("(count( elemTypes ) > 0)"),
4411 hasDifferentElems("(count( elemTypes ) > 1)"),
4412 hasBalls("({'BallElem'} in elemTypes)"),
4413 hasElems0d("({'Elem0d'} in elemTypes)"),
4414 hasEdges("({'Edge'} in elemTypes)"),
4415 hasFaces("({'Face'} in elemTypes)"),
4416 hasVolumes("({'Volume'} in elemTypes)"),
4417 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4419 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4420 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4421 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4422 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4423 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4424 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4426 popupMgr()->insert( separator(), -1, 0 );
4427 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && isComputable" );
4428 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && isComputable" );
4429 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && isPreComputable" );
4430 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && isComputable" );
4431 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && isComputable && hasGeomReference" );
4432 createPopupItem( SMESHOp::OpUpdate, OB, mesh_part );
4433 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4434 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1" );
4435 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4436 popupMgr()->insert( separator(), -1, 0 );
4437 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4438 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4439 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4440 popupMgr()->insert( separator(), -1, 0 );
4441 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4442 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4443 popupMgr()->insert( separator(), -1, 0 );
4444 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh );
4445 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4446 popupMgr()->insert( separator(), -1, 0 );
4447 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4448 //popupMgr()->insert( separator(), -1, 0 );
4450 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4451 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4452 QString only_one_2D = only_one_non_empty + " && dim>1";
4454 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4455 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4456 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4457 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4459 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4461 createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
4462 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4463 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4464 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4465 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4466 popupMgr()->insert( separator(), -1, 0 );
4469 createPopupItem( SMESHOp::OpEditGroup, View, group );
4470 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems );
4471 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems );
4473 popupMgr()->insert( separator(), -1, 0 );
4474 createPopupItem( SMESHOp::OpUpdate, View, mesh_part );
4475 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4476 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4477 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
4478 popupMgr()->insert( separator(), -1, 0 );
4480 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4481 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4482 popupMgr()->insert( separator(), -1, 0 );
4484 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4485 QString aType = QString( "%1type in {%2}" ).arg( lc );
4486 aType = aType.arg( mesh_part );
4487 QString aMeshInVTK = aClient + "&&" + aType;
4489 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4490 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4491 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4493 //-------------------------------------------------
4495 //-------------------------------------------------
4496 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4498 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4499 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4500 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4502 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4503 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4504 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4506 popupMgr()->insert( separator(), -1, -1 );
4508 //-------------------------------------------------
4510 //-------------------------------------------------
4511 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4513 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4514 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4515 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4517 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4518 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4519 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4521 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4522 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4523 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4525 popupMgr()->insert( separator(), anId, -1 );
4527 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4528 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4529 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4531 //-------------------------------------------------
4533 //-------------------------------------------------
4534 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4536 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4538 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4539 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4540 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4542 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4543 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4544 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4546 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4547 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4548 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4550 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4551 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4552 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4554 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4555 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4556 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4558 popupMgr()->insert( separator(), anId, -1 );
4560 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4561 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + isNotEmpty, QtxPopupMgr::VisibleRule );
4563 popupMgr()->insert( separator(), anId, -1 );
4565 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4566 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4569 //-------------------------------------------------
4570 // Representation of the 2D Quadratic elements
4571 //-------------------------------------------------
4572 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4573 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4574 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4575 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4577 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4578 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4579 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4581 //-------------------------------------------------
4582 // Orientation of faces
4583 //-------------------------------------------------
4584 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4585 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4586 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4588 //-------------------------------------------------
4590 //-------------------------------------------------
4591 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4592 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4594 //-------------------------------------------------
4596 //-------------------------------------------------
4597 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4598 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4600 //-------------------------------------------------
4602 //-------------------------------------------------
4604 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4605 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4606 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4607 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4609 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4611 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4612 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4614 popupMgr()->insert( separator(), anId, -1 );
4616 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4618 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4619 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4620 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4622 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4623 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4624 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4626 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4627 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4628 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4630 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4632 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4633 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4634 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4636 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4637 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4638 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4640 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4641 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4642 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4643 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4644 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4645 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4647 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4649 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4650 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4651 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4653 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4654 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4655 QtxPopupMgr::VisibleRule );
4656 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4658 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4659 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4660 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4662 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4663 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4664 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4666 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4667 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4668 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4670 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4671 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4672 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4674 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4675 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4676 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4678 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4679 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4680 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4682 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4683 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4684 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4686 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4687 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4688 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4690 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4691 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4692 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4694 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4695 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4696 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4698 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4699 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4700 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4702 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4703 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4704 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4706 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
4707 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
4708 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
4710 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4712 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4713 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4714 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4716 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4717 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4718 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4720 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4721 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4722 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4724 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
4725 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4726 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4728 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
4729 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4730 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4732 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
4733 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4734 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4736 popupMgr()->insert( separator(), anId, -1 );
4738 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
4739 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4740 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
4741 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
4742 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4744 popupMgr()->insert( separator(), anId, -1 );
4746 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4748 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
4749 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4751 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
4752 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4753 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
4755 #ifndef DISABLE_PLOT2DVIEWER
4756 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
4757 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4760 //-------------------------------------------------
4762 //-------------------------------------------------
4763 popupMgr()->insert( separator(), -1, -1 );
4764 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4765 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4766 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
4767 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4769 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
4770 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4772 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
4773 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4775 popupMgr()->insert( separator(), -1, -1 );
4777 //-------------------------------------------------
4779 //-------------------------------------------------
4780 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
4781 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4783 popupMgr()->insert( separator(), -1, -1 );
4785 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
4786 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4787 popupMgr()->insert( separator(), -1, -1 );
4789 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4790 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4792 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4793 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4796 //================================================================================
4798 * \brief Return true if SMESH or GEOM objects are selected.
4799 * Is called form LightApp_Module::activateModule() which clear selection if
4800 * not isSelectionCompatible()
4802 //================================================================================
4804 bool SMESHGUI::isSelectionCompatible()
4806 bool isCompatible = true;
4807 SALOME_ListIO selected;
4808 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4809 Sel->selectedObjects( selected );
4811 SALOME_ListIteratorOfListIO It( selected );
4812 for ( ; isCompatible && It.More(); It.Next())
4814 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4815 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4817 return isCompatible;
4821 bool SMESHGUI::reusableOperation( const int id )
4823 // compute, evaluate and precompute are not reusable operations
4824 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
4827 bool SMESHGUI::activateModule( SUIT_Study* study )
4829 bool res = SalomeApp_Module::activateModule( study );
4831 setMenuShown( true );
4832 setToolShown( true );
4834 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4835 PyGILState_STATE gstate = PyGILState_Ensure();
4836 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4837 if ( !pluginsmanager ) {
4841 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
4846 PyGILState_Release(gstate);
4847 // end of SMESH plugins loading
4849 // Reset actions accelerator keys
4850 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
4852 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4853 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4854 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study )) {
4855 if ( _PTR(Study) aStudy = s->studyDS() )
4856 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4859 // get all view currently opened in the study and connect their signals to
4860 // the corresponding slots of the class.
4861 SUIT_Desktop* aDesk = study->application()->desktop();
4863 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4864 SUIT_ViewWindow* wnd;
4865 foreach ( wnd, wndList )
4869 Py_XDECREF(pluginsmanager);
4873 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4875 setMenuShown( false );
4876 setToolShown( false );
4878 EmitSignalCloseAllDialogs();
4880 // Unset actions accelerator keys
4881 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
4883 return SalomeApp_Module::deactivateModule( study );
4886 void SMESHGUI::studyClosed( SUIT_Study* s )
4890 SMESH::RemoveVisuData( s->id() );
4891 SalomeApp_Module::studyClosed( s );
4894 void SMESHGUI::OnGUIEvent()
4896 const QObject* obj = sender();
4897 if ( !obj || !obj->inherits( "QAction" ) )
4899 int id = actionId((QAction*)obj);
4904 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4906 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4907 if ( CORBA::is_nil( myComponentSMESH ) )
4909 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4911 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4912 return aGUI.myComponentSMESH;
4915 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4916 return myComponentSMESH;
4919 QString SMESHGUI::engineIOR() const
4921 CORBA::ORB_var anORB = getApp()->orb();
4922 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4923 return QString( anIOR.in() );
4926 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4928 SalomeApp_Module::contextMenuPopup( client, menu, title );
4930 selectionMgr()->selectedObjects( lst );
4931 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4932 Handle(SALOME_InteractiveObject) io = lst.First();
4933 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4934 _PTR(Study) study = appStudy->studyDS();
4935 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4937 QString aName = QString( SMESH::fromUtf8(obj->GetName()) );
4938 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4939 aName.remove( (aName.length() - 1), 1 );
4945 LightApp_Selection* SMESHGUI::createSelection() const
4947 return new SMESHGUI_Selection();
4950 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4952 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4953 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
4954 #ifndef DISABLE_PYCONSOLE
4955 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4959 void SMESHGUI::viewManagers( QStringList& list ) const
4961 list.append( SVTK_Viewer::Type() );
4964 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4966 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4967 SMESH::UpdateSelectionProp( this );
4969 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4970 for(int i = 0; i < aViews.count() ; i++){
4971 SUIT_ViewWindow *sf = aViews[i];
4974 EmitSignalActivatedViewManager();
4978 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4980 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4981 myClippingPlaneInfoMap.erase( theViewManager );
4984 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4986 theActor->AddObserver( SMESH::DeleteActorEvent,
4987 myEventCallbackCommand.GetPointer(),
4991 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4992 unsigned long theEvent,
4993 void* theClientData,
4996 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4997 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
4998 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4999 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5000 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5001 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5002 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5003 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5004 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5005 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5006 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5007 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5008 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5009 if( anActor == *anIter3 ) {
5010 anActorList.erase( anIter3 );
5021 void SMESHGUI::createPreferences()
5023 // General tab ------------------------------------------------------------------------
5024 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5026 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5027 setPreferenceProperty( autoUpdate, "columns", 2 );
5028 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5029 setPreferenceProperty( lim, "min", 0 );
5030 setPreferenceProperty( lim, "max", 100000000 );
5031 setPreferenceProperty( lim, "step", 1000 );
5032 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5033 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5035 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5036 setPreferenceProperty( dispgroup, "columns", 2 );
5037 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5039 modes.append( tr("MEN_WIRE") );
5040 modes.append( tr("MEN_SHADE") );
5041 modes.append( tr("MEN_NODES") );
5042 modes.append( tr("MEN_SHRINK") );
5043 QList<QVariant> indices;
5044 indices.append( 0 );
5045 indices.append( 1 );
5046 indices.append( 2 );
5047 indices.append( 3 );
5048 setPreferenceProperty( dispmode, "strings", modes );
5049 setPreferenceProperty( dispmode, "indexes", indices );
5051 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5052 setPreferenceProperty( arcgroup, "columns", 2 );
5053 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5054 QStringList quadraticModes;
5055 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5056 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5058 indices.append( 0 );
5059 indices.append( 1 );
5060 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5061 setPreferenceProperty( quadraticmode, "indexes", indices );
5063 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5064 "SMESH", "max_angle" );
5065 setPreferenceProperty( maxAngle, "min", 1 );
5066 setPreferenceProperty( maxAngle, "max", 90 );
5068 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5069 setPreferenceProperty( qaGroup, "columns", 2 );
5070 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5071 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5072 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5073 setPreferenceProperty( prec, "min", 0 );
5074 setPreferenceProperty( prec, "max", 100 );
5075 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5076 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5077 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5078 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5079 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5082 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5083 setPreferenceProperty( exportgroup, "columns", 2 );
5084 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5085 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5086 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5088 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5089 setPreferenceProperty( computeGroup, "columns", 2 );
5090 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5092 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5093 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5094 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5096 indices.append( 0 );
5097 indices.append( 1 );
5098 indices.append( 2 );
5099 setPreferenceProperty( notifyMode, "strings", modes );
5100 setPreferenceProperty( notifyMode, "indexes", indices );
5102 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5103 setPreferenceProperty( infoGroup, "columns", 2 );
5104 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5106 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5107 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5109 indices.append( 0 );
5110 indices.append( 1 );
5111 setPreferenceProperty( elemInfo, "strings", modes );
5112 setPreferenceProperty( elemInfo, "indexes", indices );
5113 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5114 setPreferenceProperty( nodesLim, "min", 0 );
5115 setPreferenceProperty( nodesLim, "max", 10000000 );
5116 setPreferenceProperty( nodesLim, "step", 10000 );
5117 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5118 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5119 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5120 setPreferenceProperty( ctrlLim, "min", 0 );
5121 setPreferenceProperty( ctrlLim, "max", 10000000 );
5122 setPreferenceProperty( ctrlLim, "step", 1000 );
5123 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5124 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5125 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5126 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5127 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5129 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5130 setPreferenceProperty( segGroup, "columns", 2 );
5131 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5132 "SMESH", "segmentation" );
5133 setPreferenceProperty( segLen, "min", 1 );
5134 setPreferenceProperty( segLen, "max", 10000000 );
5135 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5136 "SMESH", "nb_segments_per_edge" );
5137 setPreferenceProperty( nbSeg, "min", 1 );
5138 setPreferenceProperty( nbSeg, "max", 10000000 );
5140 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5141 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5142 "SMESH", "forget_mesh_on_hyp_modif" );
5145 // Quantities with individual precision settings
5146 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5147 setPreferenceProperty( precGroup, "columns", 2 );
5149 const int nbQuantities = 6;
5150 int precs[nbQuantities], ii = 0;
5151 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5152 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5153 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5154 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5155 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5156 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5157 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5158 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5159 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5160 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5161 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5162 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5164 // Set property for precision value for spinboxes
5165 for ( ii = 0; ii < nbQuantities; ii++ ){
5166 setPreferenceProperty( precs[ii], "min", -14 );
5167 setPreferenceProperty( precs[ii], "max", 14 );
5168 setPreferenceProperty( precs[ii], "precision", 2 );
5171 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5172 setPreferenceProperty( previewGroup, "columns", 2 );
5173 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5174 setPreferenceProperty( chunkSize, "min", 1 );
5175 setPreferenceProperty( chunkSize, "max", 1000 );
5176 setPreferenceProperty( chunkSize, "step", 50 );
5178 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5179 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5181 // Mesh tab ------------------------------------------------------------------------
5182 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5183 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5184 setPreferenceProperty( nodeGroup, "columns", 3 );
5186 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5188 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5190 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5191 QList<QVariant> aMarkerTypeIndicesList;
5192 QList<QVariant> aMarkerTypeIconsList;
5193 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5194 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5195 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5196 aMarkerTypeIndicesList << i;
5197 aMarkerTypeIconsList << pixmap;
5199 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5200 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5202 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5204 QList<QVariant> aMarkerScaleIndicesList;
5205 QStringList aMarkerScaleValuesList;
5206 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5207 aMarkerScaleIndicesList << i;
5208 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5209 aMarkerScaleValuesList << QString::number( i );
5211 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5212 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5214 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5215 //setPreferenceProperty( elemGroup, "columns", 2 );
5217 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5218 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5219 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5220 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5221 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5222 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5223 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5224 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5225 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5228 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5229 setPreferenceProperty( grpGroup, "columns", 2 );
5231 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5232 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5234 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5235 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5236 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5237 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5238 double ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5239 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5240 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5241 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5242 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5243 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5244 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5245 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5246 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5247 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5249 setPreferenceProperty( size0d, "min", 1 );
5250 setPreferenceProperty( size0d, "max", 10 );
5252 // setPreferenceProperty( ballSize, "min", 1 );
5253 // setPreferenceProperty( ballSize, "max", 10 );
5255 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5256 setPreferenceProperty( ballDiameter, "max", 1e9 );
5257 setPreferenceProperty( ballDiameter, "step", 0.1 );
5259 setPreferenceProperty( ballScale, "min", 1e-2 );
5260 setPreferenceProperty( ballScale, "max", 1e7 );
5261 setPreferenceProperty( ballScale, "step", 0.5 );
5263 setPreferenceProperty( elemW, "min", 1 );
5264 setPreferenceProperty( elemW, "max", 5 );
5266 setPreferenceProperty( outW, "min", 1 );
5267 setPreferenceProperty( outW, "max", 5 );
5269 setPreferenceProperty( shrink, "min", 0 );
5270 setPreferenceProperty( shrink, "max", 100 );
5272 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5273 setPreferenceProperty( numGroup, "columns", 2 );
5275 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5276 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5278 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5279 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5281 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5282 setPreferenceProperty( orientGroup, "columns", 1 );
5284 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5285 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5287 setPreferenceProperty( orientScale, "min", 0.05 );
5288 setPreferenceProperty( orientScale, "max", 0.5 );
5289 setPreferenceProperty( orientScale, "step", 0.05 );
5291 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5293 // Selection tab ------------------------------------------------------------------------
5294 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5296 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5297 setPreferenceProperty( selGroup, "columns", 2 );
5299 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5300 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5302 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5303 setPreferenceProperty( preGroup, "columns", 2 );
5305 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5307 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5308 setPreferenceProperty( precSelGroup, "columns", 2 );
5310 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5311 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5312 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5314 // Scalar Bar tab ------------------------------------------------------------------------
5315 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5316 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5317 setPreferenceProperty( fontGr, "columns", 2 );
5319 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5320 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5322 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5323 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5325 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5326 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5328 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5329 setPreferenceProperty( numcol, "min", 2 );
5330 setPreferenceProperty( numcol, "max", 256 );
5332 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5333 setPreferenceProperty( numlab, "min", 2 );
5334 setPreferenceProperty( numlab, "max", 65 );
5336 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5337 setPreferenceProperty( orientGr, "columns", 2 );
5338 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5339 QStringList orients;
5340 orients.append( tr( "SMESH_VERTICAL" ) );
5341 orients.append( tr( "SMESH_HORIZONTAL" ) );
5342 indices.clear(); indices.append( 0 ); indices.append( 1 );
5343 setPreferenceProperty( orient, "strings", orients );
5344 setPreferenceProperty( orient, "indexes", indices );
5346 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5347 setPreferenceProperty( posVSizeGr, "columns", 2 );
5348 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5349 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5350 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5351 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5352 setPreferenceProperty( xv, "step", 0.1 );
5353 setPreferenceProperty( xv, "min", 0.0 );
5354 setPreferenceProperty( xv, "max", 1.0 );
5355 setPreferenceProperty( yv, "step", 0.1 );
5356 setPreferenceProperty( yv, "min", 0.0 );
5357 setPreferenceProperty( yv, "max", 1.0 );
5358 setPreferenceProperty( wv, "step", 0.1 );
5359 setPreferenceProperty( wv, "min", 0.0 );
5360 setPreferenceProperty( wv, "max", 1.0 );
5361 setPreferenceProperty( hv, "min", 0.0 );
5362 setPreferenceProperty( hv, "max", 1.0 );
5363 setPreferenceProperty( hv, "step", 0.1 );
5365 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5366 setPreferenceProperty( posHSizeGr, "columns", 2 );
5367 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5368 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5369 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5370 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5371 setPreferenceProperty( xv, "min", 0.0 );
5372 setPreferenceProperty( xv, "max", 1.0 );
5373 setPreferenceProperty( xv, "step", 0.1 );
5374 setPreferenceProperty( xh, "min", 0.0 );
5375 setPreferenceProperty( xh, "max", 1.0 );
5376 setPreferenceProperty( xh, "step", 0.1 );
5377 setPreferenceProperty( yh, "min", 0.0 );
5378 setPreferenceProperty( yh, "max", 1.0 );
5379 setPreferenceProperty( yh, "step", 0.1 );
5380 setPreferenceProperty( wh, "min", 0.0 );
5381 setPreferenceProperty( wh, "max", 1.0 );
5382 setPreferenceProperty( wh, "step", 0.1 );
5383 setPreferenceProperty( hh, "min", 0.0 );
5384 setPreferenceProperty( hh, "max", 1.0 );
5385 setPreferenceProperty( hh, "step", 0.1 );
5387 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5388 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5389 setPreferenceProperty( distributionGr, "columns", 3 );
5391 types.append( tr( "SMESH_MONOCOLOR" ) );
5392 types.append( tr( "SMESH_MULTICOLOR" ) );
5393 indices.clear(); indices.append( 0 ); indices.append( 1 );
5394 setPreferenceProperty( coloringType, "strings", types );
5395 setPreferenceProperty( coloringType, "indexes", indices );
5396 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5400 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5402 if ( sect=="SMESH" ) {
5403 float sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5404 float aTol = 1.00000009999999;
5405 std::string aWarning;
5406 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5408 if ( name== "selection_object_color" ||
5409 name=="selection_element_color" ||
5410 name== "highlight_color" ||
5411 name=="selection_precision_node" ||
5412 name=="selection_precision_element" ||
5413 name=="selection_precision_object" )
5415 SMESH::UpdateSelectionProp( this );
5417 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5419 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5420 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5421 if ( sbX1+sbW > aTol ) {
5422 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5425 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5426 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5429 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5431 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5432 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5433 if ( sbY1 + sbH > aTol ) {
5434 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5435 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5436 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5439 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5441 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5442 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5443 if ( sbX1 + sbW > aTol ) {
5444 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5447 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5448 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5451 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5453 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5454 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5455 if ( sbY1 + sbH > aTol ) {
5456 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5459 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5460 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5463 else if ( name == "segmentation" )
5465 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5466 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5468 else if ( name == "nb_segments_per_edge" )
5470 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5471 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5473 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5475 QString val = aResourceMgr->stringValue( "SMESH", name );
5476 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5478 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5480 SMESH::UpdateFontProp( this );
5482 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5484 SMESH::UpdateFontProp( this );
5487 if ( aWarning.size() != 0 ) {
5488 aWarning += "The default values are applied instead.";
5489 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5490 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5491 QObject::tr(aWarning.c_str()));
5496 //================================================================================
5498 * \brief Update something in accordance with update flags
5499 * \param theFlags - update flags
5501 * Update viewer or/and object browser etc. in accordance with update flags ( see
5502 * LightApp_UpdateFlags enumeration ).
5504 //================================================================================
5505 void SMESHGUI::update( const int flags )
5507 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5508 SMESH::UpdateView();
5510 SalomeApp_Module::update( flags );
5513 //================================================================================
5515 * \brief Set default selection mode
5517 * SLOT called when operation commited. Sets default selection mode
5519 //================================================================================
5520 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5522 SVTK_ViewWindow* vtkWnd =
5523 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5525 vtkWnd->SetSelectionMode( ActorSelection );
5528 //================================================================================
5530 * \brief Set default selection mode
5532 * SLOT called when operation aborted. Sets default selection mode
5534 //================================================================================
5535 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5537 SVTK_ViewWindow* vtkWnd =
5538 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5540 vtkWnd->SetSelectionMode( ActorSelection );
5543 //================================================================================
5545 * \brief Creates operation with given identifier
5546 * \param id - identifier of operation to be started
5547 * \return Pointer on created operation or NULL if operation is not created
5549 * Virtual method redefined from the base class creates operation with given id.
5550 * It is called called automatically from startOperation method of base class.
5552 //================================================================================
5553 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5555 LightApp_Operation* op = 0;
5556 // to do : create operation here
5559 case SMESHOp::OpSplitBiQuadratic:
5560 op = new SMESHGUI_SplitBiQuadOp();
5562 case SMESHOp::OpConvertMeshToQuadratic:
5563 op = new SMESHGUI_ConvToQuadOp();
5565 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5566 op = new SMESHGUI_Make2DFrom3DOp();
5568 case SMESHOp::OpReorientFaces:
5569 op = new SMESHGUI_ReorientFacesOp();
5571 case SMESHOp::OpCreateMesh:
5572 op = new SMESHGUI_MeshOp( true, true );
5574 case SMESHOp::OpCreateSubMesh:
5575 op = new SMESHGUI_MeshOp( true, false );
5577 case SMESHOp::OpEditMeshOrSubMesh:
5578 case SMESHOp::OpEditMesh:
5579 case SMESHOp::OpEditSubMesh:
5580 op = new SMESHGUI_MeshOp( false );
5582 case SMESHOp::OpCompute:
5583 case SMESHOp::OpComputeSubMesh:
5584 op = new SMESHGUI_ComputeOp();
5586 case SMESHOp::OpPreCompute:
5587 op = new SMESHGUI_PrecomputeOp();
5589 case SMESHOp::OpEvaluate:
5590 op = new SMESHGUI_EvaluateOp();
5592 case SMESHOp::OpMeshOrder:
5593 op = new SMESHGUI_MeshOrderOp();
5595 case SMESHOp::OpCreateGeometryGroup:
5596 op = new SMESHGUI_GroupOnShapeOp();
5598 case SMESHOp::OpFindElementByPoint:
5599 op = new SMESHGUI_FindElemByPointOp();
5601 case SMESHOp::OpMoveNode: // Make mesh pass through point
5602 op = new SMESHGUI_MakeNodeAtPointOp();
5604 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5605 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5612 op = SalomeApp_Module::createOperation( id );
5616 //================================================================================
5618 * \brief Stops current operations and starts a given one
5619 * \param id - The id of the operation to start
5621 //================================================================================
5623 void SMESHGUI::switchToOperation(int id)
5625 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5626 activeStudy()->abortAllOperations();
5627 startOperation( id );
5630 LightApp_Displayer* SMESHGUI::displayer()
5633 myDisplayer = new SMESHGUI_Displayer( getApp() );
5637 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5640 int aTolerance = 64;
5641 int anIterations = 0;
5647 if( anIterations % aPeriod == 0 )
5650 if( aTolerance < 1 )
5654 aHue = (int)( 360.0 * rand() / RAND_MAX );
5657 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5658 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5659 for( ; it != itEnd; ++it )
5661 SALOMEDS::Color anAutoColor = *it;
5662 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5665 aQColor.getHsv( &h, &s, &v );
5666 if( abs( h - aHue ) < aTolerance )
5678 aColor.setHsv( aHue, 255, 255 );
5680 SALOMEDS::Color aSColor;
5681 aSColor.R = aColor.redF();
5682 aSColor.G = aColor.greenF();
5683 aSColor.B = aColor.blueF();
5688 const char* gSeparator = "_"; // character used to separate parameter names
5689 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5690 const char* gPathSep = "|"; // character used to separate paths
5693 * \brief Store visual parameters
5695 * This method is called just before the study document is saved.
5696 * Store visual parameters in AttributeParameter attribue(s)
5698 void SMESHGUI::storeVisualParameters (int savePoint)
5701 Kernel_Utils::Localizer loc;
5703 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5704 if (!appStudy || !appStudy->studyDS())
5706 _PTR(Study) studyDS = appStudy->studyDS();
5708 // componentName is used for encoding of entries when storing them in IParameters
5709 std::string componentName = myComponentSMESH->ComponentDataType();
5710 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5711 //if (!aSComponent) return;
5714 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5715 componentName.c_str(),
5717 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5719 // store map of custom markers
5720 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5721 if( !aMarkerMap.empty() )
5723 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5724 for( ; anIter != aMarkerMap.end(); anIter++ )
5726 int anId = anIter->first;
5727 VTK::MarkerData aMarkerData = anIter->second;
5728 std::string aMarkerFileName = aMarkerData.first;
5729 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5730 if( aMarkerTexture.size() < 3 )
5731 continue; // should contain at least width, height and the first value
5733 QString aPropertyName( "texture" );
5734 aPropertyName += gSeparator;
5735 aPropertyName += QString::number( anId );
5737 QString aPropertyValue = aMarkerFileName.c_str();
5738 aPropertyValue += gPathSep;
5740 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5741 ushort aWidth = *aTextureIter++;
5742 ushort aHeight = *aTextureIter++;
5743 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5744 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5745 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5746 aPropertyValue += QString::number( *aTextureIter );
5748 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5752 // viewers counters are used for storing view_numbers in IParameters
5755 // main cycle to store parameters of displayed objects
5756 QList<SUIT_ViewManager*> lst;
5757 QList<SUIT_ViewManager*>::Iterator it;
5758 getApp()->viewManagers(lst);
5759 for (it = lst.begin(); it != lst.end(); it++)
5761 SUIT_ViewManager* vman = *it;
5762 QString vType = vman->getType();
5764 // saving VTK actors properties
5765 if (vType == SVTK_Viewer::Type())
5767 // store the clipping planes attached to the view manager
5768 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5769 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5770 if( anIter != myClippingPlaneInfoMap.end() )
5771 aClippingPlaneInfoList = anIter->second;
5773 if( !aClippingPlaneInfoList.empty() ) {
5774 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5775 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5777 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5778 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5780 QString aPropertyName( "ClippingPlane" );
5781 aPropertyName += gSeparator;
5782 aPropertyName += QString::number( vtkViewers );
5783 aPropertyName += gSeparator;
5784 aPropertyName += QString::number( anId );
5786 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5787 aPropertyValue += gDigitsSep;
5788 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5789 aPropertyValue += gDigitsSep;
5790 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5791 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5792 aPropertyValue += gDigitsSep;
5793 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5794 aPropertyValue += gDigitsSep;
5795 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5796 aPropertyValue += gDigitsSep;
5797 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5798 aPropertyValue += gDigitsSep;
5799 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5800 aPropertyValue += gDigitsSep;
5801 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5802 aPropertyValue += gDigitsSep;
5803 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5805 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5806 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5807 aPropertyValue += gDigitsSep;
5808 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5809 aPropertyValue += gDigitsSep;
5810 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5811 aPropertyValue += gDigitsSep;
5812 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5815 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5819 QVector<SUIT_ViewWindow*> views = vman->getViews();
5820 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5822 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5824 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5825 vtkActorCollection* allActors = aCopy.GetActors();
5826 allActors->InitTraversal();
5827 while (vtkActor* actor = allActors->GetNextActor())
5829 if (actor->GetVisibility()) // store only visible actors
5831 SMESH_Actor* aSmeshActor = 0;
5832 if (actor->IsA("SMESH_Actor"))
5833 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5834 if (aSmeshActor && aSmeshActor->hasIO())
5836 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5839 // entry is "encoded" = it does NOT contain component adress,
5840 // since it is a subject to change on next component loading
5841 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5843 std::string param, vtkParam = vType.toLatin1().data();
5844 vtkParam += gSeparator;
5845 vtkParam += QString::number(vtkViewers).toLatin1().data();
5846 vtkParam += gSeparator;
5849 param = vtkParam + "Visibility";
5850 ip->setParameter(entry, param, "On");
5853 param = vtkParam + "Representation";
5854 ip->setParameter(entry, param, QString::number
5855 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5858 param = vtkParam + "IsShrunk";
5859 ip->setParameter(entry, param, QString::number
5860 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5862 // Displayed entities
5863 unsigned int aMode = aSmeshActor->GetEntityMode();
5864 bool isE = aMode & SMESH_Actor::eEdges;
5865 bool isF = aMode & SMESH_Actor::eFaces;
5866 bool isV = aMode & SMESH_Actor::eVolumes;
5867 bool is0d = aMode & SMESH_Actor::e0DElements;
5868 bool isB = aMode & SMESH_Actor::eBallElem;
5870 QString modeStr ("e");
5871 modeStr += gDigitsSep; modeStr += QString::number(isE);
5872 modeStr += gDigitsSep; modeStr += "f";
5873 modeStr += gDigitsSep; modeStr += QString::number(isF);
5874 modeStr += gDigitsSep; modeStr += "v";
5875 modeStr += gDigitsSep; modeStr += QString::number(isV);
5876 modeStr += gDigitsSep; modeStr += "0d";
5877 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5878 modeStr += gDigitsSep; modeStr += "b";
5879 modeStr += gDigitsSep; modeStr += QString::number(isB);
5881 param = vtkParam + "Entities";
5882 ip->setParameter(entry, param, modeStr.toLatin1().data());
5888 aSmeshActor->GetSufaceColor(r, g, b, delta);
5889 QStringList colorStr;
5890 colorStr << "surface";
5891 colorStr << QString::number(r);
5892 colorStr << QString::number(g);
5893 colorStr << QString::number(b);
5895 colorStr << "backsurface";
5896 colorStr << QString::number(delta);
5898 aSmeshActor->GetVolumeColor(r, g, b, delta);
5899 colorStr << "volume";
5900 colorStr << QString::number(r);
5901 colorStr << QString::number(g);
5902 colorStr << QString::number(b);
5903 colorStr << QString::number(delta);
5905 aSmeshActor->GetEdgeColor(r, g, b);
5907 colorStr << QString::number(r);
5908 colorStr << QString::number(g);
5909 colorStr << QString::number(b);
5911 aSmeshActor->GetNodeColor(r, g, b);
5913 colorStr << QString::number(r);
5914 colorStr << QString::number(g);
5915 colorStr << QString::number(b);
5917 aSmeshActor->GetOutlineColor(r, g, b);
5918 colorStr << "outline";
5919 colorStr << QString::number(r);
5920 colorStr << QString::number(g);
5921 colorStr << QString::number(b);
5923 aSmeshActor->Get0DColor(r, g, b);
5924 colorStr << "elem0d";
5925 colorStr << QString::number(r);
5926 colorStr << QString::number(g);
5927 colorStr << QString::number(b);
5929 aSmeshActor->GetBallColor(r, g, b);
5931 colorStr << QString::number(r);
5932 colorStr << QString::number(g);
5933 colorStr << QString::number(b);
5935 aSmeshActor->GetFacesOrientationColor(r, g, b);
5936 colorStr << "orientation";
5937 colorStr << QString::number(r);
5938 colorStr << QString::number(g);
5939 colorStr << QString::number(b);
5941 param = vtkParam + "Colors";
5942 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5945 QStringList sizeStr;
5947 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5948 sizeStr << "outline";
5949 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5950 sizeStr << "elem0d";
5951 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5953 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5954 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
5955 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
5956 sizeStr << "shrink";
5957 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5958 sizeStr << "orientation";
5959 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5960 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5962 param = vtkParam + "Sizes";
5963 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5968 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5969 if( aMarkerType == VTK::MT_USER ) {
5970 markerStr += "custom";
5971 markerStr += gDigitsSep;
5972 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5976 markerStr += gDigitsSep;
5977 markerStr += QString::number( (int)aMarkerType );
5978 markerStr += gDigitsSep;
5979 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5982 param = vtkParam + "PointMarker";
5983 ip->setParameter(entry, param, markerStr.toLatin1().data());
5986 param = vtkParam + "Opacity";
5987 ip->setParameter(entry, param,
5988 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5991 param = vtkParam + "ClippingPlane";
5993 if( !aClippingPlaneInfoList.empty() ) {
5994 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5995 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5997 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5998 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5999 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6000 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6001 if( aSmeshActor == *anIter2 ) {
6002 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6003 QString::number( anId ).toLatin1().constData() );
6010 ip->setParameter( entry, param, "Off" );
6011 } // if (io->hasEntry())
6012 } // SMESH_Actor && hasIO
6014 } // while.. actors traversal
6018 } // if (SVTK view model)
6019 } // for (viewManagers)
6022 // data structures for clipping planes processing
6026 bool isOpenGLClipping;
6027 vtkIdType RelativeOrientation;
6030 int AbsoluteOrientation;
6031 double X, Y, Z, Dx, Dy, Dz;
6033 typedef std::list<TPlaneData> TPlaneDataList;
6034 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6036 typedef std::list<vtkActor*> TActorList;
6039 TActorList ActorList;
6040 SUIT_ViewManager* ViewManager;
6042 typedef std::list<TPlaneInfo> TPlaneInfoList;
6043 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6046 * \brief Restore visual parameters
6048 * This method is called after the study document is opened.
6049 * Restore visual parameters from AttributeParameter attribue(s)
6051 void SMESHGUI::restoreVisualParameters (int savePoint)
6054 Kernel_Utils::Localizer loc;
6056 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6057 if (!appStudy || !appStudy->studyDS())
6059 _PTR(Study) studyDS = appStudy->studyDS();
6061 // componentName is used for encoding of entries when storing them in IParameters
6062 std::string componentName = myComponentSMESH->ComponentDataType();
6063 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
6064 //if (!aSComponent) return;
6067 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6068 componentName.c_str(),
6070 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6072 // restore map of custom markers and map of clipping planes
6073 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
6074 TPlaneDataMap aPlaneDataMap;
6076 std::vector<std::string> properties = ip->getProperties();
6077 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6079 std::string property = *propIt;
6080 QString aPropertyName( property.c_str() );
6081 QString aPropertyValue( ip->getProperty( property ).c_str() );
6083 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6084 if( aPropertyNameList.isEmpty() )
6087 QString aPropertyType = aPropertyNameList[0];
6088 if( aPropertyType == "texture" )
6090 if( aPropertyNameList.size() != 2 )
6094 int anId = aPropertyNameList[1].toInt( &ok );
6095 if( !ok || anId < 1 )
6098 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6099 if( aPropertyValueList.size() != 2 )
6102 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6103 QString aMarkerTextureString = aPropertyValueList[1];
6104 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6105 if( aMarkerTextureStringList.size() != 3 )
6109 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6114 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6118 VTK::MarkerTexture aMarkerTexture;
6119 aMarkerTexture.push_back( aWidth );
6120 aMarkerTexture.push_back( aHeight );
6122 QString aMarkerTextureData = aMarkerTextureStringList[2];
6123 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6125 QChar aChar = aMarkerTextureData.at( i );
6126 if( aChar.isDigit() )
6127 aMarkerTexture.push_back( aChar.digitValue() );
6130 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6132 else if( aPropertyType == "ClippingPlane" )
6134 if( aPropertyNameList.size() != 3 )
6138 int aViewId = aPropertyNameList[1].toInt( &ok );
6139 if( !ok || aViewId < 0 )
6143 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6144 if( !ok || aClippingPlaneId < 0 )
6147 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6148 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6151 TPlaneData aPlaneData;
6152 aPlaneData.AbsoluteOrientation = false;
6153 aPlaneData.RelativeOrientation = 0;
6154 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6155 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6156 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6158 aPlaneData.Id = aClippingPlaneId;
6161 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6166 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6170 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6173 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6178 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6183 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6188 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6193 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6198 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6203 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6207 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6209 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6214 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6219 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6224 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6229 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6230 aPlaneDataList.push_back( aPlaneData );
6234 TPlaneInfoMap aPlaneInfoMap;
6236 std::vector<std::string> entries = ip->getEntries();
6238 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6240 // entry is a normal entry - it should be "decoded" (setting base adress of component)
6241 QString entry (ip->decodeEntry(*entIt).c_str());
6243 // Check that the entry corresponds to a real object in the Study
6244 // as the object may be deleted or modified after the visual state is saved.
6245 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6246 if (!so) continue; //Skip the not existent entry
6248 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6249 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6251 std::vector<std::string>::iterator namesIt = paramNames.begin();
6252 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6254 // actors are stored in a map after displaying of them for
6255 // quicker access in the future: map < viewID to actor >
6256 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6258 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6260 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6261 // '_' is used as separator and should not be used in viewer type or parameter names.
6262 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6263 if (lst.size() != 3)
6266 QString viewerTypStr = lst[0];
6267 QString viewIndexStr = lst[1];
6268 QString paramNameStr = lst[2];
6271 int viewIndex = viewIndexStr.toUInt(&ok);
6272 if (!ok) // bad conversion of view index to integer
6276 if (viewerTypStr == SVTK_Viewer::Type())
6278 SMESH_Actor* aSmeshActor = 0;
6279 if (vtkActors.IsBound(viewIndex))
6280 aSmeshActor = vtkActors.Find(viewIndex);
6282 QList<SUIT_ViewManager*> lst;
6283 getApp()->viewManagers(viewerTypStr, lst);
6285 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6286 SUIT_ViewManager* vman = NULL;
6287 if (viewIndex >= 0 && viewIndex < lst.count())
6288 vman = lst.at(viewIndex);
6290 if (paramNameStr == "Visibility")
6292 if (!aSmeshActor && displayer() && vman)
6294 SUIT_ViewModel* vmodel = vman->getViewModel();
6295 // SVTK view model can be casted to SALOME_View
6296 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6298 // store displayed actor in a temporary map for quicker
6299 // access later when restoring other parameters
6300 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6301 vtkRenderer* Renderer = vtkView->getRenderer();
6302 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6303 vtkActorCollection* theActors = aCopy.GetActors();
6304 theActors->InitTraversal();
6305 bool isFound = false;
6306 vtkActor *ac = theActors->GetNextActor();
6307 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6308 if (ac->IsA("SMESH_Actor")) {
6309 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6310 if (aGeomAc->hasIO()) {
6311 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6312 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6314 vtkActors.Bind(viewIndex, aGeomAc);
6320 } // if (paramNameStr == "Visibility")
6323 // the rest properties "work" with SMESH_Actor
6326 QString val ((*valuesIt).c_str());
6329 if (paramNameStr == "Representation") {
6330 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6333 else if (paramNameStr == "IsShrunk") {
6335 if (!aSmeshActor->IsShrunk())
6336 aSmeshActor->SetShrink();
6339 if (aSmeshActor->IsShrunk())
6340 aSmeshActor->UnShrink();
6343 // Displayed entities
6344 else if (paramNameStr == "Entities") {
6345 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6346 int aEntityMode = SMESH_Actor::eAllEntity;
6347 for ( int i = 0; i < mode.count(); i+=2 ) {
6348 if ( i < mode.count()-1 ) {
6349 QString type = mode[i];
6350 bool val = mode[i+1].toInt();
6351 if ( type == "e" && !val )
6352 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6353 else if ( type == "f" && !val )
6354 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6355 else if ( type == "v" && !val )
6356 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6357 else if ( type == "0d" && !val )
6358 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6359 else if ( type == "b" && !val )
6360 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6363 aSmeshActor->SetEntityMode( aEntityMode );
6366 else if (paramNameStr == "Colors") {
6367 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6374 QColor outlineColor;
6375 QColor orientationColor;
6381 // below lines are required to get default values for delta coefficients
6382 // of backface color for faces and color of reversed volumes
6383 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6384 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6385 for ( int i = 0; i < colors.count(); i++ ) {
6386 QString type = colors[i];
6387 if ( type == "surface" ) {
6388 // face color is set by 3 values r:g:b, where
6389 // - r,g,b - is rgb color components
6390 if ( i+1 >= colors.count() ) break; // format error
6391 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6392 if ( i+2 >= colors.count() ) break; // format error
6393 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6394 if ( i+3 >= colors.count() ) break; // format error
6395 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6396 faceColor.setRgbF( r, g, b );
6399 else if ( type == "backsurface" ) {
6400 // backface color can be defined in several ways
6401 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6402 // - in latest versions, it is set as delta coefficient
6403 bool rgbOk = false, deltaOk;
6404 if ( i+1 >= colors.count() ) break; // format error
6405 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6406 int delta = colors[i+1].toInt( &deltaOk );
6408 if ( i+1 < colors.count() ) // index is shifted to 1
6409 g = colors[i+1].toDouble( &rgbOk );
6410 if ( rgbOk ) i++; // shift index
6411 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6412 b = colors[i+1].toDouble( &rgbOk );
6414 // - as currently there's no way to set directly backsurface color as it was before,
6415 // we ignore old dump where r,g,b triple was set
6416 // - also we check that delta parameter is set properly
6417 if ( !rgbOk && deltaOk )
6420 else if ( type == "volume" ) {
6421 // volume color is set by 4 values r:g:b:delta, where
6422 // - r,g,b - is a normal volume rgb color components
6423 // - delta - is a reversed volume color delta coefficient
6424 if ( i+1 >= colors.count() ) break; // format error
6425 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6426 if ( i+2 >= colors.count() ) break; // format error
6427 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6428 if ( i+3 >= colors.count() ) break; // format error
6429 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6430 if ( i+4 >= colors.count() ) break; // format error
6431 int delta = colors[i+4].toInt( &bOk );
6432 if ( !bOk ) break; // format error
6433 volumeColor.setRgbF( r, g, b );
6437 else if ( type == "edge" ) {
6438 // edge color is set by 3 values r:g:b, where
6439 // - r,g,b - is rgb color components
6440 if ( i+1 >= colors.count() ) break; // format error
6441 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6442 if ( i+2 >= colors.count() ) break; // format error
6443 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6444 if ( i+3 >= colors.count() ) break; // format error
6445 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6446 edgeColor.setRgbF( r, g, b );
6449 else if ( type == "node" ) {
6450 // node color is set by 3 values r:g:b, where
6451 // - r,g,b - is rgb color components
6452 if ( i+1 >= colors.count() ) break; // format error
6453 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6454 if ( i+2 >= colors.count() ) break; // format error
6455 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6456 if ( i+3 >= colors.count() ) break; // format error
6457 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6458 nodeColor.setRgbF( r, g, b );
6461 else if ( type == "elem0d" ) {
6462 // 0d element color is set by 3 values r:g:b, where
6463 // - r,g,b - is rgb color components
6464 if ( i+1 >= colors.count() ) break; // format error
6465 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6466 if ( i+2 >= colors.count() ) break; // format error
6467 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6468 if ( i+3 >= colors.count() ) break; // format error
6469 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6470 elem0dColor.setRgbF( r, g, b );
6473 else if ( type == "ball" ) {
6474 // ball color is set by 3 values r:g:b, where
6475 // - r,g,b - is rgb color components
6476 if ( i+1 >= colors.count() ) break; // format error
6477 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6478 if ( i+2 >= colors.count() ) break; // format error
6479 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6480 if ( i+3 >= colors.count() ) break; // format error
6481 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6482 ballColor.setRgbF( r, g, b );
6485 else if ( type == "outline" ) {
6486 // outline color is set by 3 values r:g:b, where
6487 // - r,g,b - is rgb color components
6488 if ( i+1 >= colors.count() ) break; // format error
6489 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6490 if ( i+2 >= colors.count() ) break; // format error
6491 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6492 if ( i+3 >= colors.count() ) break; // format error
6493 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6494 outlineColor.setRgbF( r, g, b );
6497 else if ( type == "orientation" ) {
6498 // orientation color is set by 3 values r:g:b, where
6499 // - r,g,b - is rgb color components
6500 if ( i+1 >= colors.count() ) break; // format error
6501 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6502 if ( i+2 >= colors.count() ) break; // format error
6503 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6504 if ( i+3 >= colors.count() ) break; // format error
6505 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6506 orientationColor.setRgbF( r, g, b );
6511 if ( nodeColor.isValid() )
6512 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6514 if ( edgeColor.isValid() )
6515 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6517 if ( faceColor.isValid() )
6518 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6520 if ( volumeColor.isValid() )
6521 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6522 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6523 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6525 if ( elem0dColor.isValid() )
6526 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6528 if ( ballColor.isValid() )
6529 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6531 if ( outlineColor.isValid() )
6532 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6533 // orientation color
6534 if ( orientationColor.isValid() )
6535 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6538 else if (paramNameStr == "Sizes") {
6539 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6542 int outlineWidth = -1;
6543 int elem0dSize = -1;
6544 //int ballSize = -1;
6545 double ballDiameter = -1.0;
6546 double ballScale = -1.0;
6547 double shrinkSize = -1;
6548 double orientationSize = -1;
6549 bool orientation3d = false;
6550 for ( int i = 0; i < sizes.count(); i++ ) {
6551 QString type = sizes[i];
6552 if ( type == "line" ) {
6553 // line (wireframe) width is given as single integer value
6554 if ( i+1 >= sizes.count() ) break; // format error
6555 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6559 if ( type == "outline" ) {
6560 // outline width is given as single integer value
6561 if ( i+1 >= sizes.count() ) break; // format error
6562 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6566 else if ( type == "elem0d" ) {
6567 // 0d element size is given as single integer value
6568 if ( i+1 >= sizes.count() ) break; // format error
6569 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6573 else if ( type == "ball" ) {
6574 // balls are specified by two values: size:scale, where
6575 // - size - is a integer value specifying size
6576 // - scale - is a double value specifying scale factor
6577 if ( i+1 >= sizes.count() ) break; // format error
6578 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6579 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6580 if ( i+2 >= sizes.count() ) break; // format error
6581 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6587 else if ( type == "shrink" ) {
6588 // shrink factor is given as single floating point value
6589 if ( i+1 >= sizes.count() ) break; // format error
6590 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6594 else if ( type == "orientation" ) {
6595 // orientation vectors are specified by two values size:3d, where
6596 // - size - is a floating point value specifying scale factor
6597 // - 3d - is a boolean
6598 if ( i+1 >= sizes.count() ) break; // format error
6599 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6600 if ( i+2 >= sizes.count() ) break; // format error
6601 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6602 orientationSize = v1;
6603 orientation3d = (bool)v2;
6607 // line (wireframe) width
6608 if ( lineWidth > 0 )
6609 aSmeshActor->SetLineWidth( lineWidth );
6611 if ( outlineWidth > 0 )
6612 aSmeshActor->SetOutlineWidth( outlineWidth );
6613 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6614 aSmeshActor->SetOutlineWidth( lineWidth );
6616 if ( elem0dSize > 0 )
6617 aSmeshActor->Set0DSize( elem0dSize );
6619 /*if ( ballSize > 0 )
6620 aSmeshActor->SetBallSize( ballSize );*/
6622 if ( ballDiameter > 0 )
6623 aSmeshActor->SetBallSize( ballDiameter );
6625 if ( ballScale > 0.0 )
6626 aSmeshActor->SetBallScale( ballScale );
6628 if ( shrinkSize > 0 )
6629 aSmeshActor->SetShrinkFactor( shrinkSize );
6630 // orientation vectors
6631 if ( orientationSize > 0 ) {
6632 aSmeshActor->SetFacesOrientationScale( orientationSize );
6633 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6637 else if (paramNameStr == "PointMarker") {
6638 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6639 if( data.count() >= 2 ) {
6641 int aParam1 = data[1].toInt( &ok );
6643 if( data[0] == "std" && data.count() == 3 ) {
6644 int aParam2 = data[2].toInt( &ok );
6645 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6647 else if( data[0] == "custom" ) {
6648 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6649 if( markerIt != aMarkerMap.end() ) {
6650 VTK::MarkerData aMarkerData = markerIt->second;
6651 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6658 else if (paramNameStr == "Opacity") {
6659 aSmeshActor->SetOpacity(val.toFloat());
6662 else if (paramNameStr.startsWith("ClippingPlane")) {
6663 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6664 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6665 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6666 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6667 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6668 // new format - val looks like "Off" or "0" (plane id)
6669 // (note: in new format "Off" value is used only for consistency,
6670 // so it is processed together with values in old format)
6671 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6672 if( anIsOldFormat ) {
6673 if (paramNameStr == "ClippingPlane1" || val == "Off")
6674 aSmeshActor->RemoveAllClippingPlanes();
6676 QList<SUIT_ViewManager*> lst;
6677 getApp()->viewManagers(viewerTypStr, lst);
6678 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6679 if (viewIndex >= 0 && viewIndex < lst.count()) {
6680 SUIT_ViewManager* vman = lst.at(viewIndex);
6681 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6683 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6685 SMESH::TActorList anActorList;
6686 anActorList.push_back( aSmeshActor );
6687 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6688 aPlane->myViewWindow = vtkView;
6689 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6690 aPlane->PlaneMode = aMode;
6691 bool isOpenGLClipping = ( bool )vals[1].toInt();
6692 aPlane->IsOpenGLClipping = isOpenGLClipping;
6693 if ( aMode == SMESH::Absolute ) {
6694 aPlane->myAbsoluteOrientation = vals[2].toInt();
6695 aPlane->X = vals[3].toFloat();
6696 aPlane->Y = vals[4].toFloat();
6697 aPlane->Z = vals[5].toFloat();
6698 aPlane->Dx = vals[6].toFloat();
6699 aPlane->Dy = vals[7].toFloat();
6700 aPlane->Dz = vals[8].toFloat();
6702 else if ( aMode == SMESH::Relative ) {
6703 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6704 aPlane->myDistance = vals[3].toFloat();
6705 aPlane->myAngle[0] = vals[4].toFloat();
6706 aPlane->myAngle[1] = vals[5].toFloat();
6710 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6711 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6712 aClippingPlaneInfo.Plane = aPlane;
6713 aClippingPlaneInfo.ActorList = anActorList;
6714 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6722 int aPlaneId = val.toInt( &ok );
6723 if( ok && aPlaneId >= 0 ) {
6724 bool anIsDefinedPlane = false;
6725 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6726 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6727 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6728 TPlaneInfo& aPlaneInfo = *anIter;
6729 if( aPlaneInfo.PlaneId == aPlaneId ) {
6730 aPlaneInfo.ActorList.push_back( aSmeshActor );
6731 anIsDefinedPlane = true;
6735 if( !anIsDefinedPlane ) {
6736 TPlaneInfo aPlaneInfo;
6737 aPlaneInfo.PlaneId = aPlaneId;
6738 aPlaneInfo.ActorList.push_back( aSmeshActor );
6739 aPlaneInfo.ViewManager = vman;
6741 // to make the list sorted by plane id
6742 anIter = aPlaneInfoList.begin();
6743 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6744 const TPlaneInfo& aPlaneInfoRef = *anIter;
6745 if( aPlaneInfoRef.PlaneId > aPlaneId )
6748 aPlaneInfoList.insert( anIter, aPlaneInfo );
6753 } // if (aSmeshActor)
6754 } // other parameters than Visibility
6756 } // for names/parameters iterator
6757 } // for entries iterator
6759 // take into account planes with empty list of actors referred to them
6760 QList<SUIT_ViewManager*> aVMList;
6761 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6763 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6764 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6765 int aViewId = aPlaneDataIter->first;
6766 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6767 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6769 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6771 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6772 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6773 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6774 const TPlaneData& aPlaneData = *anIter2;
6775 int aPlaneId = aPlaneData.Id;
6777 bool anIsFound = false;
6778 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6779 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6780 const TPlaneInfo& aPlaneInfo = *anIter3;
6781 if( aPlaneInfo.PlaneId == aPlaneId ) {
6788 TPlaneInfo aPlaneInfo; // ActorList field is empty
6789 aPlaneInfo.PlaneId = aPlaneId;
6790 aPlaneInfo.ViewManager = aViewManager;
6792 // to make the list sorted by plane id
6793 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6794 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6795 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6796 if( aPlaneInfoRef.PlaneId > aPlaneId )
6799 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6805 // add clipping planes to actors according to the restored parameters
6806 // and update the clipping plane map
6807 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6808 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6809 int aViewId = anIter1->first;
6810 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6812 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6813 if( anIter2 == aPlaneDataMap.end() )
6815 const TPlaneDataList& aPlaneDataList = anIter2->second;
6817 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6818 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6819 const TPlaneInfo& aPlaneInfo = *anIter3;
6820 int aPlaneId = aPlaneInfo.PlaneId;
6821 const TActorList& anActorList = aPlaneInfo.ActorList;
6822 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6826 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6830 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6832 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6833 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6834 const TPlaneData& aPlaneData = *anIter4;
6835 if( aPlaneData.Id == aPlaneId ) {
6836 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6837 aPlane->myViewWindow = aViewWindow;
6838 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6839 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6840 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6841 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6842 aPlane->X = aPlaneData.X;
6843 aPlane->Y = aPlaneData.Y;
6844 aPlane->Z = aPlaneData.Z;
6845 aPlane->Dx = aPlaneData.Dx;
6846 aPlane->Dy = aPlaneData.Dy;
6847 aPlane->Dz = aPlaneData.Dz;
6849 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6850 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6851 aPlane->myDistance = aPlaneData.Distance;
6852 aPlane->myAngle[0] = aPlaneData.Angle[0];
6853 aPlane->myAngle[1] = aPlaneData.Angle[1];
6856 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6857 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6858 aClippingPlaneInfo.Plane = aPlane;
6859 aClippingPlaneInfo.ActorList = anActorList;
6860 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6871 // update all VTK views
6872 QList<SUIT_ViewManager*> lst;
6873 getApp()->viewManagers(lst);
6874 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6875 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6876 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6877 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6878 // set OpenGL clipping planes
6879 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6880 vtkActorCollection* anAllActors = aCopy.GetActors();
6881 anAllActors->InitTraversal();
6882 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6883 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6884 anActor->SetOpenGLClippingPlane();
6886 vtkView->getRenderer()->ResetCameraClippingRange();
6893 \brief Adds preferences for dfont of VTK viewer
6895 \param pIf group identifier
6896 \param param parameter
6897 \return identifier of preferences
6899 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6901 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6903 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6906 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6907 fam.append( tr( "SMESH_FONT_COURIER" ) );
6908 fam.append( tr( "SMESH_FONT_TIMES" ) );
6910 setPreferenceProperty( tfont, "fonts", fam );
6912 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6913 if ( needSize ) f = f | QtxFontEdit::Size;
6914 setPreferenceProperty( tfont, "features", f );
6920 \brief Actions after hypothesis edition
6921 Updates object browser after hypothesis edition
6923 void SMESHGUI::onHypothesisEdit( int result )
6926 SMESHGUI::Modified();
6927 updateObjBrowser( true );
6931 \brief Actions after choosing menu of control modes
6932 Updates control mode actions according to current selection
6934 void SMESHGUI::onUpdateControlActions()
6936 SALOME_ListIO selected;
6937 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
6938 aSel->selectedObjects( selected );
6940 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
6941 if ( selected.Extent() ) {
6942 if ( selected.First()->hasEntry() ) {
6943 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
6944 aControl = anActor->GetControlMode();
6945 SALOME_ListIteratorOfListIO it(selected);
6946 for ( it.Next(); it.More(); it.Next() ) {
6947 Handle(SALOME_InteractiveObject) anIO = it.Value();
6948 if ( anIO->hasEntry() ) {
6949 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
6950 if ( aControl != anActor->GetControlMode() ) {
6951 aControl = SMESH_Actor::eNone;
6961 int anAction = ActionToControl( aControl, true );
6963 action( anAction )->setChecked( true );
6965 QMenu* send = (QMenu*)sender();
6966 QList<QAction*> actions = send->actions();
6967 for ( int i = 0; i < actions.size(); i++ )
6968 actions[i]->setChecked( false );
6974 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6975 \param pview view being closed
6977 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6978 #ifndef DISABLE_PLOT2DVIEWER
6979 //Crear all Plot2d Viewers if need.
6980 SMESH::ClearPlot2Viewers(pview);
6982 EmitSignalCloseView();
6985 void SMESHGUI::message( const QString& msg )
6988 QStringList data = msg.split("/");
6989 if ( data.count() > 0 ) {
6990 if ( data.first() == "mesh_loading" ) {
6992 QString entry = data.count() > 1 ? data[1] : QString();
6993 if ( entry.isEmpty() )
6996 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6998 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
7001 name = SMESH::fromUtf8(obj->GetName());
7002 if ( name.isEmpty() )
7005 if ( data.last() == "stop" )
7006 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7008 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7009 QApplication::processEvents();
7015 \brief Connects or disconnects signals about activating and cloning view on the module slots
7016 \param pview view which is connected/disconnected
7018 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7022 SUIT_ViewManager* viewMgr = pview->getViewManager();
7024 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7025 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7027 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7028 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7033 \brief Return \c true if object can be renamed
7035 bool SMESHGUI::renameAllowed( const QString& entry) const {
7036 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7040 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7044 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7049 if(appStudy->isComponent(entry) || obj->isReference())
7052 // check type to prevent renaming of inappropriate objects
7053 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
7054 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7055 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7056 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7057 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7058 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7065 Rename object by entry.
7066 \param entry entry of the object
7067 \param name new name of the object
7068 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7070 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7072 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7076 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7081 _PTR(Study) aStudy = appStudy->studyDS();
7086 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7088 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7093 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7094 _PTR(GenericAttribute) anAttr;
7095 _PTR(AttributeName) aName;
7097 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7099 // check type to prevent renaming of inappropriate objects
7100 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
7101 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7102 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7103 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7104 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7105 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7106 if ( !name.isEmpty() ) {
7107 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
7109 // update name of group object and its actor
7110 Handle(SALOME_InteractiveObject) IObject =
7111 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7113 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7114 if( !aGroupObject->_is_nil() ) {
7115 aGroupObject->SetName( qPrintable(name) );
7116 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7117 anActor->setName( qPrintable(name) );
7127 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7129 static QList<QColor> colors;
7131 if ( colors.isEmpty() ) {
7133 for (int s = 0; s < 2 ; s++)
7135 for (int v = 100; v >= 40; v = v - 20)
7137 for (int h = 0; h < 359 ; h = h + 60)
7139 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7144 static int currentColor = randomize( colors.size() );
7146 SALOMEDS::Color color;
7147 color.R = (double)colors[currentColor].red() / 255.0;
7148 color.G = (double)colors[currentColor].green() / 255.0;
7149 color.B = (double)colors[currentColor].blue() / 255.0;
7151 currentColor = (currentColor+1) % colors.count();