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_Selection.h"
78 #include "SMESHGUI_SewingDlg.h"
79 #include "SMESHGUI_SingleEditDlg.h"
80 #include "SMESHGUI_SmoothingDlg.h"
81 #include "SMESHGUI_SymmetryDlg.h"
82 #include "SMESHGUI_TranslationDlg.h"
83 #include "SMESHGUI_TransparencyDlg.h"
84 #include "SMESHGUI_DisplayEntitiesDlg.h"
85 #include "SMESHGUI_SplitBiQuad.h"
87 #include "SMESHGUI_FilterUtils.h"
88 #include "SMESHGUI_GEOMGenUtils.h"
89 #include "SMESHGUI_GroupUtils.h"
90 #include "SMESHGUI_HypothesesUtils.h"
91 #include "SMESHGUI_MeshUtils.h"
92 #include "SMESHGUI_PatternUtils.h"
93 #include "SMESHGUI_Utils.h"
94 #include "SMESHGUI_VTKUtils.h"
96 #include "SMESH_version.h"
98 #include "SMESH_ControlsDef.hxx"
99 #include "SMESH_Actor.h"
100 #include "SMESH_ActorUtils.h"
101 #include "SMESH_Client.hxx"
102 #include "SMESH_ScalarBarActor.h"
103 #include "SMESH_TypeFilter.hxx"
105 // SALOME GUI includes
106 #include <SalomeApp_Application.h>
107 #include <SalomeApp_CheckFileDlg.h>
108 #include <SalomeApp_DataObject.h>
109 #include <SalomeApp_Study.h>
110 #include <SalomeApp_Tools.h>
112 #include <LightApp_DataOwner.h>
113 #include <LightApp_NameDlg.h>
114 #include <LightApp_Preferences.h>
115 #include <LightApp_SelectionMgr.h>
116 #include <LightApp_UpdateFlags.h>
118 #include <SVTK_ViewManager.h>
119 #include <SVTK_ViewModel.h>
120 #include <SVTK_ViewWindow.h>
122 #include <VTKViewer_Algorithm.h>
124 #include <SUIT_Desktop.h>
125 #include <SUIT_FileDlg.h>
126 #include <SUIT_MessageBox.h>
127 #include <SUIT_OverrideCursor.h>
128 #include <SUIT_ResourceMgr.h>
129 #include <SUIT_Session.h>
131 #include <QtxPopupMgr.h>
132 #include <QtxFontEdit.h>
134 #include <SALOME_ListIO.hxx>
136 #ifndef DISABLE_PLOT2DVIEWER
137 #include <SPlot2d_ViewModel.h>
138 #include <SPlot2d_Histogram.h>
142 #include <SALOMEconfig.h>
143 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
144 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
145 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
148 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
149 #include <QApplication>
151 #include <QTextStream>
156 #include <QDialogButtonBox>
159 #include <boost/shared_ptr.hpp>
162 #include <vtkCallbackCommand.h>
163 #include <vtkCamera.h>
164 #include <vtkLookupTable.h>
165 #include <vtkPlane.h>
166 #include <vtkRenderer.h>
168 // SALOME KERNEL includes
169 #include <SALOMEDSClient_ClientFactory.hxx>
170 #include <SALOMEDSClient_IParameters.hxx>
171 #include <SALOMEDSClient_SComponent.hxx>
172 #include <SALOMEDSClient_StudyBuilder.hxx>
173 #include <SALOMEDS_Study.hxx>
174 #include <SALOMEDS_SObject.hxx>
175 #include "utilities.h"
178 #include <Standard_ErrorHandler.hxx>
179 #include <NCollection_DataMap.hxx>
180 #include <NCollection_DoubleMap.hxx>
182 #include <Basics_Utils.hxx>
184 // Below macro, when uncommented, switches on simplified (more performant) algorithm
185 // of auto-color picking up
186 #define SIMPLE_AUTOCOLOR
191 //=============================================================
192 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
195 void ExportMeshToFile(int theCommandID);
197 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
199 void SetDisplayEntity(int theCommandID);
201 int ActionToControl( int theID, bool theReversed = false );
203 void Control( int theCommandID );
206 //================================================================================
208 * \brief Reads meshes from file
210 //================================================================================
212 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
216 std::string myExtension;
218 if ( theCommandID == SMESHOp::OpImportMED ||
219 theCommandID == SMESHOp::OpPopupImportMED ) {
220 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
221 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
223 else if ( theCommandID == SMESHOp::OpImportUNV ||
224 theCommandID == SMESHOp::OpPopupImportUNV ) {
225 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
227 else if ( theCommandID == SMESHOp::OpImportDAT ||
228 theCommandID == SMESHOp::OpPopupImportDAT ) {
229 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
231 else if ( theCommandID == SMESHOp::OpImportSTL ||
232 theCommandID == SMESHOp::OpPopupImportSTL ) {
233 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
235 else if ( theCommandID == SMESHOp::OpImportCGNS ||
236 theCommandID == SMESHOp::OpPopupImportCGNS ) {
237 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
239 else if ( theCommandID == SMESHOp::OpImportSAUV ||
240 theCommandID == SMESHOp::OpPopupImportSAUV ) {
241 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
242 filter.append( QObject::tr( "All files (*)" ) );
244 else if ( theCommandID == SMESHOp::OpImportGMF ||
245 theCommandID == SMESHOp::OpPopupImportGMF ) {
246 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
247 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
250 QString anInitialPath = "";
251 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
252 anInitialPath = QDir::currentPath();
254 QStringList filenames;
255 bool toCreateGroups = true;
257 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
258 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
259 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
260 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
261 // fd->setNameFilters( filter );
262 // fd->SetChecked( true );
264 // filenames << fd->selectedFile();
265 // toCreateGroups = fd->IsChecked();
271 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
274 QObject::tr( "SMESH_IMPORT_MESH" ) );
276 if ( filenames.count() > 0 )
278 SUIT_OverrideCursor wc;
279 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
282 QStringList anEntryList;
283 bool isEmpty = false;
284 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
286 QString filename = *it;
287 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
289 switch ( theCommandID ) {
290 case SMESHOp::OpImportDAT:
291 case SMESHOp::OpPopupImportDAT:
293 // DAT format (currently unsupported)
294 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
295 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
298 case SMESHOp::OpImportUNV:
299 case SMESHOp::OpPopupImportUNV:
302 aMeshes->length( 1 );
303 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
304 if ( aMeshes[0]->_is_nil() )
305 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
306 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
309 case SMESHOp::OpImportMED:
310 case SMESHOp::OpPopupImportMED:
313 SMESH::DriverMED_ReadStatus res;
314 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
315 if ( res != SMESH::DRS_OK ) {
316 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
317 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
321 case SMESHOp::OpImportSTL:
322 case SMESHOp::OpPopupImportSTL:
325 aMeshes->length( 1 );
326 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
327 if ( aMeshes[0]->_is_nil() ) {
328 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
329 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
333 case SMESHOp::OpImportCGNS:
334 case SMESHOp::OpPopupImportCGNS:
337 SMESH::DriverMED_ReadStatus res;
338 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
339 if ( res != SMESH::DRS_OK ) {
340 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
341 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
345 case SMESHOp::OpImportSAUV:
346 case SMESHOp::OpPopupImportSAUV:
349 SMESH::DriverMED_ReadStatus res;
350 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
351 if ( res != SMESH::DRS_OK ) {
352 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
353 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
357 case SMESHOp::OpImportGMF:
358 case SMESHOp::OpPopupImportGMF:
361 SMESH::ComputeError_var res;
362 aMeshes->length( 1 );
363 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
366 if ( res->code != SMESH::DRS_OK ) {
367 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
368 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
369 if ( strlen( res->comment.in() ) > 0 ) {
370 errors.back() += ": ";
371 errors.back() += res->comment.in();
378 catch ( const SALOME::SALOME_Exception& S_ex ) {
379 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
380 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
383 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
385 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
387 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
388 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
389 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
390 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
391 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
393 anEntryList.append( aMeshSO->GetID().c_str() );
401 // update Object browser
402 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
404 // browse to the published meshes
405 if( LightApp_Application* anApp =
406 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
407 anApp->browseObjects( anEntryList );
409 // show Error message box if there were errors
410 if ( errors.count() > 0 ) {
411 SUIT_MessageBox::critical( SMESHGUI::desktop(),
412 QObject::tr( "SMESH_ERROR" ),
413 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
416 // show warning message box, if some imported mesh is empty
418 SUIT_MessageBox::warning( SMESHGUI::desktop(),
419 QObject::tr( "SMESH_WRN_WARNING" ),
420 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
425 //================================================================================
427 * \brief Export selected meshes or groups into a file
429 //================================================================================
431 void ExportMeshToFile( int theCommandID )
433 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
434 SALOME_ListIO selected;
436 aSel->selectedObjects( selected );
438 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
439 theCommandID == SMESHOp::OpPopupExportDAT );
440 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
441 theCommandID == SMESHOp::OpPopupExportMED );
442 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
443 theCommandID == SMESHOp::OpPopupExportUNV );
444 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
445 theCommandID == SMESHOp::OpPopupExportSTL );
446 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
447 theCommandID == SMESHOp::OpPopupExportCGNS );
448 const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV ||
449 theCommandID == SMESHOp::OpPopupExportSAUV );
450 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
451 theCommandID == SMESHOp::OpPopupExportGMF );
453 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
454 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
456 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
457 bool aCheckWarn = true;
459 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
460 // get mesh object from selection and check duplication of their names
461 bool hasDuplicatedMeshNames = false;
462 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
463 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
464 SALOME_ListIteratorOfListIO It( selected );
465 for( ; It.More(); It.Next() )
467 Handle(SALOME_InteractiveObject) anIObject = It.Value();
468 SMESH::SMESH_IDSource_var aMeshItem =
469 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
470 if ( aMeshItem->_is_nil() ) {
471 SUIT_MessageBox::warning( SMESHGUI::desktop(),
472 QObject::tr( "SMESH_WRN_WARNING" ),
473 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
476 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
477 if ( aCheckWarn && !aGroup->_is_nil() )
479 QMessageBox msgBox(SUIT_MessageBox::Warning,
480 QObject::tr("SMESH_WRN_WARNING"),
481 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
482 QMessageBox::StandardButton::NoButton,
483 SMESHGUI::desktop());
484 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
485 msgBox.addButton(QMessageBox::Ok);
486 msgBox.addButton(QMessageBox::Cancel);
487 msgBox.setDefaultButton(QMessageBox::Cancel);
488 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
489 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
490 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
491 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
492 if(msgBox.exec() == QMessageBox::Ok)
494 if(dontShowCheckBox.checkState() == Qt::Checked)
497 resMgr->setValue( "SMESH", "show_warning", false);
505 QString aMeshName = anIObject->getName();
507 // check for name duplications
508 if ( !hasDuplicatedMeshNames )
509 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
510 if( aMeshName == (*aMeshIter).second ) {
511 hasDuplicatedMeshNames = true;
516 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
519 if( hasDuplicatedMeshNames && isMED ) {
520 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
521 QObject::tr("SMESH_WRN_WARNING"),
522 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
523 QObject::tr("SMESH_BUT_YES"),
524 QObject::tr("SMESH_BUT_NO"), 0, 1);
529 aMeshIter = aMeshList.begin();
530 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
531 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
532 QString aMeshName = (*aMeshIter).second;
534 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
536 // check for equal group names within each mesh
537 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
538 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
539 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
540 int aRet = SUIT_MessageBox::warning
541 (SMESHGUI::desktop(),
542 QObject::tr("SMESH_WRN_WARNING"),
543 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
544 QObject::tr("SMESH_BUT_YES"),
545 QObject::tr("SMESH_BUT_NO"), 0, 1);
552 // Warn the user about presence of not supported elements
554 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
558 notSupportedElemTypes.push_back( SMESH::Entity_0D );
559 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
564 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
565 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
566 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
567 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
568 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
569 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
570 notSupportedElemTypes.push_back( SMESH::Entity_0D );
571 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
576 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
577 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
578 notSupportedElemTypes.push_back( SMESH::Entity_0D );
579 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
584 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
589 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
590 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
591 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
592 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
593 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
594 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
595 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
596 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
601 notSupportedElemTypes.push_back( SMESH::Entity_0D );
602 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
603 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
604 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
605 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
606 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
607 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
608 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
609 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
611 if ( ! notSupportedElemTypes.empty() )
613 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
614 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
615 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
616 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
618 if ( !presentNotSupported.empty() )
621 const char* typeMsg[] = {
622 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
623 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
624 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
625 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
626 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
627 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
628 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
629 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
631 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
632 const int nbTypes = sizeof( typeMsg ) / sizeof( const char* );
633 int _assert[( nbTypes == SMESH::Entity_Last ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
635 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
636 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
637 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
638 if ( iType != presentNotSupported.size() - 1 )
639 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
641 int aRet = SUIT_MessageBox::warning
642 (SMESHGUI::desktop(),
643 QObject::tr("SMESH_WRN_WARNING"),
644 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
645 QObject::tr("SMESH_BUT_YES"),
646 QObject::tr("SMESH_BUT_NO"), 0, 1);
651 // Get parameters of export operation
654 SMESH::MED_VERSION aFormat = SMESH::MED_V2_2;
655 // Init the parameters with the default values
656 bool aIsASCII_STL = true;
657 bool toCreateGroups = false;
659 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
660 bool toOverwrite = true;
661 bool toFindOutDim = true;
663 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
664 QString anInitialPath = "";
665 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
666 anInitialPath = QDir::currentPath();
668 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
670 // Get a file name to write in and additional otions
671 if ( isUNV || isDAT || isGMF ) // Export w/o options
674 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
676 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
678 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
679 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
680 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
681 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
682 anInitialPath + QString("/") + aMeshName,
683 aFilter, aTitle, false);
685 else if ( isCGNS )// Export to CGNS
687 const char* theByTypeResource = "cgns_group_elems_by_type";
688 toCreateGroups = SMESHGUI::resourceMgr()->booleanValue( "SMESH", theByTypeResource, false );
690 QStringList checkBoxes;
691 checkBoxes << QObject::tr("CGNS_EXPORT_ELEMS_BY_TYPE");
693 SalomeApp_CheckFileDlg* fd =
694 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
695 fd->setWindowTitle( aTitle );
696 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
697 if ( !anInitialPath.isEmpty() )
698 fd->setDirectory( anInitialPath );
699 fd->selectFile(aMeshName);
700 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
701 fd->setValidator( fv );
702 fd->SetChecked( toCreateGroups, 0 );
705 aFilename = fd->selectedFile();
706 toOverwrite = fv->isOverwrite();
707 toCreateGroups = fd->IsChecked(0);
708 SMESHGUI::resourceMgr()->setValue("SMESH", theByTypeResource, toCreateGroups );
712 else if ( isSTL ) // Export to STL
714 QMap<QString, int> aFilterMap;
715 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
716 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
719 QMap<QString, int>::const_iterator it = aFilterMap.begin();
720 for ( ; it != aFilterMap.end(); ++it )
721 filters.push_back( it.key() );
723 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
724 fd->setWindowTitle( aTitle );
725 fd->setNameFilters( filters );
726 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
727 if ( !anInitialPath.isEmpty() )
728 fd->setDirectory( anInitialPath );
729 fd->selectFile(aMeshName);
733 aFilename = fd->selectedFile();
734 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
739 else if ( isMED || isSAUV ) // Export to MED or SAUV
741 QMap<QString, SMESH::MED_VERSION> aFilterMap;
742 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
744 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
745 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
746 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
749 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
750 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
751 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
755 QString aDefaultFilter;
756 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
757 for ( ; it != aFilterMap.end(); ++it ) {
758 filters.push_back( it.key() );
759 if (it.value() == SMESH::MED_V2_2)
760 aDefaultFilter = it.key();
762 QStringList checkBoxes;
763 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
765 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
766 QList< QWidget* > wdgList;
767 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
768 wdgList.append( fieldSelWdg );
770 SalomeApp_CheckFileDlg* fd =
771 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
772 fd->setWindowTitle( aTitle );
773 fd->setNameFilters( filters );
774 fd->selectNameFilter( aDefaultFilter );
775 fd->SetChecked( toCreateGroups, 0 );
776 fd->SetChecked( toFindOutDim, 1 );
777 if ( !anInitialPath.isEmpty() )
778 fd->setDirectory( anInitialPath );
779 fd->selectFile(aMeshName);
782 QListView *lview = fd->findChild<QListView*>("listView");
784 lview->setMinimumHeight(200);
786 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
788 tview->setMinimumHeight(200);
791 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
792 fd->setValidator( fv );
797 aFilename = fd->selectedFile();
799 aFilename = QString::null;
802 aFormat = aFilterMap[fd->selectedNameFilter()];
803 toOverwrite = fv->isOverwrite();
805 if ( !aFilename.isEmpty() ) {
806 // med-2.1 does not support poly elements
807 if ( aFormat==SMESH::MED_V2_1 )
808 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
809 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
810 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
811 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
812 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
814 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
815 QObject::tr("SMESH_WRN_WARNING"),
816 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
817 QObject::tr("SMESH_BUT_YES"),
818 QObject::tr("SMESH_BUT_NO"), 0, 1);
826 // can't append to an existing using other format
827 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
828 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
829 if( !isVersionOk || aVersion != aFormat ) {
830 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
831 QObject::tr("SMESH_WRN_WARNING"),
832 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
833 QObject::tr("SMESH_BUT_YES"),
834 QObject::tr("SMESH_BUT_NO"), 0, 1);
841 QStringList aMeshNamesCollisionList;
842 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
843 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
844 QString anExistingMeshName( aMeshNames[ i ] );
845 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
846 QString anExportMeshName = (*aMeshIter).second;
847 if( anExportMeshName == anExistingMeshName ) {
848 aMeshNamesCollisionList.append( anExportMeshName );
853 if( !aMeshNamesCollisionList.isEmpty() ) {
854 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
855 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
856 QObject::tr("SMESH_WRN_WARNING"),
857 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
858 QObject::tr("SMESH_BUT_YES"),
859 QObject::tr("SMESH_BUT_NO"),
860 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
869 toCreateGroups = fd->IsChecked(0);
870 toFindOutDim = fd->IsChecked(1);
871 fieldSelWdg->GetSelectedFields();
872 if ( !fieldSelWdg->parent() )
883 if ( !aFilename.isEmpty() ) {
884 // Check whether the file already exists and delete it if yes
885 QFile aFile( aFilename );
886 if ( aFile.exists() && toOverwrite )
888 SUIT_OverrideCursor wc;
891 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
892 // bool Renumber = false;
893 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
895 // Renumber= resMgr->booleanValue("renumbering");
897 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
898 // aMeshEditor->RenumberNodes();
899 // aMeshEditor->RenumberElements();
900 // if ( SMESHGUI::automaticUpdate() )
901 // SMESH::UpdateView();
905 aMeshIter = aMeshList.begin();
906 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
908 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
909 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
910 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
911 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
912 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
913 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
914 aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups,
915 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim );
917 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
918 aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim,
919 fields, geoAssFields.toLatin1().data() );
924 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
926 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
927 if( !aMeshItem->_is_nil() )
928 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
933 if ( aMeshOrGroup->_is_equivalent( aMesh ))
934 aMesh->ExportDAT( aFilename.toUtf8().data() );
936 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
940 if ( aMeshOrGroup->_is_equivalent( aMesh ))
941 aMesh->ExportUNV( aFilename.toUtf8().data() );
943 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
947 if ( aMeshOrGroup->_is_equivalent( aMesh ))
948 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
950 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
954 aMeshIter = aMeshList.begin();
955 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
957 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
958 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
959 aMeshItem->ExportCGNS( aMeshOrGroup,
960 aFilename.toUtf8().data(),
961 toOverwrite && aMeshIndex == 0,
967 toCreateGroups = true;
968 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
971 catch (const SALOME::SALOME_Exception& S_ex){
973 SUIT_MessageBox::warning(SMESHGUI::desktop(),
974 QObject::tr("SMESH_WRN_WARNING"),
975 QObject::tr("SMESH_EXPORT_FAILED"));
981 inline void InverseEntityMode(unsigned int& theOutputMode,
982 unsigned int theMode)
984 bool anIsNotPresent = ~theOutputMode & theMode;
986 theOutputMode |= theMode;
988 theOutputMode &= ~theMode;
991 void SetDisplayEntity(int theCommandID)
993 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
994 SALOME_ListIO selected;
996 aSel->selectedObjects( selected );
998 if ( selected.Extent() >= 1 ) {
999 SUIT_OverrideCursor wc;
1000 SALOME_ListIteratorOfListIO It( selected );
1001 for( ; It.More(); It.Next()){
1002 Handle(SALOME_InteractiveObject) IObject = It.Value();
1003 if(IObject->hasEntry()){
1004 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1005 unsigned int aMode = anActor->GetEntityMode();
1006 switch(theCommandID){
1007 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1008 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1009 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1010 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1011 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1012 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1015 anActor->SetEntityMode(aMode);
1024 SalomeApp_Application* app =
1025 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1029 LightApp_SelectionMgr* aSel = app->selectionMgr();
1030 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1031 if ( !aSel || !appStudy )
1034 SALOME_ListIO selected;
1035 aSel->selectedObjects( selected );
1036 if ( selected.IsEmpty() )
1039 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1041 _PTR(Study) aStudy = appStudy->studyDS();
1042 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1043 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1044 if ( aMainObject->_is_nil() )
1047 SUIT_OverrideCursor wc;
1049 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1051 QList<SALOMEDS::Color> aReservedColors;
1053 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1054 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1056 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1058 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1059 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1060 #else // old algorithm for auto-colors
1061 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1062 aReservedColors.append( aColor );
1063 #endif // SIMPLE_AUTOCOLOR
1064 aGroupObject->SetColor( aColor );
1066 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1067 if ( aGroupSObject ) {
1070 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1071 switch ( aGroupObject->GetType ()) {
1073 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1075 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1077 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1079 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1081 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1082 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1085 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1086 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1092 SMESH::RepaintCurrentView();
1095 void OverallMeshQuality()
1097 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1098 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1099 SALOME_ListIO selected;
1101 aSel->selectedObjects( selected );
1103 if ( selected.IsEmpty() ) return;
1104 SALOME_ListIteratorOfListIO It( selected );
1105 for ( ; It.More(); It.Next() ) {
1106 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1107 ctrlDlg->showInfo( It.Value() );
1112 QString functorToString( SMESH::Controls::FunctorPtr f )
1114 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1115 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1116 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1117 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1118 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1119 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1120 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1121 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1122 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1123 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1124 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1125 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1126 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1127 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1128 type = QObject::tr( "WARP_ELEMENTS" );
1129 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1130 type = QObject::tr( "TAPER_ELEMENTS" );
1131 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1132 type = QObject::tr( "SKEW_ELEMENTS" );
1133 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1134 type = QObject::tr( "AREA_ELEMENTS" );
1135 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1136 type = QObject::tr( "LENGTH_EDGES" );
1137 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1138 type = QObject::tr( "LENGTH2D_EDGES" );
1139 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1140 type = QObject::tr( "MULTI_BORDERS" );
1141 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1142 type = QObject::tr( "MULTI2D_BORDERS" );
1143 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1144 type = QObject::tr( "FREE_NODES" );
1145 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1146 type = QObject::tr( "FREE_EDGES" );
1147 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1148 type = QObject::tr( "FREE_BORDERS" );
1149 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1150 type = QObject::tr( "FREE_FACES" );
1151 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1152 type = QObject::tr( "BARE_BORDER_VOLUME" );
1153 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1154 type = QObject::tr( "BARE_BORDER_FACE" );
1155 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1156 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1157 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1158 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1159 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1160 type = QObject::tr( "EQUAL_NODE" );
1161 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1162 type = QObject::tr( "EQUAL_EDGE" );
1163 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1164 type = QObject::tr( "EQUAL_FACE" );
1165 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1166 type = QObject::tr( "EQUAL_VOLUME" );
1167 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1168 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1172 void SaveDistribution()
1174 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1175 SALOME_ListIO selected;
1177 aSel->selectedObjects( selected );
1179 if ( selected.Extent() == 1 ) {
1180 Handle(SALOME_InteractiveObject) anIO = selected.First();
1181 if ( anIO->hasEntry() ) {
1182 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1184 anActor->GetScalarBarActor() &&
1185 anActor->GetControlMode() != SMESH_Actor::eNone )
1187 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1188 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1189 if ( aScalarBarActor && aFunctor ) {
1190 SMESH::Controls::NumericalFunctor* aNumFun =
1191 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1193 std::vector<int> elements;
1194 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1195 if ( mesh->_is_nil() ) {
1196 SMESH::SMESH_IDSource_var idSource =
1197 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1198 if ( !idSource->_is_nil() )
1200 SMESH::long_array_var ids = idSource->GetIDs();
1201 elements.resize( ids->length() );
1202 for ( unsigned i = 0; i < elements.size(); ++i )
1203 elements[i] = ids[i];
1206 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1207 vtkLookupTable* lookupTable =
1208 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1209 double * minmax = lookupTable->GetRange();
1210 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1211 std::vector<int> nbEvents;
1212 std::vector<double> funValues;
1213 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1214 elements, minmax, isLogarithmic );
1215 QString anInitialPath = "";
1216 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1217 anInitialPath = QDir::currentPath();
1218 QString aMeshName = anIO->getName();
1220 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1221 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1222 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1223 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1224 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1227 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1229 if ( !aFilename.isEmpty() ) {
1230 QFile f( aFilename );
1231 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1232 QTextStream out( &f );
1233 out << "# Mesh: " << aMeshName << endl;
1234 out << "# Control: " << functorToString( aFunctor ) << endl;
1236 out.setFieldWidth( 10 );
1237 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1238 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1249 void ShowElement( int theCommandID )
1251 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1252 SALOME_ListIO selected;
1254 aSel->selectedObjects( selected );
1256 if ( selected.Extent() == 1 ) {
1257 Handle(SALOME_InteractiveObject) anIO = selected.First();
1258 if ( anIO->hasEntry() ) {
1259 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1261 anActor->GetScalarBarActor() &&
1262 anActor->GetControlMode() != SMESH_Actor::eNone )
1264 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1265 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1266 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1268 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1269 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1276 #ifndef DISABLE_PLOT2DVIEWER
1277 void PlotDistribution()
1279 SalomeApp_Application* app =
1280 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1284 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1285 SALOME_ListIO selected;
1287 aSel->selectedObjects( selected );
1289 if ( selected.Extent() == 1 ) {
1290 Handle(SALOME_InteractiveObject) anIO = selected.First();
1291 if ( anIO->hasEntry() ) {
1292 //Find Actor by entry before getting Plot2d viewer,
1293 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1294 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1296 SUIT_ViewManager* aViewManager =
1297 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1301 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1305 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1309 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1311 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1312 QString functorName = functorToString( anActor->GetFunctor());
1313 QString aHistogramName("%1 : %2");
1314 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1315 aHistogram->setName(aHistogramName);
1316 aHistogram->setHorTitle(functorName);
1317 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1318 aPlot->displayObject(aHistogram, true);
1323 #endif //DISABLE_PLOT2DVIEWER
1325 void DisableAutoColor()
1327 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1328 SALOME_ListIO selected;
1330 aSel->selectedObjects( selected );
1332 if ( selected.Extent() ) {
1333 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1334 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1335 if ( !aMesh->_is_nil() ) {
1336 aMesh->SetAutoColor( false );
1343 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1344 SALOME_ListIO selected;
1346 aSel->selectedObjects( selected );
1347 if ( selected.Extent() )
1349 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1350 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1351 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1353 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1354 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1361 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1363 SALOME_ListIO selected;
1364 SalomeApp_Application* app =
1365 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1369 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1370 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1371 if ( !aSel || !appStudy )
1374 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1375 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1376 aModule->EmitSignalDeactivateDialog();
1377 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1378 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1383 _PTR(Study) aStudy = appStudy->studyDS();
1385 aSel->selectedObjects( selected );
1387 if ( selected.Extent() >= 1 )
1389 switch ( theCommandID ) {
1390 case SMESHOp::OpTransparency:
1392 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1393 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1396 case SMESHOp::OpProperties:
1399 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1400 QColor orientationColor, outlineColor, volumeColor;
1401 int deltaF = 0, deltaV = 0;
1404 double ballScale = 1.0;
1406 int outlineWidth = 1;
1407 double shrinkCoef = 0.0;
1408 double orientationScale = 0.0;
1409 bool orientation3d = false;
1410 VTK::MarkerType markerType = VTK::MT_NONE;
1411 VTK::MarkerScale markerScale = VTK::MS_NONE;
1413 bool hasNodes = false;
1414 int presentEntities = 0;
1415 bool firstTime = true;
1417 SALOME_ListIteratorOfListIO It( selected );
1418 for ( ; It.More(); It.Next() ) {
1419 Handle(SALOME_InteractiveObject) IObject = It.Value();
1420 if ( !IObject->hasEntry() ) continue;
1421 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1422 if ( !anActor || !anActor->GetObject() ) continue;
1425 // nodes: color, marker
1426 anActor->GetNodeColor( color[0], color[1], color[2] );
1427 nodeColor.setRgbF( color[0], color[1], color[2] );
1428 markerType = anActor->GetMarkerType();
1429 markerScale = anActor->GetMarkerScale();
1430 markerId = anActor->GetMarkerTexture();
1431 // edges: color, width
1432 anActor->GetEdgeColor( color[0], color[1], color[2] );
1433 edgeColor.setRgbF( color[0], color[1], color[2] );
1434 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1435 // faces: front color, back color (delta)
1436 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1437 faceColor.setRgbF( color[0], color[1], color[2] );
1438 // faces: front color, back color (delta)
1439 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1440 volumeColor.setRgbF( color[0], color[1], color[2] );
1441 // 0d elements: color, size
1442 anActor->Get0DColor( color[0], color[1], color[2] );
1443 elem0dColor.setRgbF( color[0], color[1], color[2] );
1444 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1445 // balls: color, size
1446 anActor->GetBallColor( color[0], color[1], color[2] );
1447 ballColor.setRgbF( color[0], color[1], color[2] );
1448 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1449 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1451 anActor->GetOutlineColor( color[0], color[1], color[2] );
1452 outlineColor.setRgbF( color[0], color[1], color[2] );
1453 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1454 // orientation vectors: color, scale, 3d flag
1455 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1456 orientationColor.setRgbF( color[0], color[1], color[2] );
1457 orientationScale = anActor->GetFacesOrientationScale();
1458 orientation3d = anActor->GetFacesOrientation3DVectors();
1460 shrinkCoef = anActor->GetShrinkFactor();
1463 firstTime = false; // we only take properties from first object (for performance reasons)
1466 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1467 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1468 presentEntities = presentEntities | SMESH_Actor::eEdges;
1469 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1470 presentEntities = presentEntities | SMESH_Actor::eFaces;
1471 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1472 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1473 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1474 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1475 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1476 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1478 // as we know that all types of elements are present, we can exit the loop
1479 if ( presentEntities == SMESH_Actor::eAllEntity )
1483 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1484 // nodes: color, marker
1485 dlg.setNodeColor( nodeColor );
1486 if( markerType != VTK::MT_USER )
1487 dlg.setNodeMarker( markerType, markerScale );
1489 dlg.setNodeCustomMarker( markerId );
1490 // edges: color, line width
1491 dlg.setEdgeColor( edgeColor );
1492 dlg.setEdgeWidth( edgeWidth );
1493 // faces: front color, back color
1494 dlg.setFaceColor( faceColor, deltaF );
1495 // volumes: normal color, reversed color
1496 dlg.setVolumeColor( volumeColor, deltaV );
1497 // outlines: color, line width
1498 dlg.setOutlineColor( outlineColor );
1499 dlg.setOutlineWidth( outlineWidth );
1500 // 0d elements: color, size
1501 dlg.setElem0dColor( elem0dColor );
1502 dlg.setElem0dSize( elem0dSize );
1503 // balls: color, size
1504 dlg.setBallColor( ballColor );
1505 //dlg.setBallSize( ballSize );
1506 dlg.setBallScale( ballScale );
1507 // orientation: color, scale, 3d flag
1508 dlg.setOrientationColor( orientationColor );
1509 dlg.setOrientationSize( int( orientationScale * 100. ) );
1510 dlg.setOrientation3d( orientation3d );
1511 // shrink: scale factor
1512 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1513 // hide unused controls
1514 dlg.showControls( presentEntities, hasNodes );
1517 nodeColor = dlg.nodeColor();
1518 markerType = dlg.nodeMarkerType();
1519 markerScale = dlg.nodeMarkerScale();
1520 markerId = dlg.nodeMarkerId();
1521 edgeColor = dlg.edgeColor();
1522 edgeWidth = dlg.edgeWidth();
1523 faceColor = dlg.faceColor();
1524 deltaF = dlg.faceColorDelta();
1525 volumeColor = dlg.volumeColor();
1526 deltaV = dlg.volumeColorDelta();
1527 outlineColor = dlg.outlineColor();
1528 outlineWidth = dlg.outlineWidth();
1529 elem0dColor = dlg.elem0dColor();
1530 elem0dSize = dlg.elem0dSize();
1531 ballColor = dlg.ballColor();
1532 // ballSize = dlg.ballSize();
1533 ballScale = dlg.ballScale();
1534 orientationColor = dlg.orientationColor();
1535 orientationScale = dlg.orientationSize() / 100.;
1536 orientation3d = dlg.orientation3d();
1537 shrinkCoef = dlg.shrinkCoef() / 100.;
1539 // store point markers map that might be changed by the user
1540 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1542 // set properties from dialog box to the presentations
1543 SALOME_ListIteratorOfListIO It( selected );
1544 for ( ; It.More(); It.Next() ) {
1545 Handle(SALOME_InteractiveObject) IObject = It.Value();
1546 if ( !IObject->hasEntry() ) continue;
1547 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1548 if ( !anActor ) continue;
1550 // nodes: color, marker
1551 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1552 if ( markerType != VTK::MT_USER ) {
1553 anActor->SetMarkerStd( markerType, markerScale );
1556 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1557 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1558 if ( iter != markerMap.end() )
1559 anActor->SetMarkerTexture( markerId, iter->second.second );
1561 // volumes: normal color, reversed color (delta)
1562 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1563 // faces: front color, back color (delta)
1564 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1565 // edges: color, width
1566 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1567 anActor->SetLineWidth( edgeWidth );
1569 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1570 anActor->SetOutlineWidth( outlineWidth );
1571 // 0D elements: color, size
1572 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1573 anActor->Set0DSize( elem0dSize );
1574 // balls: color, size
1575 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1576 // anActor->SetBallSize( ballSize );
1577 anActor->SetBallScale( ballScale );
1578 // orientation: color, scale, 3d flag
1579 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1580 anActor->SetFacesOrientationScale( orientationScale );
1581 anActor->SetFacesOrientation3DVectors( orientation3d );
1583 anActor->SetShrinkFactor( shrinkCoef );
1585 // for groups, set also proper color
1586 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1587 if ( !aGroupObject->_is_nil() ) {
1588 SMESH::ElementType anElementType = aGroupObject->GetType();
1590 switch( anElementType ) {
1592 aColor = nodeColor; break;
1594 aColor = edgeColor; break;
1596 aColor = faceColor; break;
1598 aColor = volumeColor; break;
1600 aColor = elem0dColor; break;
1602 aColor = ballColor; break;
1606 if ( aColor.isValid() ) {
1607 SALOMEDS::Color aGroupColor;
1608 aGroupColor.R = aColor.redF();
1609 aGroupColor.G = aColor.greenF();
1610 aGroupColor.B = aColor.blueF();
1611 aGroupObject->SetColor( aGroupColor );
1613 } // if ( !aGroupObject->_is_nil() )
1614 } // for ( ; It.More(); It.Next() )
1615 SMESH::RepaintCurrentView();
1616 } // if ( dlg.exec() )
1618 } // case SMESHOp::OpProperties:
1619 } // switch(theCommandID)
1620 SUIT_OverrideCursor wc;
1621 SALOME_ListIteratorOfListIO It( selected );
1622 for( ; It.More(); It.Next()){
1623 Handle(SALOME_InteractiveObject) IObject = It.Value();
1624 if(IObject->hasEntry()){
1625 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1626 switch(theCommandID){
1627 case SMESHOp::OpDMWireframe:
1628 anActor->SetRepresentation(SMESH_Actor::eEdge);
1630 case SMESHOp::OpDMShading:
1631 anActor->SetRepresentation(SMESH_Actor::eSurface);
1633 case SMESHOp::OpDMShrink:
1634 if(anActor->IsShrunk())
1635 anActor->UnShrink();
1637 anActor->SetShrink();
1639 case SMESHOp::OpDMNodes:
1640 anActor->SetRepresentation(SMESH_Actor::ePoint);
1642 case SMESHOp::OpRepresentationLines:
1643 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1644 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1646 case SMESHOp::OpRepresentationArcs:
1647 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1648 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1654 SMESH::RepaintCurrentView();
1658 int ActionToControl( int theID, bool theReversed )
1660 NCollection_DoubleMap<int,int> ActionControl;
1661 ActionControl.Bind( 0, SMESH_Actor::eNone );
1662 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1663 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1664 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1665 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1666 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1667 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1668 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1669 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1670 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1671 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1672 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1673 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1674 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1675 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1676 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1677 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1678 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1679 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1680 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1681 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1682 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1683 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1684 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1685 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1686 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1687 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1688 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1690 return theReversed ? ActionControl.Find2( theID ) : ActionControl.Find1( theID );
1693 void Control( int theCommandID )
1695 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1696 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1698 SALOME_ListIO selected;
1699 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1700 aSel->selectedObjects( selected );
1702 if ( !selected.IsEmpty() ) {
1703 SALOME_ListIteratorOfListIO It(selected);
1704 for ( ; It.More(); It.Next())
1706 Handle(SALOME_InteractiveObject) anIO = It.Value();
1707 if ( !anIO.IsNull() ) {
1708 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1710 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1711 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1712 if ( !anIDSrc->_is_nil() ) {
1713 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1714 if (( !anActor && selected.Extent() == 1 ) &&
1715 ( anActor = SMESH::CreateActor( aStudy, anIO->getEntry() )))
1717 anActor->SetControlMode( aControl );
1718 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1719 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1723 if ( anActor->GetControlMode() != aControl )
1724 anActor->SetControlMode( aControl );
1725 QString functorName = functorToString( anActor->GetFunctor() );
1726 int anEntitiesCount = anActor->GetNumberControlEntities();
1727 if (anEntitiesCount >= 0)
1728 functorName = functorName + ": " + QString::number(anEntitiesCount);
1729 anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
1730 SMESH::RepaintCurrentView();
1731 #ifndef DISABLE_PLOT2DVIEWER
1732 if ( anActor->GetPlot2Histogram() ) {
1733 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1734 QString aHistogramName("%1 : %2");
1735 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1736 aHistogram->setName( aHistogramName );
1737 aHistogram->setHorTitle( functorName );
1738 SMESH::ProcessIn2DViewers( anActor );
1750 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1751 SMESH::MeshObjectType theType,
1752 const QString theInTypeName,
1753 QString & theOutTypeName)
1755 SMESH_TypeFilter aTypeFilter( theType );
1757 if ( !theIO.IsNull() )
1759 entry = theIO->getEntry();
1760 LightApp_DataOwner owner( entry );
1761 if ( aTypeFilter.isOk( &owner )) {
1762 theOutTypeName = theInTypeName;
1770 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1772 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1773 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1775 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1776 CORBA::String_var anID = aSComp->GetID().c_str();
1777 if ( !strcmp(anID.in(),theIO->getEntry()) )
1783 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1784 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1785 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1786 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1787 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1795 // QString CheckHomogeneousSelection()
1797 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1798 // SALOME_ListIO selected;
1800 // aSel->selectedObjects( selected );
1802 // QString RefType = CheckTypeObject(selected.First());
1803 // SALOME_ListIteratorOfListIO It(selected);
1804 // for ( ; It.More(); It.Next())
1806 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1807 // QString Type = CheckTypeObject(IObject);
1808 // if ( Type.compare(RefType) != 0 )
1809 // return "Heterogeneous Selection";
1815 uint randomize( uint size )
1817 static bool initialized = false;
1818 if ( !initialized ) {
1819 qsrand( QDateTime::currentDateTime().toTime_t() );
1823 v = uint( (double)( v ) / RAND_MAX * size );
1824 v = qMax( uint(0), qMin ( v, size-1 ) );
1830 void SMESHGUI::OnEditDelete()
1832 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1833 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1834 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1836 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1837 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1838 _PTR(GenericAttribute) anAttr;
1839 _PTR(AttributeIOR) anIOR;
1841 int objectCount = 0;
1843 QString aParentComponent = QString::null;
1844 Handle(SALOME_InteractiveObject) anIO;
1845 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1847 anIO = anIt.Value();
1848 QString cur = anIO->getComponentDataType();
1849 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1851 // check if object is reference
1852 _PTR(SObject) aRefSObj;
1853 aNameList.append("\n - ");
1854 if ( aSO->ReferencedObject( aRefSObj ) ) {
1855 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1856 aNameList.append( aRefName );
1857 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1860 aNameList.append(anIO->getName());
1864 if( aParentComponent.isNull() )
1865 aParentComponent = cur;
1866 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1867 aParentComponent = "";
1870 if ( objectCount == 0 )
1871 return; // No Valid Objects Selected
1873 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1874 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1875 QObject::tr("ERR_ERROR"),
1876 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1879 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1880 if (SUIT_MessageBox::warning
1881 (SMESHGUI::desktop(),
1882 QObject::tr("SMESH_WRN_WARNING"),
1883 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1884 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1885 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1888 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1890 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1891 // then treat them all starting from the deepest objects (at list back)
1892 std::list< _PTR(SObject) > listSO;
1893 SALOME_ListIteratorOfListIO It(selected);
1894 for( ; It.More(); It.Next()) // loop on selected IO's
1896 Handle(SALOME_InteractiveObject) IObject = It.Value();
1897 if(IObject->hasEntry()) {
1898 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1900 // disable removal of "SMESH" component object
1901 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1903 if ( engineIOR() == anIOR->Value().c_str() )
1906 //Check the referenced object
1907 _PTR(SObject) aRefSObject;
1908 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1909 aSO = aRefSObject; // Delete main Object instead of reference
1911 listSO.push_back( aSO );
1912 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1913 for ( ; itSO != listSO.end(); ++itSO ) {
1914 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1915 for (it->InitEx(false); it->More(); it->Next())
1916 listSO.push_back( it->Value() );
1920 // Check if none of objects to delete is referred from outside
1921 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1922 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1924 _PTR(SObject) SO = *ritSO;
1925 if ( !SO ) continue;
1926 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1927 for (size_t i = 0; i < aReferences.size(); i++) {
1928 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1929 std::string type = aComponent->ComponentDataType();
1930 if ( type != "SMESH" )
1932 SUIT_MessageBox::warning( anApp->desktop(),
1933 QObject::tr("WRN_WARNING"),
1934 QObject::tr("DEP_OBJECT") );
1935 return; // outside SMESH, there is an object depending on a SMESH object
1940 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1941 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1943 Handle(SALOME_InteractiveObject) IObject = It.Value();
1944 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1945 if ( !mesh->_is_nil() )
1949 // Treat SO's in the list starting from the back
1950 aStudyBuilder->NewCommand(); // There is a transaction
1951 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1953 _PTR(SObject) SO = *ritSO;
1954 if ( !SO ) continue;
1955 std::string anEntry = SO->GetID();
1957 /** Erase graphical object and remove all its data **/
1958 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1959 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1961 /** Remove an object from data structures **/
1962 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1963 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1964 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1965 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1966 aMesh->RemoveGroup( aGroup );
1968 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1969 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1970 aMesh->RemoveSubMesh( aSubMesh );
1972 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1974 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1977 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1978 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1979 QString objType = CheckTypeObject(IObject);
1980 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1981 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1982 aStudyBuilder->RemoveObjectWithChildren( SO );
1984 else {// default action: remove SObject from the study
1985 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1986 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1988 aStudyBuilder->RemoveObjectWithChildren( SO );
1992 } /* listSO back loop */
1994 aStudyBuilder->CommitCommand();
1996 /* Clear any previous selection */
1998 aSel->setSelectedObjects( l1 );
2000 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2004 SMESHGUI_EXPORT CAM_Module* createModule()
2006 return new SMESHGUI();
2009 SMESHGUI_EXPORT char* getModuleVersion() {
2010 return (char*)SMESH_VERSION_STR;
2014 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2016 //=============================================================================
2020 //=============================================================================
2021 SMESHGUI::SMESHGUI() :
2022 SalomeApp_Module( "SMESH" )
2024 if ( CORBA::is_nil( myComponentSMESH ) )
2026 CORBA::Boolean anIsEmbeddedMode;
2027 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2028 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2030 // 0019923: EDF 765 SMESH : default values of hypothesis
2031 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2032 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2033 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2034 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2035 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2037 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2038 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2039 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2041 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2042 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2046 myActiveDialogBox = 0;
2047 myFilterLibraryDlg = 0;
2051 myEventCallbackCommand = vtkCallbackCommand::New();
2052 myEventCallbackCommand->Delete();
2053 myEventCallbackCommand->SetClientData( this );
2054 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2057 /* load resources for all available meshers */
2058 SMESH::InitAvailableHypotheses();
2061 //=============================================================================
2065 //=============================================================================
2066 SMESHGUI::~SMESHGUI()
2070 //=============================================================================
2074 //=============================================================================
2075 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2077 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2079 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2084 //=============================================================================
2088 //=============================================================================
2089 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2091 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2095 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2096 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2097 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2098 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2099 return autoUpdate && !exceeded;
2102 //=============================================================================
2106 //=============================================================================
2107 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2108 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2110 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2114 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2115 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2116 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2118 SMESH::long_array_var info = theMesh->GetMeshInfo();
2119 long nbOdElems = info[SMDSEntity_0D];
2120 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2121 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2122 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2123 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2124 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2125 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2126 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2127 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] +
2128 info[SMDSEntity_Polyhedra] +
2129 info[SMDSEntity_Hexagonal_Prism];
2130 long nbBalls = info[SMDSEntity_Ball];
2132 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2133 *nbElements = requestedSize;
2135 *entities = SMESH_Actor::eAllEntity;
2138 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2140 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2142 if ( incrementalLimit ) {
2145 if ( nbOdElems > 0 ) {
2146 if ( total + nbOdElems > updateLimit ) {
2147 *entities = *entities & ~SMESH_Actor::e0DElements;
2148 *hidden = *hidden | SMESH_Actor::e0DElements;
2155 if ( nbEdges > 0 ) {
2156 if ( total + nbEdges > updateLimit ) {
2157 *entities = *entities & ~SMESH_Actor::eEdges;
2158 *hidden = *hidden | SMESH_Actor::eEdges;
2165 if ( nbFaces > 0 ) {
2166 if ( total + nbFaces > updateLimit ) {
2167 *entities = *entities & ~SMESH_Actor::eFaces;
2168 *hidden = *hidden | SMESH_Actor::eFaces;
2175 if ( nbVolumes > 0 ) {
2176 if ( total + nbVolumes > updateLimit ) {
2177 *entities = *entities & ~SMESH_Actor::eVolumes;
2178 *hidden = *hidden | SMESH_Actor::eVolumes;
2185 if ( nbBalls > 0 ) {
2186 if ( total + nbBalls > updateLimit ) {
2187 *entities = *entities & ~SMESH_Actor::eBallElem;
2188 *hidden = *hidden | SMESH_Actor::eBallElem;
2196 return autoUpdate && !exceeded;
2199 //=============================================================================
2203 //=============================================================================
2204 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2206 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2209 //=============================================================================
2213 //=============================================================================
2214 SMESHGUI* SMESHGUI::GetSMESHGUI()
2216 SMESHGUI* smeshMod = 0;
2217 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2220 CAM_Module* module = app->module( "Mesh" );
2221 smeshMod = dynamic_cast<SMESHGUI*>( module );
2224 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
2226 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
2229 _PTR(Study) aStudy = study->studyDS();
2231 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
2240 Standard_EXPORT SMESHGUI* GetComponentGUI()
2242 return SMESHGUI::GetSMESHGUI();
2246 //=============================================================================
2250 //=============================================================================
2251 void SMESHGUI::SetState(int aState)
2256 //=============================================================================
2260 //=============================================================================
2261 void SMESHGUI::ResetState()
2266 //=============================================================================
2270 //=============================================================================
2271 void SMESHGUI::EmitSignalDeactivateDialog()
2273 emit SignalDeactivateActiveDialog();
2276 //=============================================================================
2280 //=============================================================================
2281 void SMESHGUI::EmitSignalStudyFrameChanged()
2283 emit SignalStudyFrameChanged();
2286 //=============================================================================
2290 //=============================================================================
2291 void SMESHGUI::EmitSignalCloseAllDialogs()
2293 emit SignalCloseAllDialogs();
2296 //=============================================================================
2300 //=============================================================================
2301 void SMESHGUI::EmitSignalVisibilityChanged()
2303 emit SignalVisibilityChanged();
2306 //=============================================================================
2310 //=============================================================================
2311 void SMESHGUI::EmitSignalCloseView()
2313 emit SignalCloseView();
2316 //=============================================================================
2320 //=============================================================================
2321 void SMESHGUI::EmitSignalActivatedViewManager()
2323 emit SignalActivatedViewManager();
2326 //=============================================================================
2330 //=============================================================================
2331 QDialog *SMESHGUI::GetActiveDialogBox()
2333 return myActiveDialogBox;
2336 //=============================================================================
2340 //=============================================================================
2341 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2343 myActiveDialogBox = (QDialog *) aDlg;
2347 //=============================================================================
2351 //=============================================================================
2352 SUIT_Desktop* SMESHGUI::desktop()
2354 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2356 return app->desktop();
2361 //=============================================================================
2365 //=============================================================================
2366 SalomeApp_Study* SMESHGUI::activeStudy()
2368 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2370 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2375 //=============================================================================
2379 //=============================================================================
2380 void SMESHGUI::Modified( bool theIsUpdateActions )
2382 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2383 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2384 appStudy->Modified();
2385 if( theIsUpdateActions )
2386 app->updateActions();
2391 //=============================================================================
2395 //=============================================================================
2396 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2398 /* Here the position is on the bottom right corner - 10 */
2399 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2401 SUIT_Desktop *PP = desktop();
2402 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2403 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2407 //=============================================================================
2411 //=============================================================================
2412 static int isStudyLocked(_PTR(Study) theStudy){
2413 return theStudy->GetProperties()->IsLocked();
2416 static bool checkLock(_PTR(Study) theStudy) {
2417 if (isStudyLocked(theStudy)) {
2418 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2419 QObject::tr("WRN_WARNING"),
2420 QObject::tr("WRN_STUDY_LOCKED") );
2426 //=======================================================================
2427 //function : CheckActiveStudyLocked
2429 //=======================================================================
2431 bool SMESHGUI::isActiveStudyLocked()
2433 _PTR(Study) aStudy = activeStudy()->studyDS();
2434 return checkLock( aStudy );
2437 //=============================================================================
2441 //=============================================================================
2442 bool SMESHGUI::OnGUIEvent( int theCommandID )
2444 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2448 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2449 SUIT_ResourceMgr* mgr = resourceMgr();
2453 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2454 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2457 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2458 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2460 //QAction* act = action( theCommandID );
2462 switch (theCommandID) {
2463 case SMESHOp::OpDelete:
2464 if(checkLock(aStudy)) break;
2467 case SMESHOp::OpImportDAT:
2468 case SMESHOp::OpImportUNV:
2469 case SMESHOp::OpImportMED:
2470 case SMESHOp::OpImportSTL:
2471 case SMESHOp::OpImportCGNS:
2472 case SMESHOp::OpImportSAUV:
2473 case SMESHOp::OpImportGMF:
2474 case SMESHOp::OpPopupImportDAT:
2475 case SMESHOp::OpPopupImportUNV:
2476 case SMESHOp::OpPopupImportMED:
2477 case SMESHOp::OpPopupImportSTL:
2478 case SMESHOp::OpPopupImportCGNS:
2479 case SMESHOp::OpPopupImportSAUV:
2480 case SMESHOp::OpPopupImportGMF:
2482 if(checkLock(aStudy)) break;
2483 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2487 case SMESHOp::OpFileInformation:
2489 SALOME_ListIO selected;
2490 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2492 aSel->selectedObjects( selected );
2493 if( selected.Extent() )
2495 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2496 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2497 if ( !aMesh->_is_nil() )
2499 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2505 case SMESHOp::OpExportDAT:
2506 case SMESHOp::OpExportMED:
2507 case SMESHOp::OpExportUNV:
2508 case SMESHOp::OpExportSTL:
2509 case SMESHOp::OpExportCGNS:
2510 case SMESHOp::OpExportSAUV:
2511 case SMESHOp::OpExportGMF:
2512 case SMESHOp::OpPopupExportDAT:
2513 case SMESHOp::OpPopupExportMED:
2514 case SMESHOp::OpPopupExportUNV:
2515 case SMESHOp::OpPopupExportSTL:
2516 case SMESHOp::OpPopupExportCGNS:
2517 case SMESHOp::OpPopupExportSAUV:
2518 case SMESHOp::OpPopupExportGMF:
2520 ::ExportMeshToFile(theCommandID);
2524 case SMESHOp::OpReset: // SCALAR BAR
2526 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2527 SALOME_ListIO selected;
2529 aSel->selectedObjects( selected );
2531 SALOME_ListIteratorOfListIO it(selected);
2532 for( ; it.More(); it.Next()) {
2533 Handle(SALOME_InteractiveObject) anIO = it.Value();
2534 if( anIO->hasEntry() ) {
2535 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2536 anActor->SetControlMode( SMESH_Actor::eNone );
2537 #ifndef DISABLE_PLOT2DVIEWER
2538 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2543 SMESH::UpdateView();
2546 case SMESHOp::OpScalarBarProperties:
2548 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2551 case SMESHOp::OpShowScalarBar:
2553 // show/hide scalar bar
2554 ::ShowElement(theCommandID);
2557 case SMESHOp::OpSaveDistribution:
2559 // dump control distribution data to the text file
2560 ::SaveDistribution();
2564 case SMESHOp::OpShowDistribution:
2566 // show/hide distribution
2567 ::ShowElement(theCommandID);
2571 #ifndef DISABLE_PLOT2DVIEWER
2572 case SMESHOp::OpPlotDistribution:
2574 // plot distribution
2575 ::PlotDistribution();
2581 case SMESHOp::OpAutoColor:
2585 case SMESHOp::OpDisableAutoColor:
2586 ::DisableAutoColor();
2589 case SMESHOp::OpClipping:
2590 case SMESHOp::OpTransparency:
2591 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2594 case SMESHOp::OpDMWireframe:
2595 case SMESHOp::OpDMShading:
2596 case SMESHOp::OpDMNodes:
2597 case SMESHOp::OpDMShrink:
2598 ::SetDisplayMode(theCommandID, myMarkerMap);
2601 //2D quadratic representation
2602 case SMESHOp::OpRepresentationLines:
2603 case SMESHOp::OpRepresentationArcs:
2604 ::SetDisplayMode(theCommandID, myMarkerMap);
2608 case SMESHOp::OpDE0DElements:
2609 case SMESHOp::OpDEEdges:
2610 case SMESHOp::OpDEFaces:
2611 case SMESHOp::OpDEVolumes:
2612 case SMESHOp::OpDEBalls:
2613 case SMESHOp::OpDEAllEntity:
2614 ::SetDisplayEntity(theCommandID);
2617 // Choose entities to be displayed
2618 case SMESHOp::OpDEChoose:
2620 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2624 case SMESHOp::OpOrientationOnFaces:
2626 SUIT_OverrideCursor wc;
2627 LightApp_SelectionMgr* mgr = selectionMgr();
2628 SALOME_ListIO selected; mgr->selectedObjects( selected );
2630 SALOME_ListIteratorOfListIO it(selected);
2631 for( ; it.More(); it.Next()) {
2632 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2633 if(anIObject->hasEntry()) {
2634 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2635 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2642 case SMESHOp::OpUpdate:
2644 if(checkLock(aStudy)) break;
2645 SUIT_OverrideCursor wc;
2647 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2650 SMESH::UpdateView();
2652 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2653 SMESH::OnVisuException();
2655 catch (...) { // PAL16774 (Crash after display of many groups)
2656 SMESH::OnVisuException();
2660 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2661 aSel->selectedObjects( l );
2662 aSel->setSelectedObjects( l );
2666 case SMESHOp::OpHide:
2667 case SMESHOp::OpShow:
2668 case SMESHOp::OpShowOnly:
2670 SUIT_OverrideCursor wc;
2671 SMESH::EDisplaing anAction;
2672 switch (theCommandID) {
2673 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2674 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2675 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2678 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2679 SALOME_ListIO sel_objects, to_process;
2681 aSel->selectedObjects( sel_objects );
2683 if ( theCommandID==SMESHOp::OpShowOnly )
2685 //MESSAGE("anAction = SMESH::eDisplayOnly");
2686 startOperation( myEraseAll );
2689 extractContainers( sel_objects, to_process );
2694 SALOME_ListIteratorOfListIO It( to_process );
2695 for ( ; It.More(); It.Next())
2697 Handle(SALOME_InteractiveObject) IOS = It.Value();
2698 if ( IOS->hasEntry() )
2700 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2701 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2702 break; // PAL16774 (Crash after display of many groups)
2704 if (anAction == SMESH::eDisplayOnly)
2705 anAction = SMESH::eDisplay;
2710 // PAL13338 + PAL15161 -->
2711 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !checkLock(aStudy)) {
2712 SMESH::UpdateView();
2713 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2715 // PAL13338 + PAL15161 <--
2717 catch (...) { // PAL16774 (Crash after display of many groups)
2718 SMESH::OnVisuException();
2721 if (anAction == SMESH::eErase) {
2723 aSel->setSelectedObjects( l1 );
2726 aSel->setSelectedObjects( to_process );
2731 case SMESHOp::OpNode:
2733 if(checkLock(aStudy)) break;
2736 EmitSignalDeactivateDialog();
2738 ( new SMESHGUI_NodesDlg( this ) )->show();
2741 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2746 case SMESHOp::OpCreateMesh:
2747 case SMESHOp::OpCreateSubMesh:
2748 case SMESHOp::OpEditMeshOrSubMesh:
2749 case SMESHOp::OpEditMesh:
2750 case SMESHOp::OpEditSubMesh:
2751 case SMESHOp::OpCompute:
2752 case SMESHOp::OpComputeSubMesh:
2753 case SMESHOp::OpPreCompute:
2754 case SMESHOp::OpEvaluate:
2755 case SMESHOp::OpMeshOrder:
2756 startOperation( theCommandID );
2758 case SMESHOp::OpCopyMesh:
2760 if (checkLock(aStudy)) break;
2761 EmitSignalDeactivateDialog();
2762 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2765 case SMESHOp::OpBuildCompoundMesh:
2767 if (checkLock(aStudy)) break;
2768 EmitSignalDeactivateDialog();
2769 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2773 case SMESHOp::OpDiagonalInversion:
2774 case SMESHOp::OpUnionOfTwoTriangle:
2778 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2782 if ( checkLock( aStudy ) )
2785 /*Standard_Boolean aRes;
2786 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2787 if ( aMesh->_is_nil() )
2789 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2790 tr( "SMESH_BAD_SELECTION" ) );
2794 EmitSignalDeactivateDialog();
2795 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2796 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2798 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2801 case SMESHOp::OpOrientation:
2802 case SMESHOp::OpUnionOfTriangles:
2803 case SMESHOp::OpCuttingOfQuadrangles:
2804 case SMESHOp::OpSplitVolumes:
2808 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2812 if ( checkLock( aStudy ) )
2815 EmitSignalDeactivateDialog();
2816 SMESHGUI_MultiEditDlg* aDlg = NULL;
2817 if ( theCommandID == SMESHOp::OpOrientation )
2818 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2819 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2820 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2821 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2822 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2824 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2829 case SMESHOp::OpSmoothing:
2831 if(checkLock(aStudy)) break;
2833 EmitSignalDeactivateDialog();
2834 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2837 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2841 case SMESHOp::OpExtrusion:
2843 if (checkLock(aStudy)) break;
2845 EmitSignalDeactivateDialog();
2846 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2848 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2852 case SMESHOp::OpExtrusionAlongAPath:
2854 if (checkLock(aStudy)) break;
2856 EmitSignalDeactivateDialog();
2857 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2859 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2863 case SMESHOp::OpRevolution:
2865 if(checkLock(aStudy)) break;
2867 EmitSignalDeactivateDialog();
2868 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2871 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2875 case SMESHOp::OpPatternMapping:
2877 if ( checkLock( aStudy ) )
2881 EmitSignalDeactivateDialog();
2882 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2885 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2889 case SMESHOp::OpSplitBiQuadratic:
2890 case SMESHOp::OpConvertMeshToQuadratic:
2891 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2892 case SMESHOp::OpReorientFaces:
2893 case SMESHOp::OpCreateGeometryGroup:
2895 startOperation( theCommandID );
2898 case SMESHOp::OpCreateGroup:
2902 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2906 if(checkLock(aStudy)) break;
2907 EmitSignalDeactivateDialog();
2908 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2910 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2911 SALOME_ListIO selected;
2913 aSel->selectedObjects( selected );
2915 int nbSel = selected.Extent();
2917 // check if mesh is selected
2918 aMesh = SMESH::GetMeshByIO( selected.First() );
2920 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2925 case SMESHOp::OpConstructGroup:
2929 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2933 if(checkLock(aStudy)) break;
2934 EmitSignalDeactivateDialog();
2936 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2937 SALOME_ListIO selected;
2939 aSel->selectedObjects( selected );
2941 int nbSel = selected.Extent();
2943 // check if submesh is selected
2944 Handle(SALOME_InteractiveObject) IObject = selected.First();
2945 if (IObject->hasEntry()) {
2946 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2948 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2949 if (!aSubMesh->_is_nil()) {
2951 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2952 // get submesh elements list by types
2953 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2954 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2955 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2956 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2957 // create group for each type o elements
2958 QString aName = IObject->getName();
2959 QStringList anEntryList;
2960 if (aNodes->length() > 0) {
2961 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2962 aGroup->Add(aNodes.inout());
2963 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2964 anEntryList.append( aSObject->GetID().c_str() );
2966 if (aEdges->length() > 0) {
2967 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2968 aGroup->Add(aEdges.inout());
2969 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2970 anEntryList.append( aSObject->GetID().c_str() );
2972 if (aFaces->length() > 0) {
2973 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2974 aGroup->Add(aFaces.inout());
2975 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2976 anEntryList.append( aSObject->GetID().c_str() );
2978 if (aVolumes->length() > 0) {
2979 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2980 aGroup->Add(aVolumes.inout());
2981 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2982 anEntryList.append( aSObject->GetID().c_str() );
2985 anApp->browseObjects( anEntryList );
2987 catch(const SALOME::SALOME_Exception & S_ex){
2988 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2995 SUIT_MessageBox::warning(desktop(),
2996 tr("SMESH_WRN_WARNING"),
2997 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3002 case SMESHOp::OpEditGroup:
3006 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3010 if(checkLock(aStudy)) break;
3011 EmitSignalDeactivateDialog();
3013 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3014 SALOME_ListIO selected;
3016 aSel->selectedObjects( selected );
3018 SALOME_ListIteratorOfListIO It (selected);
3019 int nbSelectedGroups = 0;
3020 for ( ; It.More(); It.Next() )
3022 SMESH::SMESH_GroupBase_var aGroup =
3023 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3024 if (!aGroup->_is_nil()) {
3026 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3030 if (nbSelectedGroups == 0)
3032 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3038 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3040 if(checkLock(aStudy)) break;
3041 if (myState == 800) {
3042 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3043 if (aDlg) aDlg->onAdd();
3048 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3050 if(checkLock(aStudy)) break;
3051 if (myState == 800) {
3052 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3053 if (aDlg) aDlg->onRemove();
3058 case SMESHOp::OpEditGeomGroupAsGroup:
3062 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3066 if(checkLock(aStudy)) break;
3067 EmitSignalDeactivateDialog();
3069 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3070 SALOME_ListIO selected;
3072 aSel->selectedObjects( selected );
3074 SALOME_ListIteratorOfListIO It (selected);
3075 for ( ; It.More(); It.Next() )
3077 SMESH::SMESH_GroupOnGeom_var aGroup =
3078 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3079 if (!aGroup->_is_nil()) {
3080 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3085 SMESH::SMESH_GroupOnFilter_var aGroup =
3086 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3087 if (!aGroup->_is_nil()) {
3088 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3096 case SMESHOp::OpUnionGroups:
3097 case SMESHOp::OpIntersectGroups:
3098 case SMESHOp::OpCutGroups:
3102 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3106 if ( checkLock( aStudy ) )
3109 EmitSignalDeactivateDialog();
3111 SMESHGUI_GroupOpDlg* aDlg = 0;
3112 if ( theCommandID == SMESHOp::OpUnionGroups )
3113 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3114 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3115 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3117 aDlg = new SMESHGUI_CutGroupsDlg( this );
3124 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3126 if ( checkLock( aStudy ) )
3129 EmitSignalDeactivateDialog();
3130 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3136 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3140 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3144 if ( checkLock( aStudy ) )
3147 EmitSignalDeactivateDialog();
3149 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3153 case SMESHOp::OpMeshInformation:
3154 case SMESHOp::OpWhatIs:
3156 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3157 EmitSignalDeactivateDialog();
3158 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3159 SALOME_ListIO selected;
3161 aSel->selectedObjects( selected );
3163 if ( selected.Extent() > 1 ) { // a dlg for each IO
3164 SALOME_ListIteratorOfListIO It( selected );
3165 for ( ; It.More(); It.Next() ) {
3166 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3167 dlg->showInfo( It.Value() );
3172 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3178 case SMESHOp::OpFindElementByPoint:
3180 startOperation( theCommandID );
3184 case SMESHOp::OpEditHypothesis:
3186 if(checkLock(aStudy)) break;
3188 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3189 SALOME_ListIO selected;
3191 aSel->selectedObjects( selected );
3193 int nbSel = selected.Extent();
3196 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3197 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3199 if ( !aHypothesis->_is_nil() )
3201 SMESHGUI_GenericHypothesisCreator* aCreator =
3202 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3205 // set geometry of mesh and sub-mesh to aCreator
3206 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3207 if ( selected.Extent() == 1 )
3209 QString subGeomID, meshGeomID;
3210 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3211 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3213 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3214 aCreator->setShapeEntry( subGeomID );
3215 aCreator->setMainShapeEntry( meshGeomID );
3219 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3229 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3231 if(checkLock(aStudy)) break;
3232 SUIT_OverrideCursor wc;
3234 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3235 SALOME_ListIO selected;
3237 aSel->selectedObjects( selected, QString::null, false );
3239 SALOME_ListIteratorOfListIO It(selected);
3240 for (int i = 0; It.More(); It.Next(), i++) {
3241 Handle(SALOME_InteractiveObject) IObject = It.Value();
3242 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3245 aSel->setSelectedObjects( l1 );
3250 case SMESHOp::OpElem0D:
3251 case SMESHOp::OpBall:
3252 case SMESHOp::OpEdge:
3253 case SMESHOp::OpTriangle:
3254 case SMESHOp::OpQuadrangle:
3255 case SMESHOp::OpPolygon:
3256 case SMESHOp::OpTetrahedron:
3257 case SMESHOp::OpHexahedron:
3258 case SMESHOp::OpPentahedron:
3259 case SMESHOp::OpPyramid:
3260 case SMESHOp::OpHexagonalPrism:
3262 if(checkLock(aStudy)) break;
3264 EmitSignalDeactivateDialog();
3265 SMDSAbs_EntityType type = SMDSEntity_Edge;
3266 switch (theCommandID) {
3267 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3268 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3269 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3270 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3271 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3272 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3273 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3274 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3275 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3276 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3279 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3282 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3286 case SMESHOp::OpPolyhedron:
3288 if(checkLock(aStudy)) break;
3290 EmitSignalDeactivateDialog();
3291 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3294 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3298 case SMESHOp::OpQuadraticEdge:
3299 case SMESHOp::OpQuadraticTriangle:
3300 case SMESHOp::OpBiQuadraticTriangle:
3301 case SMESHOp::OpQuadraticQuadrangle:
3302 case SMESHOp::OpBiQuadraticQuadrangle:
3303 case SMESHOp::OpQuadraticPolygon:
3304 case SMESHOp::OpQuadraticTetrahedron:
3305 case SMESHOp::OpQuadraticPyramid:
3306 case SMESHOp::OpQuadraticPentahedron:
3307 case SMESHOp::OpQuadraticHexahedron:
3308 case SMESHOp::OpTriQuadraticHexahedron:
3310 if(checkLock(aStudy)) break;
3312 EmitSignalDeactivateDialog();
3313 SMDSAbs_EntityType type = SMDSEntity_Last;
3315 switch (theCommandID) {
3316 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3317 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3318 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3319 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3320 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3321 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3322 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3323 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3324 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3325 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3326 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3329 if ( type != SMDSEntity_Last )
3330 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3333 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3334 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3338 case SMESHOp::OpRemoveNodes:
3340 if(checkLock(aStudy)) break;
3342 EmitSignalDeactivateDialog();
3343 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3346 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3347 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3351 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3353 if(checkLock(aStudy)) break;
3355 EmitSignalDeactivateDialog();
3356 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3360 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3361 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3365 case SMESHOp::OpClearMesh: {
3367 if(checkLock(aStudy)) break;
3369 SALOME_ListIO selected;
3370 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3371 aSel->selectedObjects( selected );
3373 SUIT_OverrideCursor wc;
3374 SALOME_ListIteratorOfListIO It (selected);
3375 for ( ; It.More(); It.Next() )
3377 Handle(SALOME_InteractiveObject) IOS = It.Value();
3378 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3379 if ( aMesh->_is_nil()) continue;
3382 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3383 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3384 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3385 SMESH::ModifiedMesh( aMeshSObj, false, true);
3386 // hide groups and submeshes
3387 _PTR(ChildIterator) anIter =
3388 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3389 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3391 _PTR(SObject) so = anIter->Value();
3392 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3395 catch (const SALOME::SALOME_Exception& S_ex){
3397 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3401 SMESH::UpdateView();
3405 case SMESHOp::OpRemoveOrphanNodes:
3407 if(checkLock(aStudy)) break;
3408 SALOME_ListIO selected;
3409 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3410 aSel->selectedObjects( selected );
3411 if ( selected.Extent() == 1 ) {
3412 Handle(SALOME_InteractiveObject) anIO = selected.First();
3413 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3414 if ( !aMesh->_is_nil() ) {
3415 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3416 tr( "SMESH_WARNING" ),
3417 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3418 SUIT_MessageBox::Yes |
3419 SUIT_MessageBox::No,
3420 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3423 SUIT_OverrideCursor wc;
3424 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3425 int removed = aMeshEditor->RemoveOrphanNodes();
3426 SUIT_MessageBox::information(SMESHGUI::desktop(),
3427 tr("SMESH_INFORMATION"),
3428 tr("NB_NODES_REMOVED").arg(removed));
3429 if ( removed > 0 ) {
3430 SMESH::UpdateView();
3431 SMESHGUI::Modified();
3434 catch (const SALOME::SALOME_Exception& S_ex) {
3435 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3444 case SMESHOp::OpRenumberingNodes:
3446 if(checkLock(aStudy)) break;
3448 EmitSignalDeactivateDialog();
3449 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3453 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3454 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3458 case SMESHOp::OpRenumberingElements:
3460 if(checkLock(aStudy)) break;
3462 EmitSignalDeactivateDialog();
3463 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3467 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3468 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3472 case SMESHOp::OpTranslation:
3474 if(checkLock(aStudy)) break;
3476 EmitSignalDeactivateDialog();
3477 ( new SMESHGUI_TranslationDlg( this ) )->show();
3480 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3481 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3485 case SMESHOp::OpRotation:
3487 if(checkLock(aStudy)) break;
3489 EmitSignalDeactivateDialog();
3490 ( new SMESHGUI_RotationDlg( this ) )->show();
3493 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3494 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3498 case SMESHOp::OpSymmetry:
3500 if(checkLock(aStudy)) break;
3502 EmitSignalDeactivateDialog();
3503 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3506 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3507 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3511 case SMESHOp::OpScale:
3513 if(checkLock(aStudy)) break;
3515 EmitSignalDeactivateDialog();
3516 ( new SMESHGUI_ScaleDlg( this ) )->show();
3519 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3520 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3525 case SMESHOp::OpSewing:
3527 if(checkLock(aStudy)) break;
3529 EmitSignalDeactivateDialog();
3530 ( new SMESHGUI_SewingDlg( this ) )->show();
3533 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3534 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3538 case SMESHOp::OpMergeNodes:
3540 if(checkLock(aStudy)) break;
3542 EmitSignalDeactivateDialog();
3543 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3546 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3547 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3551 case SMESHOp::OpMergeElements:
3553 if (checkLock(aStudy)) break;
3555 EmitSignalDeactivateDialog();
3556 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3558 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3559 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3564 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3565 startOperation( SMESHOp::OpMoveNode );
3568 case SMESHOp::OpDuplicateNodes:
3570 if(checkLock(aStudy)) break;
3572 EmitSignalDeactivateDialog();
3573 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3576 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3577 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3582 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3583 startOperation( SMESHOp::OpElem0DOnElemNodes );
3586 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3588 static QList<int> aTypes;
3589 if ( aTypes.isEmpty() )
3591 aTypes.append( SMESH::NODE );
3592 aTypes.append( SMESH::EDGE );
3593 aTypes.append( SMESH::FACE );
3594 aTypes.append( SMESH::VOLUME );
3596 if (!myFilterLibraryDlg)
3597 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3598 else if (myFilterLibraryDlg->isHidden())
3599 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3600 myFilterLibraryDlg->raise();
3604 case SMESHOp::OpFreeNode:
3605 case SMESHOp::OpEqualNode:
3606 case SMESHOp::OpNodeConnectivityNb:
3607 case SMESHOp::OpFreeEdge:
3608 case SMESHOp::OpFreeBorder:
3609 case SMESHOp::OpLength:
3610 case SMESHOp::OpConnection:
3611 case SMESHOp::OpEqualEdge:
3612 case SMESHOp::OpFreeFace:
3613 case SMESHOp::OpBareBorderFace:
3614 case SMESHOp::OpOverConstrainedFace:
3615 case SMESHOp::OpLength2D:
3616 case SMESHOp::OpConnection2D:
3617 case SMESHOp::OpArea:
3618 case SMESHOp::OpTaper:
3619 case SMESHOp::OpAspectRatio:
3620 case SMESHOp::OpMinimumAngle:
3621 case SMESHOp::OpWarpingAngle:
3622 case SMESHOp::OpSkew:
3623 case SMESHOp::OpMaxElementLength2D:
3624 case SMESHOp::OpEqualFace:
3625 case SMESHOp::OpAspectRatio3D:
3626 case SMESHOp::OpVolume:
3627 case SMESHOp::OpMaxElementLength3D:
3628 case SMESHOp::OpBareBorderVolume:
3629 case SMESHOp::OpOverConstrainedVolume:
3630 case SMESHOp::OpEqualVolume:
3633 LightApp_SelectionMgr* mgr = selectionMgr();
3634 SALOME_ListIO selected; mgr->selectedObjects( selected );
3636 if( !selected.IsEmpty() ) {
3637 SUIT_OverrideCursor wc;
3638 ::Control( theCommandID );
3641 SUIT_MessageBox::warning(desktop(),
3642 tr( "SMESH_WRN_WARNING" ),
3643 tr( "SMESH_BAD_SELECTION" ) );
3647 SUIT_MessageBox::warning(desktop(),
3648 tr( "SMESH_WRN_WARNING" ),
3649 tr( "NOT_A_VTK_VIEWER" ) );
3652 case SMESHOp::OpOverallMeshQuality:
3653 OverallMeshQuality();
3655 case SMESHOp::OpNumberingNodes:
3657 SUIT_OverrideCursor wc;
3658 LightApp_SelectionMgr* mgr = selectionMgr();
3659 SALOME_ListIO selected; mgr->selectedObjects( selected );
3661 SALOME_ListIteratorOfListIO it(selected);
3662 for( ; it.More(); it.Next()) {
3663 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3664 if(anIObject->hasEntry()) {
3665 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3666 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3672 case SMESHOp::OpNumberingElements:
3674 SUIT_OverrideCursor wc;
3675 LightApp_SelectionMgr* mgr = selectionMgr();
3676 SALOME_ListIO selected; mgr->selectedObjects( selected );
3678 SALOME_ListIteratorOfListIO it(selected);
3679 for( ; it.More(); it.Next()) {
3680 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3681 if(anIObject->hasEntry())
3682 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3683 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3688 case SMESHOp::OpPropertiesLength:
3689 case SMESHOp::OpPropertiesArea:
3690 case SMESHOp::OpPropertiesVolume:
3691 case SMESHOp::OpMinimumDistance:
3692 case SMESHOp::OpBoundingBox:
3694 int page = SMESHGUI_MeasureDlg::MinDistance;
3695 if ( theCommandID == SMESHOp::OpBoundingBox )
3696 page = SMESHGUI_MeasureDlg::BoundingBox;
3697 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3698 page = SMESHGUI_MeasureDlg::Length;
3699 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3700 page = SMESHGUI_MeasureDlg::Area;
3701 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3702 page = SMESHGUI_MeasureDlg::Volume;
3704 EmitSignalDeactivateDialog();
3705 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3709 case SMESHOp::OpSortChild:
3715 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3716 //updateObjBrowser();
3720 //=============================================================================
3724 //=============================================================================
3725 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3730 //=============================================================================
3734 //=============================================================================
3735 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3740 //=============================================================================
3744 //=============================================================================
3745 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3750 //=============================================================================
3751 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3752 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3754 //=============================================================================
3755 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3756 SUIT_ViewWindow* wnd )
3758 if(theIO->hasEntry()){
3759 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3760 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3764 //=======================================================================
3765 // function : createSMESHAction
3767 //=======================================================================
3768 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3769 const int key, const bool toggle, const QString& shortcutAction )
3772 QWidget* parent = application()->desktop();
3773 SUIT_ResourceMgr* resMgr = resourceMgr();
3775 if ( !icon_id.isEmpty() )
3776 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3778 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3779 if ( !pix.isNull() )
3780 icon = QIcon( pix );
3782 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3783 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3784 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3786 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3787 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3790 //=======================================================================
3791 // function : createPopupItem
3793 //=======================================================================
3794 void SMESHGUI::createPopupItem( const int id,
3795 const QString& clients,
3796 const QString& types,
3797 const QString& theRule,
3800 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3801 popupMgr()->insert( action( id ), pId, 0 );
3803 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3804 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3805 QString rule = "(%1) and (%2) and (%3)";
3806 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3807 if( clients.isEmpty() )
3808 rule = rule.arg( QString( "true" ) );
3810 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3811 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3814 bool cont = myRules.contains( id );
3816 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3818 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3819 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3822 //=======================================================================
3823 // function : initialize
3825 //=======================================================================
3826 void SMESHGUI::initialize( CAM_Application* app )
3828 SalomeApp_Module::initialize( app );
3830 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3832 /* Automatic Update flag */
3833 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3835 // ----- create actions --------------
3837 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3838 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
3839 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
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::OpPopupImportUNV, "IMPORT_UNV");
3847 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
3848 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
3850 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
3852 createSMESHAction( SMESHOp::OpPopupImportSAUV, "IMPORT_SAUV" );
3853 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
3855 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
3856 createSMESHAction( SMESHOp::OpExportMED, "MED" );
3857 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
3858 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
3860 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
3862 createSMESHAction( SMESHOp::OpExportSAUV, "SAUV");
3863 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
3864 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
3865 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
3866 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
3867 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
3869 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
3871 createSMESHAction( SMESHOp::OpPopupExportSAUV, "SAUV");
3872 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
3873 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
3874 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3875 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
3876 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3877 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3878 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
3879 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
3880 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
3881 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3882 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
3883 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
3884 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
3885 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3886 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
3887 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
3888 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3889 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
3890 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3891 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3892 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3893 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
3894 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
3895 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
3896 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
3897 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
3898 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
3899 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
3900 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
3901 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
3902 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3903 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
3905 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3906 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3907 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
3908 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3909 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3910 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
3911 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
3912 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3913 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3914 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3915 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3916 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3917 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3918 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
3919 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
3920 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
3921 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
3922 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
3923 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
3924 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3925 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3926 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3927 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3928 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3929 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3930 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3931 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3932 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
3934 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
3935 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
3936 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3937 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
3938 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
3939 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3940 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
3941 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
3942 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
3943 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
3944 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
3945 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
3946 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
3947 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3948 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3949 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3950 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3951 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3952 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3953 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
3954 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3955 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3956 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3957 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3958 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3960 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3961 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3962 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3963 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
3965 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3966 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3968 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3969 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
3970 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3971 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
3972 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3973 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
3974 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3975 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3976 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3977 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
3978 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
3979 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3980 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
3981 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
3982 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
3983 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3984 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
3985 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
3986 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
3987 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3988 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
3989 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
3990 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3991 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3993 createSMESHAction( SMESHOp::OpReset, "RESET" );
3994 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
3995 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
3996 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
3997 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
3998 #ifndef DISABLE_PLOT2DVIEWER
3999 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4001 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4002 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4003 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4004 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4005 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4006 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4007 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4008 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4009 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4010 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4011 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4012 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4013 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4015 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4016 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4018 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4019 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4020 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4021 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4022 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4023 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4024 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4025 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4026 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4028 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4029 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4030 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4031 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4032 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4034 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4035 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4036 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4038 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4040 QList<int> aCtrlActions;
4041 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4042 << SMESHOp::OpNodeConnectivityNb // node controls
4043 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4044 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4045 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4046 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4047 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4048 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4049 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4050 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4051 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4052 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4053 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4054 aCtrlGroup->setExclusive( true );
4055 for( int i = 0; i < aCtrlActions.size(); i++ )
4056 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4058 // ----- create menu --------------
4059 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4060 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4061 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4062 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4063 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4064 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4065 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4066 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4068 createMenu( separator(), fileId );
4070 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4071 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4072 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4073 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4074 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4075 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4076 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4077 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4078 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4079 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4080 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4081 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4082 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4084 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4085 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4086 createMenu( SMESHOp::OpImportMED, importId, -1 );
4087 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4089 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4091 createMenu( SMESHOp::OpImportSAUV, importId, -1 );
4092 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4093 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4094 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4095 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4096 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4098 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4100 createMenu( SMESHOp::OpExportSAUV, exportId, -1 );
4101 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4102 createMenu( separator(), fileId, 10 );
4104 createMenu( SMESHOp::OpDelete, editId, -1 );
4106 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4108 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4109 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4110 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4111 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4112 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4113 createMenu( separator(), meshId, -1 );
4114 createMenu( SMESHOp::OpCompute, meshId, -1 );
4115 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4116 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4117 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4118 createMenu( separator(), meshId, -1 );
4119 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4120 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4121 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4122 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4123 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4124 createMenu( separator(), meshId, -1 );
4125 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4126 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4127 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4128 createMenu( separator(), meshId, -1 );
4129 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4130 createMenu( separator(), meshId, -1 );
4131 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4132 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4133 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4134 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4135 createMenu( separator(), meshId, -1 );
4137 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4138 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4139 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4140 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4141 createMenu( SMESHOp::OpLength, edgeId, -1 );
4142 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4143 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4144 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4145 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4146 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4147 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4148 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4149 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4150 createMenu( SMESHOp::OpArea, faceId, -1 );
4151 createMenu( SMESHOp::OpTaper, faceId, -1 );
4152 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4153 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4154 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4155 createMenu( SMESHOp::OpSkew, faceId, -1 );
4156 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4157 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4158 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4159 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4160 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4161 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4162 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4163 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4164 createMenu( separator(), ctrlId, -1 );
4165 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4166 createMenu( separator(), ctrlId, -1 );
4167 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4169 createMenu( SMESHOp::OpNode, addId, -1 );
4170 createMenu( SMESHOp::OpElem0D, addId, -1 );
4171 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4172 createMenu( SMESHOp::OpBall, addId, -1 );
4173 createMenu( SMESHOp::OpEdge, addId, -1 );
4174 createMenu( SMESHOp::OpTriangle, addId, -1 );
4175 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4176 createMenu( SMESHOp::OpPolygon, addId, -1 );
4177 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4178 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4179 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4180 createMenu( SMESHOp::OpPyramid, addId, -1 );
4181 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4182 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4183 createMenu( separator(), addId, -1 );
4184 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4185 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4186 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4187 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4188 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4189 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4190 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4191 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4192 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4193 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4194 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4196 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4197 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4198 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4199 createMenu( separator(), removeId, -1 );
4200 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4201 createMenu( separator(), removeId, -1 );
4202 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4204 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4205 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4207 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4208 createMenu( SMESHOp::OpRotation, transfId, -1 );
4209 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4210 createMenu( SMESHOp::OpScale, transfId, -1 );
4211 createMenu( SMESHOp::OpSewing, transfId, -1 );
4212 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4213 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4214 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4216 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4217 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4218 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4219 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4220 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4221 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4222 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4223 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4224 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4225 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4226 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4227 createMenu( SMESHOp::OpExtrusionAlongAPath , modifyId, -1 );
4228 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4229 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4230 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4231 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4233 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4234 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4235 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4236 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4237 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4238 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4240 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4241 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4242 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4243 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4245 // ----- create toolbars --------------
4246 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ),
4247 info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ),
4248 groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ),
4249 ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ),
4250 ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ),
4251 ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ),
4252 ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ),
4253 addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ),
4254 addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ),
4255 remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ),
4256 //renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ),
4257 transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
4258 modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ),
4259 measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ),
4260 dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4262 createTool( SMESHOp::OpCreateMesh, meshTb );
4263 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4264 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4265 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4266 createTool( SMESHOp::OpCopyMesh, meshTb );
4267 createTool( separator(), meshTb );
4268 createTool( SMESHOp::OpCompute, meshTb );
4269 createTool( SMESHOp::OpPreCompute, meshTb );
4270 createTool( SMESHOp::OpEvaluate, meshTb );
4271 createTool( SMESHOp::OpMeshOrder, meshTb );
4273 createTool( SMESHOp::OpCreateGroup, groupTb );
4274 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4275 createTool( SMESHOp::OpConstructGroup, groupTb );
4276 createTool( SMESHOp::OpEditGroup, groupTb );
4278 createTool( SMESHOp::OpMeshInformation, info );
4279 //createTool( SMESHOp::OpStdInfo, meshTb );
4280 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4281 createTool( SMESHOp::OpFindElementByPoint, info );
4283 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4284 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4285 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4287 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4288 createTool( SMESHOp::OpLength, ctrl1dTb );
4289 createTool( SMESHOp::OpConnection, ctrl1dTb );
4290 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4292 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4293 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4294 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4295 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4296 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4297 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4298 createTool( SMESHOp::OpArea, ctrl2dTb );
4299 createTool( SMESHOp::OpTaper, ctrl2dTb );
4300 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4301 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4302 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4303 createTool( SMESHOp::OpSkew, ctrl2dTb );
4304 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4305 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4307 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4308 createTool( SMESHOp::OpVolume, ctrl3dTb );
4309 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4310 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4311 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4312 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4314 createTool( SMESHOp::OpNode, addElemTb );
4315 createTool( SMESHOp::OpElem0D, addElemTb );
4316 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4317 createTool( SMESHOp::OpBall, addElemTb );
4318 createTool( SMESHOp::OpEdge, addElemTb );
4319 createTool( SMESHOp::OpTriangle, addElemTb );
4320 createTool( SMESHOp::OpQuadrangle, addElemTb );
4321 createTool( SMESHOp::OpPolygon, addElemTb );
4322 createTool( SMESHOp::OpTetrahedron, addElemTb );
4323 createTool( SMESHOp::OpHexahedron, addElemTb );
4324 createTool( SMESHOp::OpPentahedron, addElemTb );
4325 createTool( SMESHOp::OpPyramid, addElemTb );
4326 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4327 createTool( SMESHOp::OpPolyhedron, addElemTb );
4329 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4330 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4331 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4332 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4333 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4334 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4335 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4336 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4337 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4338 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4339 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4341 createTool( SMESHOp::OpRemoveNodes, remTb );
4342 createTool( SMESHOp::OpRemoveElements, remTb );
4343 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4344 createTool( SMESHOp::OpClearMesh, remTb );
4346 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4347 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4349 createTool( SMESHOp::OpTranslation, transformTb );
4350 createTool( SMESHOp::OpRotation, transformTb );
4351 createTool( SMESHOp::OpSymmetry, transformTb );
4352 createTool( SMESHOp::OpScale, transformTb );
4353 createTool( SMESHOp::OpSewing, transformTb );
4354 createTool( SMESHOp::OpMergeNodes, transformTb );
4355 createTool( SMESHOp::OpMergeElements, transformTb );
4356 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4358 createTool( SMESHOp::OpMoveNode, modifyTb );
4359 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4360 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4361 createTool( SMESHOp::OpOrientation, modifyTb );
4362 createTool( SMESHOp::OpReorientFaces, modifyTb );
4363 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4364 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4365 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4366 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4367 createTool( SMESHOp::OpSmoothing, modifyTb );
4368 createTool( SMESHOp::OpExtrusion, modifyTb );
4369 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4370 createTool( SMESHOp::OpRevolution, modifyTb );
4371 createTool( SMESHOp::OpPatternMapping, modifyTb );
4372 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4373 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4375 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4377 createTool( SMESHOp::OpUpdate, dispModeTb );
4379 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4380 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4384 OB = "'ObjectBrowser'",
4385 View = "'" + SVTK_Viewer::Type() + "'",
4387 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4388 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4389 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4390 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4391 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4392 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4393 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4394 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4395 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4396 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4397 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4398 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4400 mesh_part = mesh + " " + subMesh + " " + group,
4401 mesh_group = mesh + " " + group,
4402 mesh_submesh = mesh + " " + subMesh,
4403 hyp_alg = hypo + " " + algo;
4405 // popup for object browser
4407 isInvisible("not( isVisible )"),
4408 isEmpty("numberOfNodes = 0"),
4409 isNotEmpty("numberOfNodes <> 0"),
4411 // has nodes, edges, etc in VISIBLE! actor
4412 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4413 hasElems("(count( elemTypes ) > 0)"),
4414 hasDifferentElems("(count( elemTypes ) > 1)"),
4415 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4416 hasBalls("({'BallElem'} in elemTypes)"),
4417 hasElems0d("({'Elem0d'} in elemTypes)"),
4418 hasEdges("({'Edge'} in elemTypes)"),
4419 hasFaces("({'Face'} in elemTypes)"),
4420 hasVolumes("({'Volume'} in elemTypes)"),
4421 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4423 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4424 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4425 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4426 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4427 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4428 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4430 popupMgr()->insert( separator(), -1, 0 );
4431 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && isComputable" );
4432 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && isComputable" );
4433 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && isPreComputable" );
4434 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && isComputable" );
4435 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && isComputable && hasGeomReference" );
4436 createPopupItem( SMESHOp::OpUpdate, OB, mesh_part );
4437 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4438 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1" );
4439 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4440 popupMgr()->insert( separator(), -1, 0 );
4441 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4442 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4443 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4444 popupMgr()->insert( separator(), -1, 0 );
4445 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4446 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4447 popupMgr()->insert( separator(), -1, 0 );
4448 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh );
4449 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4450 popupMgr()->insert( separator(), -1, 0 );
4451 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4452 //popupMgr()->insert( separator(), -1, 0 );
4454 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4455 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4456 QString only_one_2D = only_one_non_empty + " && dim>1";
4458 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4459 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4460 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4461 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4463 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4465 createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
4466 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4467 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4468 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4469 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4471 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4472 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4473 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4474 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4476 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4478 createPopupItem( SMESHOp::OpPopupImportSAUV, OB, smesh, "", anId );
4479 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4480 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4481 popupMgr()->insert( separator(), -1, 0 );
4484 createPopupItem( SMESHOp::OpEditGroup, View, group );
4485 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4486 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4488 popupMgr()->insert( separator(), -1, 0 );
4489 createPopupItem( SMESHOp::OpUpdate, View, mesh_part );
4490 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4491 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4492 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
4493 popupMgr()->insert( separator(), -1, 0 );
4495 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4496 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4497 popupMgr()->insert( separator(), -1, 0 );
4499 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4500 QString aType = QString( "%1type in {%2}" ).arg( lc );
4501 aType = aType.arg( mesh_part );
4502 QString aMeshInVTK = aClient + "&&" + aType;
4504 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4505 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4506 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4508 //-------------------------------------------------
4510 //-------------------------------------------------
4511 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4513 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4514 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4515 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4517 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4518 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4519 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4521 popupMgr()->insert( separator(), -1, -1 );
4523 //-------------------------------------------------
4525 //-------------------------------------------------
4526 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4528 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4529 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4530 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4532 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4533 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4534 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4536 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4537 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4538 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4540 popupMgr()->insert( separator(), anId, -1 );
4542 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4543 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4544 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4546 //-------------------------------------------------
4548 //-------------------------------------------------
4549 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4551 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4553 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4554 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4555 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4557 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4558 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4559 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4561 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4562 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4563 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4565 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4566 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4567 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4569 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4570 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4571 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4573 popupMgr()->insert( separator(), anId, -1 );
4575 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4576 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4578 popupMgr()->insert( separator(), anId, -1 );
4580 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4581 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4584 //-------------------------------------------------
4585 // Representation of the 2D Quadratic elements
4586 //-------------------------------------------------
4587 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4588 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4589 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4590 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4592 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4593 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4594 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4596 //-------------------------------------------------
4597 // Orientation of faces
4598 //-------------------------------------------------
4599 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4600 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4601 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4603 //-------------------------------------------------
4605 //-------------------------------------------------
4606 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4607 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4609 //-------------------------------------------------
4611 //-------------------------------------------------
4612 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4613 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4615 //-------------------------------------------------
4617 //-------------------------------------------------
4619 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4620 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4621 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4622 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4624 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4626 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4627 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4629 popupMgr()->insert( separator(), anId, -1 );
4631 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4633 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4634 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4635 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4637 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4638 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4639 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4641 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4642 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4643 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4645 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4647 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4648 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4649 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4651 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4652 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4653 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4655 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4656 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4657 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4658 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4659 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4660 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4662 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4664 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4665 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4666 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4668 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4669 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4670 QtxPopupMgr::VisibleRule );
4671 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4673 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4674 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4675 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4677 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4678 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4679 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4681 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4682 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4683 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4685 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4686 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4687 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4689 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4690 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4691 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4693 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4694 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4695 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4697 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4698 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4699 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4701 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4702 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4703 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4705 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4706 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4707 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4709 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4710 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4711 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4713 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4714 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4715 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4716 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4717 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4718 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4720 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4722 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4723 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4724 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4726 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4727 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4728 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4730 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4731 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4732 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4734 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
4735 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4736 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4738 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
4739 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4740 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4742 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
4743 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4744 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4746 popupMgr()->insert( separator(), anId, -1 );
4748 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
4749 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4750 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
4751 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
4752 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4754 popupMgr()->insert( separator(), anId, -1 );
4756 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4758 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
4759 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4761 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
4762 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4763 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
4765 #ifndef DISABLE_PLOT2DVIEWER
4766 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
4767 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4770 //-------------------------------------------------
4772 //-------------------------------------------------
4773 popupMgr()->insert( separator(), -1, -1 );
4774 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4775 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4776 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
4777 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4779 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
4780 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4782 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
4783 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4785 popupMgr()->insert( separator(), -1, -1 );
4787 //-------------------------------------------------
4789 //-------------------------------------------------
4790 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
4791 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4793 popupMgr()->insert( separator(), -1, -1 );
4795 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
4796 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4797 popupMgr()->insert( separator(), -1, -1 );
4799 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4800 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4802 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4803 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4806 //================================================================================
4808 * \brief Return true if SMESH or GEOM objects are selected.
4809 * Is called form LightApp_Module::activateModule() which clear selection if
4810 * not isSelectionCompatible()
4812 //================================================================================
4814 bool SMESHGUI::isSelectionCompatible()
4816 bool isCompatible = true;
4817 SALOME_ListIO selected;
4818 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4819 Sel->selectedObjects( selected );
4821 SALOME_ListIteratorOfListIO It( selected );
4822 for ( ; isCompatible && It.More(); It.Next())
4824 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4825 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4827 return isCompatible;
4831 bool SMESHGUI::reusableOperation( const int id )
4833 // compute, evaluate and precompute are not reusable operations
4834 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
4837 bool SMESHGUI::activateModule( SUIT_Study* study )
4839 bool res = SalomeApp_Module::activateModule( study );
4841 setMenuShown( true );
4842 setToolShown( true );
4844 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4845 PyGILState_STATE gstate = PyGILState_Ensure();
4846 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4847 if ( !pluginsmanager ) {
4851 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
4856 PyGILState_Release(gstate);
4857 // end of SMESH plugins loading
4859 // Reset actions accelerator keys
4860 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
4862 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4863 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4864 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study )) {
4865 if ( _PTR(Study) aStudy = s->studyDS() )
4866 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4869 // get all view currently opened in the study and connect their signals to
4870 // the corresponding slots of the class.
4871 SUIT_Desktop* aDesk = study->application()->desktop();
4873 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4874 SUIT_ViewWindow* wnd;
4875 foreach ( wnd, wndList )
4879 Py_XDECREF(pluginsmanager);
4883 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4885 setMenuShown( false );
4886 setToolShown( false );
4888 EmitSignalCloseAllDialogs();
4890 // Unset actions accelerator keys
4891 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
4893 return SalomeApp_Module::deactivateModule( study );
4896 void SMESHGUI::studyClosed( SUIT_Study* s )
4900 SMESH::RemoveVisuData( s->id() );
4901 SalomeApp_Module::studyClosed( s );
4904 void SMESHGUI::OnGUIEvent()
4906 const QObject* obj = sender();
4907 if ( !obj || !obj->inherits( "QAction" ) )
4909 int id = actionId((QAction*)obj);
4914 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4916 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4917 if ( CORBA::is_nil( myComponentSMESH ) )
4919 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4921 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4922 return aGUI.myComponentSMESH;
4925 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4926 return myComponentSMESH;
4929 QString SMESHGUI::engineIOR() const
4931 CORBA::ORB_var anORB = getApp()->orb();
4932 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4933 return QString( anIOR.in() );
4936 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4938 SalomeApp_Module::contextMenuPopup( client, menu, title );
4940 selectionMgr()->selectedObjects( lst );
4941 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4942 Handle(SALOME_InteractiveObject) io = lst.First();
4943 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4944 _PTR(Study) study = appStudy->studyDS();
4945 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4947 QString aName = QString( SMESH::fromUtf8(obj->GetName()) );
4948 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4949 aName.remove( (aName.length() - 1), 1 );
4955 LightApp_Selection* SMESHGUI::createSelection() const
4957 return new SMESHGUI_Selection();
4960 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4962 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4963 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
4964 #ifndef DISABLE_PYCONSOLE
4965 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4969 void SMESHGUI::viewManagers( QStringList& list ) const
4971 list.append( SVTK_Viewer::Type() );
4974 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4976 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4977 SMESH::UpdateSelectionProp( this );
4979 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4980 for(int i = 0; i < aViews.count() ; i++){
4981 SUIT_ViewWindow *sf = aViews[i];
4984 EmitSignalActivatedViewManager();
4988 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4990 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4991 myClippingPlaneInfoMap.erase( theViewManager );
4994 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4996 theActor->AddObserver( SMESH::DeleteActorEvent,
4997 myEventCallbackCommand.GetPointer(),
5001 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5002 unsigned long theEvent,
5003 void* theClientData,
5006 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5007 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5008 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5009 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5010 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5011 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5012 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5013 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5014 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5015 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5016 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5017 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5018 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5019 if( anActor == *anIter3 ) {
5020 anActorList.erase( anIter3 );
5031 void SMESHGUI::createPreferences()
5033 // General tab ------------------------------------------------------------------------
5034 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5036 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5037 setPreferenceProperty( autoUpdate, "columns", 2 );
5038 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5039 setPreferenceProperty( lim, "min", 0 );
5040 setPreferenceProperty( lim, "max", 100000000 );
5041 setPreferenceProperty( lim, "step", 1000 );
5042 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5043 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5045 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5046 setPreferenceProperty( dispgroup, "columns", 2 );
5047 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5049 modes.append( tr("MEN_WIRE") );
5050 modes.append( tr("MEN_SHADE") );
5051 modes.append( tr("MEN_NODES") );
5052 modes.append( tr("MEN_SHRINK") );
5053 QList<QVariant> indices;
5054 indices.append( 0 );
5055 indices.append( 1 );
5056 indices.append( 2 );
5057 indices.append( 3 );
5058 setPreferenceProperty( dispmode, "strings", modes );
5059 setPreferenceProperty( dispmode, "indexes", indices );
5061 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5062 setPreferenceProperty( arcgroup, "columns", 2 );
5063 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5064 QStringList quadraticModes;
5065 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5066 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5068 indices.append( 0 );
5069 indices.append( 1 );
5070 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5071 setPreferenceProperty( quadraticmode, "indexes", indices );
5073 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5074 "SMESH", "max_angle" );
5075 setPreferenceProperty( maxAngle, "min", 1 );
5076 setPreferenceProperty( maxAngle, "max", 90 );
5078 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5079 setPreferenceProperty( qaGroup, "columns", 2 );
5080 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5081 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5082 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5083 setPreferenceProperty( prec, "min", 0 );
5084 setPreferenceProperty( prec, "max", 100 );
5085 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5086 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5087 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5088 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5089 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5092 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5093 setPreferenceProperty( exportgroup, "columns", 2 );
5094 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5095 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5096 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5098 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5099 setPreferenceProperty( computeGroup, "columns", 2 );
5100 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5102 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5103 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5104 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5106 indices.append( 0 );
5107 indices.append( 1 );
5108 indices.append( 2 );
5109 setPreferenceProperty( notifyMode, "strings", modes );
5110 setPreferenceProperty( notifyMode, "indexes", indices );
5112 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5113 setPreferenceProperty( infoGroup, "columns", 2 );
5114 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5116 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5117 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5119 indices.append( 0 );
5120 indices.append( 1 );
5121 setPreferenceProperty( elemInfo, "strings", modes );
5122 setPreferenceProperty( elemInfo, "indexes", indices );
5123 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5124 setPreferenceProperty( nodesLim, "min", 0 );
5125 setPreferenceProperty( nodesLim, "max", 10000000 );
5126 setPreferenceProperty( nodesLim, "step", 10000 );
5127 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5128 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5129 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5130 setPreferenceProperty( ctrlLim, "min", 0 );
5131 setPreferenceProperty( ctrlLim, "max", 10000000 );
5132 setPreferenceProperty( ctrlLim, "step", 1000 );
5133 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5134 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5135 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5136 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5137 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5139 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5140 setPreferenceProperty( segGroup, "columns", 2 );
5141 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5142 "SMESH", "segmentation" );
5143 setPreferenceProperty( segLen, "min", 1 );
5144 setPreferenceProperty( segLen, "max", 10000000 );
5145 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5146 "SMESH", "nb_segments_per_edge" );
5147 setPreferenceProperty( nbSeg, "min", 1 );
5148 setPreferenceProperty( nbSeg, "max", 10000000 );
5150 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5151 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5152 "SMESH", "forget_mesh_on_hyp_modif" );
5155 // Quantities with individual precision settings
5156 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5157 setPreferenceProperty( precGroup, "columns", 2 );
5159 const int nbQuantities = 6;
5160 int precs[nbQuantities], ii = 0;
5161 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5162 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5163 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5164 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5165 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5166 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5167 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5168 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5169 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5170 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5171 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5172 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5174 // Set property for precision value for spinboxes
5175 for ( ii = 0; ii < nbQuantities; ii++ ){
5176 setPreferenceProperty( precs[ii], "min", -14 );
5177 setPreferenceProperty( precs[ii], "max", 14 );
5178 setPreferenceProperty( precs[ii], "precision", 2 );
5181 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5182 setPreferenceProperty( previewGroup, "columns", 2 );
5183 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5184 setPreferenceProperty( chunkSize, "min", 1 );
5185 setPreferenceProperty( chunkSize, "max", 1000 );
5186 setPreferenceProperty( chunkSize, "step", 50 );
5188 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5189 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5191 // Mesh tab ------------------------------------------------------------------------
5192 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5193 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5194 setPreferenceProperty( nodeGroup, "columns", 3 );
5196 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5198 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5200 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5201 QList<QVariant> aMarkerTypeIndicesList;
5202 QList<QVariant> aMarkerTypeIconsList;
5203 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5204 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5205 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5206 aMarkerTypeIndicesList << i;
5207 aMarkerTypeIconsList << pixmap;
5209 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5210 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5212 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5214 QList<QVariant> aMarkerScaleIndicesList;
5215 QStringList aMarkerScaleValuesList;
5216 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5217 aMarkerScaleIndicesList << i;
5218 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5219 aMarkerScaleValuesList << QString::number( i );
5221 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5222 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5224 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5225 //setPreferenceProperty( elemGroup, "columns", 2 );
5227 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5228 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5229 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5230 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5231 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5232 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5233 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5234 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5235 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5238 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5239 setPreferenceProperty( grpGroup, "columns", 2 );
5241 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5242 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5244 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5245 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5246 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5247 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5248 double ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5249 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5250 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5251 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5252 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5253 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5254 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5255 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5256 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5257 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5259 setPreferenceProperty( size0d, "min", 1 );
5260 setPreferenceProperty( size0d, "max", 10 );
5262 // setPreferenceProperty( ballSize, "min", 1 );
5263 // setPreferenceProperty( ballSize, "max", 10 );
5265 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5266 setPreferenceProperty( ballDiameter, "max", 1e9 );
5267 setPreferenceProperty( ballDiameter, "step", 0.1 );
5269 setPreferenceProperty( ballScale, "min", 1e-2 );
5270 setPreferenceProperty( ballScale, "max", 1e7 );
5271 setPreferenceProperty( ballScale, "step", 0.5 );
5273 setPreferenceProperty( elemW, "min", 1 );
5274 setPreferenceProperty( elemW, "max", 5 );
5276 setPreferenceProperty( outW, "min", 1 );
5277 setPreferenceProperty( outW, "max", 5 );
5279 setPreferenceProperty( shrink, "min", 0 );
5280 setPreferenceProperty( shrink, "max", 100 );
5282 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5283 setPreferenceProperty( numGroup, "columns", 2 );
5285 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5286 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5288 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5289 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5291 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5292 setPreferenceProperty( orientGroup, "columns", 1 );
5294 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5295 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5297 setPreferenceProperty( orientScale, "min", 0.05 );
5298 setPreferenceProperty( orientScale, "max", 0.5 );
5299 setPreferenceProperty( orientScale, "step", 0.05 );
5301 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5303 // Selection tab ------------------------------------------------------------------------
5304 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5306 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5307 setPreferenceProperty( selGroup, "columns", 2 );
5309 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5310 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5312 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5313 setPreferenceProperty( preGroup, "columns", 2 );
5315 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5317 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5318 setPreferenceProperty( precSelGroup, "columns", 2 );
5320 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5321 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5322 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5324 // Scalar Bar tab ------------------------------------------------------------------------
5325 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5326 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5327 setPreferenceProperty( fontGr, "columns", 2 );
5329 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5330 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5332 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5333 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5335 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5336 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5338 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5339 setPreferenceProperty( numcol, "min", 2 );
5340 setPreferenceProperty( numcol, "max", 256 );
5342 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5343 setPreferenceProperty( numlab, "min", 2 );
5344 setPreferenceProperty( numlab, "max", 65 );
5346 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5347 setPreferenceProperty( orientGr, "columns", 2 );
5348 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5349 QStringList orients;
5350 orients.append( tr( "SMESH_VERTICAL" ) );
5351 orients.append( tr( "SMESH_HORIZONTAL" ) );
5352 indices.clear(); indices.append( 0 ); indices.append( 1 );
5353 setPreferenceProperty( orient, "strings", orients );
5354 setPreferenceProperty( orient, "indexes", indices );
5356 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5357 setPreferenceProperty( posVSizeGr, "columns", 2 );
5358 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5359 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5360 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5361 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5362 setPreferenceProperty( xv, "step", 0.1 );
5363 setPreferenceProperty( xv, "min", 0.0 );
5364 setPreferenceProperty( xv, "max", 1.0 );
5365 setPreferenceProperty( yv, "step", 0.1 );
5366 setPreferenceProperty( yv, "min", 0.0 );
5367 setPreferenceProperty( yv, "max", 1.0 );
5368 setPreferenceProperty( wv, "step", 0.1 );
5369 setPreferenceProperty( wv, "min", 0.0 );
5370 setPreferenceProperty( wv, "max", 1.0 );
5371 setPreferenceProperty( hv, "min", 0.0 );
5372 setPreferenceProperty( hv, "max", 1.0 );
5373 setPreferenceProperty( hv, "step", 0.1 );
5375 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5376 setPreferenceProperty( posHSizeGr, "columns", 2 );
5377 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5378 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5379 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5380 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5381 setPreferenceProperty( xv, "min", 0.0 );
5382 setPreferenceProperty( xv, "max", 1.0 );
5383 setPreferenceProperty( xv, "step", 0.1 );
5384 setPreferenceProperty( xh, "min", 0.0 );
5385 setPreferenceProperty( xh, "max", 1.0 );
5386 setPreferenceProperty( xh, "step", 0.1 );
5387 setPreferenceProperty( yh, "min", 0.0 );
5388 setPreferenceProperty( yh, "max", 1.0 );
5389 setPreferenceProperty( yh, "step", 0.1 );
5390 setPreferenceProperty( wh, "min", 0.0 );
5391 setPreferenceProperty( wh, "max", 1.0 );
5392 setPreferenceProperty( wh, "step", 0.1 );
5393 setPreferenceProperty( hh, "min", 0.0 );
5394 setPreferenceProperty( hh, "max", 1.0 );
5395 setPreferenceProperty( hh, "step", 0.1 );
5397 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5398 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5399 setPreferenceProperty( distributionGr, "columns", 3 );
5401 types.append( tr( "SMESH_MONOCOLOR" ) );
5402 types.append( tr( "SMESH_MULTICOLOR" ) );
5403 indices.clear(); indices.append( 0 ); indices.append( 1 );
5404 setPreferenceProperty( coloringType, "strings", types );
5405 setPreferenceProperty( coloringType, "indexes", indices );
5406 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5410 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5412 if ( sect=="SMESH" ) {
5413 float sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5414 float aTol = 1.00000009999999;
5415 std::string aWarning;
5416 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5418 if ( name== "selection_object_color" ||
5419 name=="selection_element_color" ||
5420 name== "highlight_color" ||
5421 name=="selection_precision_node" ||
5422 name=="selection_precision_element" ||
5423 name=="selection_precision_object" )
5425 SMESH::UpdateSelectionProp( this );
5427 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5429 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5430 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5431 if ( sbX1+sbW > aTol ) {
5432 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5435 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5436 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5439 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5441 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5442 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5443 if ( sbY1 + sbH > aTol ) {
5444 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5445 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5446 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5449 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5451 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5452 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5453 if ( sbX1 + sbW > aTol ) {
5454 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5457 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5458 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5461 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5463 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5464 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5465 if ( sbY1 + sbH > aTol ) {
5466 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5469 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5470 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5473 else if ( name == "segmentation" )
5475 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5476 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5478 else if ( name == "nb_segments_per_edge" )
5480 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5481 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5483 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5485 QString val = aResourceMgr->stringValue( "SMESH", name );
5486 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5488 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5490 SMESH::UpdateFontProp( this );
5492 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5494 SMESH::UpdateFontProp( this );
5497 if ( aWarning.size() != 0 ) {
5498 aWarning += "The default values are applied instead.";
5499 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5500 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5501 QObject::tr(aWarning.c_str()));
5506 //================================================================================
5508 * \brief Update something in accordance with update flags
5509 * \param theFlags - update flags
5511 * Update viewer or/and object browser etc. in accordance with update flags ( see
5512 * LightApp_UpdateFlags enumeration ).
5514 //================================================================================
5515 void SMESHGUI::update( const int flags )
5517 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5518 SMESH::UpdateView();
5520 SalomeApp_Module::update( flags );
5523 //================================================================================
5525 * \brief Set default selection mode
5527 * SLOT called when operation committed. Sets default selection mode
5529 //================================================================================
5530 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5532 SVTK_ViewWindow* vtkWnd =
5533 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5535 vtkWnd->SetSelectionMode( ActorSelection );
5538 //================================================================================
5540 * \brief Set default selection mode
5542 * SLOT called when operation aborted. Sets default selection mode
5544 //================================================================================
5545 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5547 SVTK_ViewWindow* vtkWnd =
5548 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5550 vtkWnd->SetSelectionMode( ActorSelection );
5553 //================================================================================
5555 * \brief Creates operation with given identifier
5556 * \param id - identifier of operation to be started
5557 * \return Pointer on created operation or NULL if operation is not created
5559 * Virtual method redefined from the base class creates operation with given id.
5560 * It is called called automatically from startOperation method of base class.
5562 //================================================================================
5563 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5565 LightApp_Operation* op = 0;
5566 // to do : create operation here
5569 case SMESHOp::OpSplitBiQuadratic:
5570 op = new SMESHGUI_SplitBiQuadOp();
5572 case SMESHOp::OpConvertMeshToQuadratic:
5573 op = new SMESHGUI_ConvToQuadOp();
5575 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5576 op = new SMESHGUI_Make2DFrom3DOp();
5578 case SMESHOp::OpReorientFaces:
5579 op = new SMESHGUI_ReorientFacesOp();
5581 case SMESHOp::OpCreateMesh:
5582 op = new SMESHGUI_MeshOp( true, true );
5584 case SMESHOp::OpCreateSubMesh:
5585 op = new SMESHGUI_MeshOp( true, false );
5587 case SMESHOp::OpEditMeshOrSubMesh:
5588 case SMESHOp::OpEditMesh:
5589 case SMESHOp::OpEditSubMesh:
5590 op = new SMESHGUI_MeshOp( false );
5592 case SMESHOp::OpCompute:
5593 case SMESHOp::OpComputeSubMesh:
5594 op = new SMESHGUI_ComputeOp();
5596 case SMESHOp::OpPreCompute:
5597 op = new SMESHGUI_PrecomputeOp();
5599 case SMESHOp::OpEvaluate:
5600 op = new SMESHGUI_EvaluateOp();
5602 case SMESHOp::OpMeshOrder:
5603 op = new SMESHGUI_MeshOrderOp();
5605 case SMESHOp::OpCreateGeometryGroup:
5606 op = new SMESHGUI_GroupOnShapeOp();
5608 case SMESHOp::OpFindElementByPoint:
5609 op = new SMESHGUI_FindElemByPointOp();
5611 case SMESHOp::OpMoveNode: // Make mesh pass through point
5612 op = new SMESHGUI_MakeNodeAtPointOp();
5614 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5615 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5622 op = SalomeApp_Module::createOperation( id );
5626 //================================================================================
5628 * \brief Stops current operations and starts a given one
5629 * \param id - The id of the operation to start
5631 //================================================================================
5633 void SMESHGUI::switchToOperation(int id)
5635 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5636 activeStudy()->abortAllOperations();
5637 startOperation( id );
5640 LightApp_Displayer* SMESHGUI::displayer()
5643 myDisplayer = new SMESHGUI_Displayer( getApp() );
5647 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5650 int aTolerance = 64;
5651 int anIterations = 0;
5657 if( anIterations % aPeriod == 0 )
5660 if( aTolerance < 1 )
5664 aHue = (int)( 360.0 * rand() / RAND_MAX );
5667 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5668 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5669 for( ; it != itEnd; ++it )
5671 SALOMEDS::Color anAutoColor = *it;
5672 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5675 aQColor.getHsv( &h, &s, &v );
5676 if( abs( h - aHue ) < aTolerance )
5688 aColor.setHsv( aHue, 255, 255 );
5690 SALOMEDS::Color aSColor;
5691 aSColor.R = aColor.redF();
5692 aSColor.G = aColor.greenF();
5693 aSColor.B = aColor.blueF();
5698 const char* gSeparator = "_"; // character used to separate parameter names
5699 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5700 const char* gPathSep = "|"; // character used to separate paths
5703 * \brief Store visual parameters
5705 * This method is called just before the study document is saved.
5706 * Store visual parameters in AttributeParameter attribue(s)
5708 void SMESHGUI::storeVisualParameters (int savePoint)
5711 Kernel_Utils::Localizer loc;
5713 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5714 if (!appStudy || !appStudy->studyDS())
5716 _PTR(Study) studyDS = appStudy->studyDS();
5718 // componentName is used for encoding of entries when storing them in IParameters
5719 std::string componentName = myComponentSMESH->ComponentDataType();
5720 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5721 //if (!aSComponent) return;
5724 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5725 componentName.c_str(),
5727 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5729 // store map of custom markers
5730 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5731 if( !aMarkerMap.empty() )
5733 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5734 for( ; anIter != aMarkerMap.end(); anIter++ )
5736 int anId = anIter->first;
5737 VTK::MarkerData aMarkerData = anIter->second;
5738 std::string aMarkerFileName = aMarkerData.first;
5739 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5740 if( aMarkerTexture.size() < 3 )
5741 continue; // should contain at least width, height and the first value
5743 QString aPropertyName( "texture" );
5744 aPropertyName += gSeparator;
5745 aPropertyName += QString::number( anId );
5747 QString aPropertyValue = aMarkerFileName.c_str();
5748 aPropertyValue += gPathSep;
5750 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5751 ushort aWidth = *aTextureIter++;
5752 ushort aHeight = *aTextureIter++;
5753 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5754 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5755 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5756 aPropertyValue += QString::number( *aTextureIter );
5758 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5762 // viewers counters are used for storing view_numbers in IParameters
5765 // main cycle to store parameters of displayed objects
5766 QList<SUIT_ViewManager*> lst;
5767 QList<SUIT_ViewManager*>::Iterator it;
5768 getApp()->viewManagers(lst);
5769 for (it = lst.begin(); it != lst.end(); it++)
5771 SUIT_ViewManager* vman = *it;
5772 QString vType = vman->getType();
5774 // saving VTK actors properties
5775 if (vType == SVTK_Viewer::Type())
5777 // store the clipping planes attached to the view manager
5778 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5779 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5780 if( anIter != myClippingPlaneInfoMap.end() )
5781 aClippingPlaneInfoList = anIter->second;
5783 if( !aClippingPlaneInfoList.empty() ) {
5784 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5785 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5787 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5788 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5790 QString aPropertyName( "ClippingPlane" );
5791 aPropertyName += gSeparator;
5792 aPropertyName += QString::number( vtkViewers );
5793 aPropertyName += gSeparator;
5794 aPropertyName += QString::number( anId );
5796 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5797 aPropertyValue += gDigitsSep;
5798 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5799 aPropertyValue += gDigitsSep;
5800 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5801 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5802 aPropertyValue += gDigitsSep;
5803 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5804 aPropertyValue += gDigitsSep;
5805 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5806 aPropertyValue += gDigitsSep;
5807 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5808 aPropertyValue += gDigitsSep;
5809 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5810 aPropertyValue += gDigitsSep;
5811 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5812 aPropertyValue += gDigitsSep;
5813 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5815 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5816 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5817 aPropertyValue += gDigitsSep;
5818 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5819 aPropertyValue += gDigitsSep;
5820 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5821 aPropertyValue += gDigitsSep;
5822 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5825 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5829 QVector<SUIT_ViewWindow*> views = vman->getViews();
5830 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5832 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5834 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5835 vtkActorCollection* allActors = aCopy.GetActors();
5836 allActors->InitTraversal();
5837 while (vtkActor* actor = allActors->GetNextActor())
5839 if (actor->GetVisibility()) // store only visible actors
5841 SMESH_Actor* aSmeshActor = 0;
5842 if (actor->IsA("SMESH_Actor"))
5843 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5844 if (aSmeshActor && aSmeshActor->hasIO())
5846 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5849 // entry is "encoded" = it does NOT contain component address,
5850 // since it is a subject to change on next component loading
5851 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5853 std::string param, vtkParam = vType.toLatin1().data();
5854 vtkParam += gSeparator;
5855 vtkParam += QString::number(vtkViewers).toLatin1().data();
5856 vtkParam += gSeparator;
5859 param = vtkParam + "Visibility";
5860 ip->setParameter(entry, param, "On");
5863 param = vtkParam + "Representation";
5864 ip->setParameter(entry, param, QString::number
5865 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5868 param = vtkParam + "IsShrunk";
5869 ip->setParameter(entry, param, QString::number
5870 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5872 // Displayed entities
5873 unsigned int aMode = aSmeshActor->GetEntityMode();
5874 bool isE = aMode & SMESH_Actor::eEdges;
5875 bool isF = aMode & SMESH_Actor::eFaces;
5876 bool isV = aMode & SMESH_Actor::eVolumes;
5877 bool is0d = aMode & SMESH_Actor::e0DElements;
5878 bool isB = aMode & SMESH_Actor::eBallElem;
5880 QString modeStr ("e");
5881 modeStr += gDigitsSep; modeStr += QString::number(isE);
5882 modeStr += gDigitsSep; modeStr += "f";
5883 modeStr += gDigitsSep; modeStr += QString::number(isF);
5884 modeStr += gDigitsSep; modeStr += "v";
5885 modeStr += gDigitsSep; modeStr += QString::number(isV);
5886 modeStr += gDigitsSep; modeStr += "0d";
5887 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5888 modeStr += gDigitsSep; modeStr += "b";
5889 modeStr += gDigitsSep; modeStr += QString::number(isB);
5891 param = vtkParam + "Entities";
5892 ip->setParameter(entry, param, modeStr.toLatin1().data());
5898 aSmeshActor->GetSufaceColor(r, g, b, delta);
5899 QStringList colorStr;
5900 colorStr << "surface";
5901 colorStr << QString::number(r);
5902 colorStr << QString::number(g);
5903 colorStr << QString::number(b);
5905 colorStr << "backsurface";
5906 colorStr << QString::number(delta);
5908 aSmeshActor->GetVolumeColor(r, g, b, delta);
5909 colorStr << "volume";
5910 colorStr << QString::number(r);
5911 colorStr << QString::number(g);
5912 colorStr << QString::number(b);
5913 colorStr << QString::number(delta);
5915 aSmeshActor->GetEdgeColor(r, g, b);
5917 colorStr << QString::number(r);
5918 colorStr << QString::number(g);
5919 colorStr << QString::number(b);
5921 aSmeshActor->GetNodeColor(r, g, b);
5923 colorStr << QString::number(r);
5924 colorStr << QString::number(g);
5925 colorStr << QString::number(b);
5927 aSmeshActor->GetOutlineColor(r, g, b);
5928 colorStr << "outline";
5929 colorStr << QString::number(r);
5930 colorStr << QString::number(g);
5931 colorStr << QString::number(b);
5933 aSmeshActor->Get0DColor(r, g, b);
5934 colorStr << "elem0d";
5935 colorStr << QString::number(r);
5936 colorStr << QString::number(g);
5937 colorStr << QString::number(b);
5939 aSmeshActor->GetBallColor(r, g, b);
5941 colorStr << QString::number(r);
5942 colorStr << QString::number(g);
5943 colorStr << QString::number(b);
5945 aSmeshActor->GetFacesOrientationColor(r, g, b);
5946 colorStr << "orientation";
5947 colorStr << QString::number(r);
5948 colorStr << QString::number(g);
5949 colorStr << QString::number(b);
5951 param = vtkParam + "Colors";
5952 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5955 QStringList sizeStr;
5957 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5958 sizeStr << "outline";
5959 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5960 sizeStr << "elem0d";
5961 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5963 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5964 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
5965 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
5966 sizeStr << "shrink";
5967 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5968 sizeStr << "orientation";
5969 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5970 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5972 param = vtkParam + "Sizes";
5973 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5978 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5979 if( aMarkerType == VTK::MT_USER ) {
5980 markerStr += "custom";
5981 markerStr += gDigitsSep;
5982 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5986 markerStr += gDigitsSep;
5987 markerStr += QString::number( (int)aMarkerType );
5988 markerStr += gDigitsSep;
5989 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5992 param = vtkParam + "PointMarker";
5993 ip->setParameter(entry, param, markerStr.toLatin1().data());
5996 param = vtkParam + "Opacity";
5997 ip->setParameter(entry, param,
5998 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6001 param = vtkParam + "ClippingPlane";
6003 if( !aClippingPlaneInfoList.empty() ) {
6004 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6005 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6007 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6008 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6009 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6010 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6011 if( aSmeshActor == *anIter2 ) {
6012 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6013 QString::number( anId ).toLatin1().constData() );
6020 ip->setParameter( entry, param, "Off" );
6021 } // if (io->hasEntry())
6022 } // SMESH_Actor && hasIO
6024 } // while.. actors traversal
6028 } // if (SVTK view model)
6029 } // for (viewManagers)
6032 // data structures for clipping planes processing
6036 bool isOpenGLClipping;
6037 vtkIdType RelativeOrientation;
6040 int AbsoluteOrientation;
6041 double X, Y, Z, Dx, Dy, Dz;
6043 typedef std::list<TPlaneData> TPlaneDataList;
6044 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6046 typedef std::list<vtkActor*> TActorList;
6049 TActorList ActorList;
6050 SUIT_ViewManager* ViewManager;
6052 typedef std::list<TPlaneInfo> TPlaneInfoList;
6053 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6056 * \brief Restore visual parameters
6058 * This method is called after the study document is opened.
6059 * Restore visual parameters from AttributeParameter attribue(s)
6061 void SMESHGUI::restoreVisualParameters (int savePoint)
6064 Kernel_Utils::Localizer loc;
6066 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6067 if (!appStudy || !appStudy->studyDS())
6069 _PTR(Study) studyDS = appStudy->studyDS();
6071 // componentName is used for encoding of entries when storing them in IParameters
6072 std::string componentName = myComponentSMESH->ComponentDataType();
6073 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
6074 //if (!aSComponent) return;
6077 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6078 componentName.c_str(),
6080 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6082 // restore map of custom markers and map of clipping planes
6083 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
6084 TPlaneDataMap aPlaneDataMap;
6086 std::vector<std::string> properties = ip->getProperties();
6087 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6089 std::string property = *propIt;
6090 QString aPropertyName( property.c_str() );
6091 QString aPropertyValue( ip->getProperty( property ).c_str() );
6093 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6094 if( aPropertyNameList.isEmpty() )
6097 QString aPropertyType = aPropertyNameList[0];
6098 if( aPropertyType == "texture" )
6100 if( aPropertyNameList.size() != 2 )
6104 int anId = aPropertyNameList[1].toInt( &ok );
6105 if( !ok || anId < 1 )
6108 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6109 if( aPropertyValueList.size() != 2 )
6112 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6113 QString aMarkerTextureString = aPropertyValueList[1];
6114 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6115 if( aMarkerTextureStringList.size() != 3 )
6119 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6124 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6128 VTK::MarkerTexture aMarkerTexture;
6129 aMarkerTexture.push_back( aWidth );
6130 aMarkerTexture.push_back( aHeight );
6132 QString aMarkerTextureData = aMarkerTextureStringList[2];
6133 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6135 QChar aChar = aMarkerTextureData.at( i );
6136 if( aChar.isDigit() )
6137 aMarkerTexture.push_back( aChar.digitValue() );
6140 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6142 else if( aPropertyType == "ClippingPlane" )
6144 if( aPropertyNameList.size() != 3 )
6148 int aViewId = aPropertyNameList[1].toInt( &ok );
6149 if( !ok || aViewId < 0 )
6153 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6154 if( !ok || aClippingPlaneId < 0 )
6157 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6158 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6161 TPlaneData aPlaneData;
6162 aPlaneData.AbsoluteOrientation = false;
6163 aPlaneData.RelativeOrientation = 0;
6164 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6165 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6166 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6168 aPlaneData.Id = aClippingPlaneId;
6171 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6176 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6180 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6183 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6188 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6193 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6198 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6203 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6208 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6213 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6217 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6219 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6224 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6229 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6234 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6239 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6240 aPlaneDataList.push_back( aPlaneData );
6244 TPlaneInfoMap aPlaneInfoMap;
6246 std::vector<std::string> entries = ip->getEntries();
6248 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6250 // entry is a normal entry - it should be "decoded" (setting base address of component)
6251 QString entry (ip->decodeEntry(*entIt).c_str());
6253 // Check that the entry corresponds to a real object in the Study
6254 // as the object may be deleted or modified after the visual state is saved.
6255 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6256 if (!so) continue; //Skip the not existent entry
6258 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6259 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6261 std::vector<std::string>::iterator namesIt = paramNames.begin();
6262 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6264 // actors are stored in a map after displaying of them for
6265 // quicker access in the future: map < viewID to actor >
6266 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6268 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6270 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6271 // '_' is used as separator and should not be used in viewer type or parameter names.
6272 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6273 if (lst.size() != 3)
6276 QString viewerTypStr = lst[0];
6277 QString viewIndexStr = lst[1];
6278 QString paramNameStr = lst[2];
6281 int viewIndex = viewIndexStr.toUInt(&ok);
6282 if (!ok) // bad conversion of view index to integer
6286 if (viewerTypStr == SVTK_Viewer::Type())
6288 SMESH_Actor* aSmeshActor = 0;
6289 if (vtkActors.IsBound(viewIndex))
6290 aSmeshActor = vtkActors.Find(viewIndex);
6292 QList<SUIT_ViewManager*> lst;
6293 getApp()->viewManagers(viewerTypStr, lst);
6295 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6296 SUIT_ViewManager* vman = NULL;
6297 if (viewIndex >= 0 && viewIndex < lst.count())
6298 vman = lst.at(viewIndex);
6300 if (paramNameStr == "Visibility")
6302 if (!aSmeshActor && displayer() && vman)
6304 SUIT_ViewModel* vmodel = vman->getViewModel();
6305 // SVTK view model can be casted to SALOME_View
6306 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6308 // store displayed actor in a temporary map for quicker
6309 // access later when restoring other parameters
6310 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6311 vtkRenderer* Renderer = vtkView->getRenderer();
6312 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6313 vtkActorCollection* theActors = aCopy.GetActors();
6314 theActors->InitTraversal();
6315 bool isFound = false;
6316 vtkActor *ac = theActors->GetNextActor();
6317 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6318 if (ac->IsA("SMESH_Actor")) {
6319 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6320 if (aGeomAc->hasIO()) {
6321 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6322 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6324 vtkActors.Bind(viewIndex, aGeomAc);
6330 } // if (paramNameStr == "Visibility")
6333 // the rest properties "work" with SMESH_Actor
6336 QString val ((*valuesIt).c_str());
6339 if (paramNameStr == "Representation") {
6340 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6343 else if (paramNameStr == "IsShrunk") {
6345 if (!aSmeshActor->IsShrunk())
6346 aSmeshActor->SetShrink();
6349 if (aSmeshActor->IsShrunk())
6350 aSmeshActor->UnShrink();
6353 // Displayed entities
6354 else if (paramNameStr == "Entities") {
6355 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6356 int aEntityMode = SMESH_Actor::eAllEntity;
6357 for ( int i = 0; i < mode.count(); i+=2 ) {
6358 if ( i < mode.count()-1 ) {
6359 QString type = mode[i];
6360 bool val = mode[i+1].toInt();
6361 if ( type == "e" && !val )
6362 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6363 else if ( type == "f" && !val )
6364 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6365 else if ( type == "v" && !val )
6366 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6367 else if ( type == "0d" && !val )
6368 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6369 else if ( type == "b" && !val )
6370 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6373 aSmeshActor->SetEntityMode( aEntityMode );
6376 else if (paramNameStr == "Colors") {
6377 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6384 QColor outlineColor;
6385 QColor orientationColor;
6391 // below lines are required to get default values for delta coefficients
6392 // of backface color for faces and color of reversed volumes
6393 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6394 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6395 for ( int i = 0; i < colors.count(); i++ ) {
6396 QString type = colors[i];
6397 if ( type == "surface" ) {
6398 // face color is set by 3 values r:g:b, where
6399 // - r,g,b - is rgb color components
6400 if ( i+1 >= colors.count() ) break; // format error
6401 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6402 if ( i+2 >= colors.count() ) break; // format error
6403 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6404 if ( i+3 >= colors.count() ) break; // format error
6405 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6406 faceColor.setRgbF( r, g, b );
6409 else if ( type == "backsurface" ) {
6410 // backface color can be defined in several ways
6411 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6412 // - in latest versions, it is set as delta coefficient
6413 bool rgbOk = false, deltaOk;
6414 if ( i+1 >= colors.count() ) break; // format error
6415 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6416 int delta = colors[i+1].toInt( &deltaOk );
6418 if ( i+1 < colors.count() ) // index is shifted to 1
6419 g = colors[i+1].toDouble( &rgbOk );
6420 if ( rgbOk ) i++; // shift index
6421 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6422 b = colors[i+1].toDouble( &rgbOk );
6424 // - as currently there's no way to set directly backsurface color as it was before,
6425 // we ignore old dump where r,g,b triple was set
6426 // - also we check that delta parameter is set properly
6427 if ( !rgbOk && deltaOk )
6430 else if ( type == "volume" ) {
6431 // volume color is set by 4 values r:g:b:delta, where
6432 // - r,g,b - is a normal volume rgb color components
6433 // - delta - is a reversed volume color delta coefficient
6434 if ( i+1 >= colors.count() ) break; // format error
6435 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6436 if ( i+2 >= colors.count() ) break; // format error
6437 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6438 if ( i+3 >= colors.count() ) break; // format error
6439 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6440 if ( i+4 >= colors.count() ) break; // format error
6441 int delta = colors[i+4].toInt( &bOk );
6442 if ( !bOk ) break; // format error
6443 volumeColor.setRgbF( r, g, b );
6447 else if ( type == "edge" ) {
6448 // edge color is set by 3 values r:g:b, where
6449 // - r,g,b - is rgb color components
6450 if ( i+1 >= colors.count() ) break; // format error
6451 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6452 if ( i+2 >= colors.count() ) break; // format error
6453 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6454 if ( i+3 >= colors.count() ) break; // format error
6455 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6456 edgeColor.setRgbF( r, g, b );
6459 else if ( type == "node" ) {
6460 // node color is set by 3 values r:g:b, where
6461 // - r,g,b - is rgb color components
6462 if ( i+1 >= colors.count() ) break; // format error
6463 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6464 if ( i+2 >= colors.count() ) break; // format error
6465 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6466 if ( i+3 >= colors.count() ) break; // format error
6467 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6468 nodeColor.setRgbF( r, g, b );
6471 else if ( type == "elem0d" ) {
6472 // 0d element color is set by 3 values r:g:b, where
6473 // - r,g,b - is rgb color components
6474 if ( i+1 >= colors.count() ) break; // format error
6475 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6476 if ( i+2 >= colors.count() ) break; // format error
6477 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6478 if ( i+3 >= colors.count() ) break; // format error
6479 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6480 elem0dColor.setRgbF( r, g, b );
6483 else if ( type == "ball" ) {
6484 // ball color is set by 3 values r:g:b, where
6485 // - r,g,b - is rgb color components
6486 if ( i+1 >= colors.count() ) break; // format error
6487 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6488 if ( i+2 >= colors.count() ) break; // format error
6489 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6490 if ( i+3 >= colors.count() ) break; // format error
6491 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6492 ballColor.setRgbF( r, g, b );
6495 else if ( type == "outline" ) {
6496 // outline color is set by 3 values r:g:b, where
6497 // - r,g,b - is rgb color components
6498 if ( i+1 >= colors.count() ) break; // format error
6499 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6500 if ( i+2 >= colors.count() ) break; // format error
6501 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6502 if ( i+3 >= colors.count() ) break; // format error
6503 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6504 outlineColor.setRgbF( r, g, b );
6507 else if ( type == "orientation" ) {
6508 // orientation color is set by 3 values r:g:b, where
6509 // - r,g,b - is rgb color components
6510 if ( i+1 >= colors.count() ) break; // format error
6511 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6512 if ( i+2 >= colors.count() ) break; // format error
6513 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6514 if ( i+3 >= colors.count() ) break; // format error
6515 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6516 orientationColor.setRgbF( r, g, b );
6521 if ( nodeColor.isValid() )
6522 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6524 if ( edgeColor.isValid() )
6525 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6527 if ( faceColor.isValid() )
6528 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6530 if ( volumeColor.isValid() )
6531 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6532 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6533 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6535 if ( elem0dColor.isValid() )
6536 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6538 if ( ballColor.isValid() )
6539 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6541 if ( outlineColor.isValid() )
6542 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6543 // orientation color
6544 if ( orientationColor.isValid() )
6545 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6548 else if (paramNameStr == "Sizes") {
6549 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6552 int outlineWidth = -1;
6553 int elem0dSize = -1;
6554 //int ballSize = -1;
6555 double ballDiameter = -1.0;
6556 double ballScale = -1.0;
6557 double shrinkSize = -1;
6558 double orientationSize = -1;
6559 bool orientation3d = false;
6560 for ( int i = 0; i < sizes.count(); i++ ) {
6561 QString type = sizes[i];
6562 if ( type == "line" ) {
6563 // line (wireframe) width is given as single integer value
6564 if ( i+1 >= sizes.count() ) break; // format error
6565 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6569 if ( type == "outline" ) {
6570 // outline width is given as single integer value
6571 if ( i+1 >= sizes.count() ) break; // format error
6572 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6576 else if ( type == "elem0d" ) {
6577 // 0d element size is given as single integer value
6578 if ( i+1 >= sizes.count() ) break; // format error
6579 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6583 else if ( type == "ball" ) {
6584 // balls are specified by two values: size:scale, where
6585 // - size - is a integer value specifying size
6586 // - scale - is a double value specifying scale factor
6587 if ( i+1 >= sizes.count() ) break; // format error
6588 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6589 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6590 if ( i+2 >= sizes.count() ) break; // format error
6591 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6597 else if ( type == "shrink" ) {
6598 // shrink factor is given as single floating point value
6599 if ( i+1 >= sizes.count() ) break; // format error
6600 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6604 else if ( type == "orientation" ) {
6605 // orientation vectors are specified by two values size:3d, where
6606 // - size - is a floating point value specifying scale factor
6607 // - 3d - is a boolean
6608 if ( i+1 >= sizes.count() ) break; // format error
6609 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6610 if ( i+2 >= sizes.count() ) break; // format error
6611 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6612 orientationSize = v1;
6613 orientation3d = (bool)v2;
6617 // line (wireframe) width
6618 if ( lineWidth > 0 )
6619 aSmeshActor->SetLineWidth( lineWidth );
6621 if ( outlineWidth > 0 )
6622 aSmeshActor->SetOutlineWidth( outlineWidth );
6623 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6624 aSmeshActor->SetOutlineWidth( lineWidth );
6626 if ( elem0dSize > 0 )
6627 aSmeshActor->Set0DSize( elem0dSize );
6629 /*if ( ballSize > 0 )
6630 aSmeshActor->SetBallSize( ballSize );*/
6632 if ( ballDiameter > 0 )
6633 aSmeshActor->SetBallSize( ballDiameter );
6635 if ( ballScale > 0.0 )
6636 aSmeshActor->SetBallScale( ballScale );
6638 if ( shrinkSize > 0 )
6639 aSmeshActor->SetShrinkFactor( shrinkSize );
6640 // orientation vectors
6641 if ( orientationSize > 0 ) {
6642 aSmeshActor->SetFacesOrientationScale( orientationSize );
6643 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6647 else if (paramNameStr == "PointMarker") {
6648 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6649 if( data.count() >= 2 ) {
6651 int aParam1 = data[1].toInt( &ok );
6653 if( data[0] == "std" && data.count() == 3 ) {
6654 int aParam2 = data[2].toInt( &ok );
6655 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6657 else if( data[0] == "custom" ) {
6658 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6659 if( markerIt != aMarkerMap.end() ) {
6660 VTK::MarkerData aMarkerData = markerIt->second;
6661 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6668 else if (paramNameStr == "Opacity") {
6669 aSmeshActor->SetOpacity(val.toFloat());
6672 else if (paramNameStr.startsWith("ClippingPlane")) {
6673 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6674 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6675 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6676 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6677 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6678 // new format - val looks like "Off" or "0" (plane id)
6679 // (note: in new format "Off" value is used only for consistency,
6680 // so it is processed together with values in old format)
6681 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6682 if( anIsOldFormat ) {
6683 if (paramNameStr == "ClippingPlane1" || val == "Off")
6684 aSmeshActor->RemoveAllClippingPlanes();
6686 QList<SUIT_ViewManager*> lst;
6687 getApp()->viewManagers(viewerTypStr, lst);
6688 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6689 if (viewIndex >= 0 && viewIndex < lst.count()) {
6690 SUIT_ViewManager* vman = lst.at(viewIndex);
6691 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6693 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6695 SMESH::TActorList anActorList;
6696 anActorList.push_back( aSmeshActor );
6697 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6698 aPlane->myViewWindow = vtkView;
6699 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6700 aPlane->PlaneMode = aMode;
6701 bool isOpenGLClipping = ( bool )vals[1].toInt();
6702 aPlane->IsOpenGLClipping = isOpenGLClipping;
6703 if ( aMode == SMESH::Absolute ) {
6704 aPlane->myAbsoluteOrientation = vals[2].toInt();
6705 aPlane->X = vals[3].toFloat();
6706 aPlane->Y = vals[4].toFloat();
6707 aPlane->Z = vals[5].toFloat();
6708 aPlane->Dx = vals[6].toFloat();
6709 aPlane->Dy = vals[7].toFloat();
6710 aPlane->Dz = vals[8].toFloat();
6712 else if ( aMode == SMESH::Relative ) {
6713 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6714 aPlane->myDistance = vals[3].toFloat();
6715 aPlane->myAngle[0] = vals[4].toFloat();
6716 aPlane->myAngle[1] = vals[5].toFloat();
6720 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6721 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6722 aClippingPlaneInfo.Plane = aPlane;
6723 aClippingPlaneInfo.ActorList = anActorList;
6724 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6732 int aPlaneId = val.toInt( &ok );
6733 if( ok && aPlaneId >= 0 ) {
6734 bool anIsDefinedPlane = false;
6735 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6736 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6737 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6738 TPlaneInfo& aPlaneInfo = *anIter;
6739 if( aPlaneInfo.PlaneId == aPlaneId ) {
6740 aPlaneInfo.ActorList.push_back( aSmeshActor );
6741 anIsDefinedPlane = true;
6745 if( !anIsDefinedPlane ) {
6746 TPlaneInfo aPlaneInfo;
6747 aPlaneInfo.PlaneId = aPlaneId;
6748 aPlaneInfo.ActorList.push_back( aSmeshActor );
6749 aPlaneInfo.ViewManager = vman;
6751 // to make the list sorted by plane id
6752 anIter = aPlaneInfoList.begin();
6753 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6754 const TPlaneInfo& aPlaneInfoRef = *anIter;
6755 if( aPlaneInfoRef.PlaneId > aPlaneId )
6758 aPlaneInfoList.insert( anIter, aPlaneInfo );
6763 } // if (aSmeshActor)
6764 } // other parameters than Visibility
6766 } // for names/parameters iterator
6767 } // for entries iterator
6769 // take into account planes with empty list of actors referred to them
6770 QList<SUIT_ViewManager*> aVMList;
6771 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6773 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6774 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6775 int aViewId = aPlaneDataIter->first;
6776 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6777 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6779 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6781 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6782 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6783 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6784 const TPlaneData& aPlaneData = *anIter2;
6785 int aPlaneId = aPlaneData.Id;
6787 bool anIsFound = false;
6788 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6789 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6790 const TPlaneInfo& aPlaneInfo = *anIter3;
6791 if( aPlaneInfo.PlaneId == aPlaneId ) {
6798 TPlaneInfo aPlaneInfo; // ActorList field is empty
6799 aPlaneInfo.PlaneId = aPlaneId;
6800 aPlaneInfo.ViewManager = aViewManager;
6802 // to make the list sorted by plane id
6803 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6804 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6805 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6806 if( aPlaneInfoRef.PlaneId > aPlaneId )
6809 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6815 // add clipping planes to actors according to the restored parameters
6816 // and update the clipping plane map
6817 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6818 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6819 int aViewId = anIter1->first;
6820 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6822 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6823 if( anIter2 == aPlaneDataMap.end() )
6825 const TPlaneDataList& aPlaneDataList = anIter2->second;
6827 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6828 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6829 const TPlaneInfo& aPlaneInfo = *anIter3;
6830 int aPlaneId = aPlaneInfo.PlaneId;
6831 const TActorList& anActorList = aPlaneInfo.ActorList;
6832 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6836 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6840 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6842 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6843 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6844 const TPlaneData& aPlaneData = *anIter4;
6845 if( aPlaneData.Id == aPlaneId ) {
6846 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6847 aPlane->myViewWindow = aViewWindow;
6848 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6849 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6850 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6851 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6852 aPlane->X = aPlaneData.X;
6853 aPlane->Y = aPlaneData.Y;
6854 aPlane->Z = aPlaneData.Z;
6855 aPlane->Dx = aPlaneData.Dx;
6856 aPlane->Dy = aPlaneData.Dy;
6857 aPlane->Dz = aPlaneData.Dz;
6859 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6860 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6861 aPlane->myDistance = aPlaneData.Distance;
6862 aPlane->myAngle[0] = aPlaneData.Angle[0];
6863 aPlane->myAngle[1] = aPlaneData.Angle[1];
6866 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6867 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6868 aClippingPlaneInfo.Plane = aPlane;
6869 aClippingPlaneInfo.ActorList = anActorList;
6870 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6881 // update all VTK views
6882 QList<SUIT_ViewManager*> lst;
6883 getApp()->viewManagers(lst);
6884 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6885 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6886 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6887 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6888 // set OpenGL clipping planes
6889 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6890 vtkActorCollection* anAllActors = aCopy.GetActors();
6891 anAllActors->InitTraversal();
6892 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6893 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6894 anActor->SetOpenGLClippingPlane();
6896 vtkView->getRenderer()->ResetCameraClippingRange();
6903 \brief Adds preferences for dfont of VTK viewer
6905 \param pIf group identifier
6906 \param param parameter
6907 \return identifier of preferences
6909 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6911 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6913 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6916 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6917 fam.append( tr( "SMESH_FONT_COURIER" ) );
6918 fam.append( tr( "SMESH_FONT_TIMES" ) );
6920 setPreferenceProperty( tfont, "fonts", fam );
6922 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6923 if ( needSize ) f = f | QtxFontEdit::Size;
6924 setPreferenceProperty( tfont, "features", f );
6930 \brief Actions after hypothesis edition
6931 Updates object browser after hypothesis edition
6933 void SMESHGUI::onHypothesisEdit( int result )
6936 SMESHGUI::Modified();
6937 updateObjBrowser( true );
6941 \brief Actions after choosing menu of control modes
6942 Updates control mode actions according to current selection
6944 void SMESHGUI::onUpdateControlActions()
6946 SALOME_ListIO selected;
6947 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
6948 aSel->selectedObjects( selected );
6950 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
6951 if ( selected.Extent() ) {
6952 if ( selected.First()->hasEntry() ) {
6953 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
6954 aControl = anActor->GetControlMode();
6955 SALOME_ListIteratorOfListIO it(selected);
6956 for ( it.Next(); it.More(); it.Next() ) {
6957 Handle(SALOME_InteractiveObject) anIO = it.Value();
6958 if ( anIO->hasEntry() ) {
6959 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
6960 if ( aControl != anActor->GetControlMode() ) {
6961 aControl = SMESH_Actor::eNone;
6971 int anAction = ActionToControl( aControl, true );
6973 action( anAction )->setChecked( true );
6975 QMenu* send = (QMenu*)sender();
6976 QList<QAction*> actions = send->actions();
6977 for ( int i = 0; i < actions.size(); i++ )
6978 actions[i]->setChecked( false );
6984 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6985 \param pview view being closed
6987 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6988 #ifndef DISABLE_PLOT2DVIEWER
6989 //Crear all Plot2d Viewers if need.
6990 SMESH::ClearPlot2Viewers(pview);
6992 EmitSignalCloseView();
6995 void SMESHGUI::message( const QString& msg )
6998 QStringList data = msg.split("/");
6999 if ( data.count() > 0 ) {
7000 if ( data.first() == "mesh_loading" ) {
7002 QString entry = data.count() > 1 ? data[1] : QString();
7003 if ( entry.isEmpty() )
7006 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7008 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
7011 name = SMESH::fromUtf8(obj->GetName());
7012 if ( name.isEmpty() )
7015 if ( data.last() == "stop" )
7016 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7018 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7019 QApplication::processEvents();
7025 \brief Connects or disconnects signals about activating and cloning view on the module slots
7026 \param pview view which is connected/disconnected
7028 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7032 SUIT_ViewManager* viewMgr = pview->getViewManager();
7034 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7035 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7037 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7038 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7043 \brief Return \c true if object can be renamed
7045 bool SMESHGUI::renameAllowed( const QString& entry) const {
7046 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7050 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7054 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7059 if(appStudy->isComponent(entry) || obj->isReference())
7062 // check type to prevent renaming of inappropriate objects
7063 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
7064 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7065 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7066 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7067 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7068 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7075 Rename object by entry.
7076 \param entry entry of the object
7077 \param name new name of the object
7078 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7080 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7082 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7086 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7091 _PTR(Study) aStudy = appStudy->studyDS();
7096 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7098 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7103 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7104 _PTR(GenericAttribute) anAttr;
7105 _PTR(AttributeName) aName;
7107 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7109 // check type to prevent renaming of inappropriate objects
7110 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
7111 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7112 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7113 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7114 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7115 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7116 if ( !name.isEmpty() ) {
7117 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
7119 // update name of group object and its actor
7120 Handle(SALOME_InteractiveObject) IObject =
7121 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7123 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7124 if( !aGroupObject->_is_nil() ) {
7125 aGroupObject->SetName( qPrintable(name) );
7126 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7127 anActor->setName( qPrintable(name) );
7137 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7139 static QList<QColor> colors;
7141 if ( colors.isEmpty() ) {
7143 for (int s = 0; s < 2 ; s++)
7145 for (int v = 100; v >= 40; v = v - 20)
7147 for (int h = 0; h < 359 ; h = h + 60)
7149 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7154 static int currentColor = randomize( colors.size() );
7156 SALOMEDS::Color color;
7157 color.R = (double)colors[currentColor].red() / 255.0;
7158 color.G = (double)colors[currentColor].green() / 255.0;
7159 color.B = (double)colors[currentColor].blue() / 255.0;
7161 currentColor = (currentColor+1) % colors.count();