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)
146 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
149 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
150 #include <QApplication>
152 #include <QTextStream>
157 #include <QDialogButtonBox>
160 #include <boost/shared_ptr.hpp>
163 #include <vtkCallbackCommand.h>
164 #include <vtkCamera.h>
165 #include <vtkLookupTable.h>
166 #include <vtkPlane.h>
167 #include <vtkRenderer.h>
169 // SALOME KERNEL includes
170 #include <SALOMEDSClient_ClientFactory.hxx>
171 #include <SALOMEDSClient_IParameters.hxx>
172 #include <SALOMEDSClient_SComponent.hxx>
173 #include <SALOMEDSClient_StudyBuilder.hxx>
174 #include <SALOMEDS_Study.hxx>
175 #include <SALOMEDS_SObject.hxx>
176 #include "utilities.h"
179 #include <Standard_ErrorHandler.hxx>
180 #include <NCollection_DataMap.hxx>
181 #include <NCollection_DoubleMap.hxx>
183 #include <Basics_Utils.hxx>
185 // Below macro, when uncommented, switches on simplified (more performant) algorithm
186 // of auto-color picking up
187 #define SIMPLE_AUTOCOLOR
192 //=============================================================
193 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
196 void ExportMeshToFile(int theCommandID);
198 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
200 void SetDisplayEntity(int theCommandID);
202 int ActionToControl( int theID, bool theReversed = false );
204 void Control( int theCommandID );
207 //================================================================================
209 * \brief Reads meshes from file
211 //================================================================================
213 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
217 std::string myExtension;
219 if ( theCommandID == SMESHOp::OpImportMED ||
220 theCommandID == SMESHOp::OpPopupImportMED ) {
221 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
222 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
224 else if ( theCommandID == SMESHOp::OpImportUNV ||
225 theCommandID == SMESHOp::OpPopupImportUNV ) {
226 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
228 else if ( theCommandID == SMESHOp::OpImportDAT ||
229 theCommandID == SMESHOp::OpPopupImportDAT ) {
230 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
232 else if ( theCommandID == SMESHOp::OpImportSTL ||
233 theCommandID == SMESHOp::OpPopupImportSTL ) {
234 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
236 else if ( theCommandID == SMESHOp::OpImportCGNS ||
237 theCommandID == SMESHOp::OpPopupImportCGNS ) {
238 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
240 else if ( theCommandID == SMESHOp::OpImportSAUV ||
241 theCommandID == SMESHOp::OpPopupImportSAUV ) {
242 filter.append( QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)" );
243 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
245 else if ( theCommandID == SMESHOp::OpImportGMF ||
246 theCommandID == SMESHOp::OpPopupImportGMF ) {
247 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
248 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
251 QString anInitialPath = "";
252 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
253 anInitialPath = QDir::currentPath();
255 QStringList filenames;
256 bool toCreateGroups = true;
258 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
259 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
260 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
261 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
262 // fd->setNameFilters( filter );
263 // fd->SetChecked( true );
265 // filenames << fd->selectedFile();
266 // toCreateGroups = fd->IsChecked();
272 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
275 QObject::tr( "SMESH_IMPORT_MESH" ) );
277 if ( filenames.count() > 0 )
279 SUIT_OverrideCursor wc;
280 _PTR(Study) aStudy = SMESH::getStudy();
283 QStringList anEntryList;
284 bool isEmpty = false;
285 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
287 QString filename = *it;
288 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
290 switch ( theCommandID ) {
291 case SMESHOp::OpImportDAT:
292 case SMESHOp::OpPopupImportDAT:
294 // DAT format (currently unsupported)
295 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
296 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
299 case SMESHOp::OpImportUNV:
300 case SMESHOp::OpPopupImportUNV:
303 aMeshes->length( 1 );
304 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
305 if ( aMeshes[0]->_is_nil() )
306 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
307 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
310 case SMESHOp::OpImportMED:
311 case SMESHOp::OpPopupImportMED:
314 SMESH::DriverMED_ReadStatus res;
315 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
316 if ( res != SMESH::DRS_OK ) {
317 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
318 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
322 case SMESHOp::OpImportSTL:
323 case SMESHOp::OpPopupImportSTL:
326 aMeshes->length( 1 );
327 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
328 if ( aMeshes[0]->_is_nil() ) {
329 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
330 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
334 case SMESHOp::OpImportCGNS:
335 case SMESHOp::OpPopupImportCGNS:
338 SMESH::DriverMED_ReadStatus res;
339 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
340 if ( res != SMESH::DRS_OK ) {
341 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
342 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
346 case SMESHOp::OpImportSAUV:
347 case SMESHOp::OpPopupImportSAUV:
350 SMESH::DriverMED_ReadStatus res;
351 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
352 if ( res != SMESH::DRS_OK ) {
353 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
354 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
358 case SMESHOp::OpImportGMF:
359 case SMESHOp::OpPopupImportGMF:
362 SMESH::ComputeError_var res;
363 aMeshes->length( 1 );
364 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
367 if ( res->code != SMESH::DRS_OK ) {
368 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
369 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
370 if ( strlen( res->comment.in() ) > 0 ) {
371 errors.back() += ": ";
372 errors.back() += res->comment.in();
379 catch ( const SALOME::SALOME_Exception& S_ex ) {
380 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
381 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
384 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
386 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
388 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
389 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
390 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
391 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
392 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
394 anEntryList.append( aMeshSO->GetID().c_str() );
402 // update Object browser
403 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
405 // browse to the published meshes
406 if( LightApp_Application* anApp =
407 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
408 anApp->browseObjects( anEntryList );
410 // show Error message box if there were errors
411 if ( errors.count() > 0 ) {
412 SUIT_MessageBox::critical( SMESHGUI::desktop(),
413 QObject::tr( "SMESH_ERROR" ),
414 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
417 // show warning message box, if some imported mesh is empty
419 SUIT_MessageBox::warning( SMESHGUI::desktop(),
420 QObject::tr( "SMESH_WRN_WARNING" ),
421 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
426 //================================================================================
428 * \brief Export selected meshes or groups into a file
430 //================================================================================
432 void ExportMeshToFile( int theCommandID )
434 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
435 SALOME_ListIO selected;
437 aSel->selectedObjects( selected );
439 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
440 theCommandID == SMESHOp::OpPopupExportDAT );
441 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
442 theCommandID == SMESHOp::OpPopupExportMED );
443 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
444 theCommandID == SMESHOp::OpPopupExportUNV );
445 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
446 theCommandID == SMESHOp::OpPopupExportSTL );
447 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
448 theCommandID == SMESHOp::OpPopupExportCGNS );
449 const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV ||
450 theCommandID == SMESHOp::OpPopupExportSAUV );
451 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
452 theCommandID == SMESHOp::OpPopupExportGMF );
454 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
455 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
457 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
458 bool aCheckWarn = true;
460 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
461 // get mesh object from selection and check duplication of their names
462 bool hasDuplicatedMeshNames = false;
463 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
464 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
465 SALOME_ListIteratorOfListIO It( selected );
466 for( ; It.More(); It.Next() )
468 Handle(SALOME_InteractiveObject) anIObject = It.Value();
469 SMESH::SMESH_IDSource_var aMeshItem =
470 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
471 if ( aMeshItem->_is_nil() ) {
472 SUIT_MessageBox::warning( SMESHGUI::desktop(),
473 QObject::tr( "SMESH_WRN_WARNING" ),
474 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
477 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
478 if ( aCheckWarn && !aGroup->_is_nil() )
480 QMessageBox msgBox(SUIT_MessageBox::Warning,
481 QObject::tr("SMESH_WRN_WARNING"),
482 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
483 QMessageBox::StandardButton::NoButton,
484 SMESHGUI::desktop());
485 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
486 msgBox.addButton(QMessageBox::Ok);
487 msgBox.addButton(QMessageBox::Cancel);
488 msgBox.setDefaultButton(QMessageBox::Cancel);
489 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
490 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
491 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
492 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
493 if(msgBox.exec() == QMessageBox::Ok)
495 if(dontShowCheckBox.checkState() == Qt::Checked)
498 resMgr->setValue( "SMESH", "show_warning", false);
506 QString aMeshName = anIObject->getName();
508 // check for name duplications
509 if ( !hasDuplicatedMeshNames )
510 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
511 if( aMeshName == (*aMeshIter).second ) {
512 hasDuplicatedMeshNames = true;
517 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
520 if( hasDuplicatedMeshNames && isMED ) {
521 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
522 QObject::tr("SMESH_WRN_WARNING"),
523 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
524 QObject::tr("SMESH_BUT_YES"),
525 QObject::tr("SMESH_BUT_NO"), 0, 1);
530 aMeshIter = aMeshList.begin();
531 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
532 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
533 QString aMeshName = (*aMeshIter).second;
535 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
537 // check for equal group names within each mesh
538 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
539 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
540 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
541 int aRet = SUIT_MessageBox::warning
542 (SMESHGUI::desktop(),
543 QObject::tr("SMESH_WRN_WARNING"),
544 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
545 QObject::tr("SMESH_BUT_YES"),
546 QObject::tr("SMESH_BUT_NO"), 0, 1);
553 // Warn the user about presence of not supported elements
555 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
559 notSupportedElemTypes.push_back( SMESH::Entity_0D );
560 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
565 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
566 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
567 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
568 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
569 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
570 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
571 notSupportedElemTypes.push_back( SMESH::Entity_0D );
572 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
577 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
578 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
579 notSupportedElemTypes.push_back( SMESH::Entity_0D );
580 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
585 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
590 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
591 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
592 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
593 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
594 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
595 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
596 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
597 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
602 notSupportedElemTypes.push_back( SMESH::Entity_0D );
603 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
604 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
605 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
606 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
607 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
608 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
609 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
610 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
611 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
613 if ( ! notSupportedElemTypes.empty() )
615 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
616 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
617 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
618 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
620 if ( !presentNotSupported.empty() )
623 const char* typeMsg[] = {
624 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
625 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
626 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
627 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
628 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
629 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
630 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
631 "SMESH_BIQUADRATIC_PENTAHEDRONS",
632 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
634 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
635 const int nbTypes = sizeof( typeMsg ) / sizeof( const char* );
636 int _assert[( nbTypes == SMESH::Entity_Last ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
638 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
639 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
640 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
641 if ( iType != presentNotSupported.size() - 1 )
642 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
644 int aRet = SUIT_MessageBox::warning
645 (SMESHGUI::desktop(),
646 QObject::tr("SMESH_WRN_WARNING"),
647 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
648 QObject::tr("SMESH_BUT_YES"),
649 QObject::tr("SMESH_BUT_NO"), 0, 1);
654 // Get parameters of export operation
657 // Init the parameters with the default values
658 bool aIsASCII_STL = true;
659 bool toCreateGroups = false;
661 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
662 bool toOverwrite = true;
663 bool toFindOutDim = true;
665 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
666 QString anInitialPath = "";
667 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
668 anInitialPath = QDir::currentPath();
670 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
672 // Get a file name to write in and additional otions
673 if ( isUNV || isDAT || isGMF ) // Export w/o options
676 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
678 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
680 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
681 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
682 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
683 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
684 anInitialPath + QString("/") + aMeshName,
685 aFilter, aTitle, false);
687 else if ( isCGNS )// Export to CGNS
689 const char* theByTypeResource = "cgns_group_elems_by_type";
690 toCreateGroups = SMESHGUI::resourceMgr()->booleanValue( "SMESH", theByTypeResource, false );
692 QStringList checkBoxes;
693 checkBoxes << QObject::tr("CGNS_EXPORT_ELEMS_BY_TYPE");
695 SalomeApp_CheckFileDlg* fd =
696 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
697 fd->setWindowTitle( aTitle );
698 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
699 if ( !anInitialPath.isEmpty() )
700 fd->setDirectory( anInitialPath );
701 fd->selectFile(aMeshName);
702 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
703 fd->setValidator( fv );
704 fd->SetChecked( toCreateGroups, 0 );
707 aFilename = fd->selectedFile();
708 toOverwrite = fv->isOverwrite();
709 toCreateGroups = fd->IsChecked(0);
710 SMESHGUI::resourceMgr()->setValue("SMESH", theByTypeResource, toCreateGroups );
714 else if ( isSTL ) // Export to STL
716 QMap<QString, int> aFilterMap;
717 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
718 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
721 QMap<QString, int>::const_iterator it = aFilterMap.begin();
722 for ( ; it != aFilterMap.end(); ++it )
723 filters.push_back( it.key() );
725 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
726 fd->setWindowTitle( aTitle );
727 fd->setNameFilters( filters );
728 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
729 if ( !anInitialPath.isEmpty() )
730 fd->setDirectory( anInitialPath );
731 fd->selectFile(aMeshName);
735 aFilename = fd->selectedFile();
736 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
741 else if ( isMED || isSAUV ) // Export to MED or SAUV
745 filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
748 filters << QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)";
751 QStringList checkBoxes;
752 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
754 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
755 QList< QWidget* > wdgList;
756 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
757 wdgList.append( fieldSelWdg );
759 SalomeApp_CheckFileDlg* fd =
760 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
761 fd->setWindowTitle( aTitle );
762 fd->setNameFilters( filters );
763 fd->SetChecked( toCreateGroups, 0 );
764 fd->SetChecked( toFindOutDim, 1 );
765 if ( !anInitialPath.isEmpty() )
766 fd->setDirectory( anInitialPath );
767 fd->selectFile(aMeshName);
770 QListView *lview = fd->findChild<QListView*>("listView");
772 lview->setMinimumHeight(200);
774 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
776 tview->setMinimumHeight(200);
779 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
780 fd->setValidator( fv );
785 aFilename = fd->selectedFile();
787 aFilename = QString::null;
790 toOverwrite = fv->isOverwrite();
792 if ( !aFilename.isEmpty() ) {
794 // can't append to an existing using other format
795 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckCompatibility( aFilename.toUtf8().constData() );
796 if ( !isVersionOk ) {
797 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
798 QObject::tr("SMESH_WRN_WARNING"),
799 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
800 QObject::tr("SMESH_BUT_YES"),
801 QObject::tr("SMESH_BUT_NO"), 0, 1);
808 QStringList aMeshNamesCollisionList;
809 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
810 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
811 QString anExistingMeshName( aMeshNames[ i ] );
812 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
813 QString anExportMeshName = (*aMeshIter).second;
814 if( anExportMeshName == anExistingMeshName ) {
815 aMeshNamesCollisionList.append( anExportMeshName );
820 if( !aMeshNamesCollisionList.isEmpty() ) {
821 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
822 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
823 QObject::tr("SMESH_WRN_WARNING"),
824 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
825 QObject::tr("SMESH_BUT_YES"),
826 QObject::tr("SMESH_BUT_NO"),
827 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
836 toCreateGroups = fd->IsChecked(0);
837 toFindOutDim = fd->IsChecked(1);
838 fieldSelWdg->GetSelectedFields();
839 if ( !fieldSelWdg->parent() )
850 if ( !aFilename.isEmpty() ) {
851 // Check whether the file already exists and delete it if yes
852 QFile aFile( aFilename );
853 if ( aFile.exists() && toOverwrite )
855 SUIT_OverrideCursor wc;
858 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
859 // bool Renumber = false;
860 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
862 // Renumber= resMgr->booleanValue("renumbering");
864 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
865 // aMeshEditor->RenumberNodes();
866 // aMeshEditor->RenumberElements();
867 // if ( SMESHGUI::automaticUpdate() )
868 // SMESH::UpdateView();
872 aMeshIter = aMeshList.begin();
873 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
875 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
876 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
877 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
878 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
879 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
880 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
881 aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups,
882 toOverwrite && aMeshIndex == 0, toFindOutDim );
884 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
885 toOverwrite && aMeshIndex == 0, toFindOutDim,
886 fields, geoAssFields.toLatin1().data() );
891 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
893 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
894 if( !aMeshItem->_is_nil() )
895 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
900 if ( aMeshOrGroup->_is_equivalent( aMesh ))
901 aMesh->ExportDAT( aFilename.toUtf8().data() );
903 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
907 if ( aMeshOrGroup->_is_equivalent( aMesh ))
908 aMesh->ExportUNV( aFilename.toUtf8().data() );
910 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
914 if ( aMeshOrGroup->_is_equivalent( aMesh ))
915 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
917 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
921 aMeshIter = aMeshList.begin();
922 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
924 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
925 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
926 aMeshItem->ExportCGNS( aMeshOrGroup,
927 aFilename.toUtf8().data(),
928 toOverwrite && aMeshIndex == 0,
934 toCreateGroups = true;
935 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
938 catch (const SALOME::SALOME_Exception& S_ex){
940 SUIT_MessageBox::warning(SMESHGUI::desktop(),
941 QObject::tr("SMESH_WRN_WARNING"),
942 QObject::tr("SMESH_EXPORT_FAILED"));
948 inline void InverseEntityMode(unsigned int& theOutputMode,
949 unsigned int theMode)
951 bool anIsNotPresent = ~theOutputMode & theMode;
953 theOutputMode |= theMode;
955 theOutputMode &= ~theMode;
958 void SetDisplayEntity(int theCommandID)
960 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
961 SALOME_ListIO selected;
963 aSel->selectedObjects( selected );
965 if ( selected.Extent() >= 1 ) {
966 SUIT_OverrideCursor wc;
967 SALOME_ListIteratorOfListIO It( selected );
968 for( ; It.More(); It.Next()){
969 Handle(SALOME_InteractiveObject) IObject = It.Value();
970 if(IObject->hasEntry()){
971 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
972 unsigned int aMode = anActor->GetEntityMode();
973 switch(theCommandID){
974 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
975 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
976 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
977 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
978 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
979 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
982 anActor->SetEntityMode(aMode);
991 SalomeApp_Application* app =
992 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
996 LightApp_SelectionMgr* aSel = app->selectionMgr();
997 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
998 if ( !aSel || !appStudy )
1001 SALOME_ListIO selected;
1002 aSel->selectedObjects( selected );
1003 if ( selected.IsEmpty() )
1006 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1008 _PTR(Study) aStudy = appStudy->studyDS();
1009 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1010 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1011 if ( aMainObject->_is_nil() )
1014 SUIT_OverrideCursor wc;
1016 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1018 QList<SALOMEDS::Color> aReservedColors;
1020 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1021 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1023 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1025 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1026 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1027 #else // old algorithm for auto-colors
1028 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1029 aReservedColors.append( aColor );
1030 #endif // SIMPLE_AUTOCOLOR
1031 aGroupObject->SetColor( aColor );
1033 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1034 if ( aGroupSObject ) {
1037 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1038 switch ( aGroupObject->GetType ()) {
1040 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1042 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1044 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1046 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1048 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1049 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1052 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1053 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1059 SMESH::RepaintCurrentView();
1062 void OverallMeshQuality()
1064 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1065 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1066 SALOME_ListIO selected;
1068 aSel->selectedObjects( selected );
1070 if ( selected.IsEmpty() ) return;
1071 SALOME_ListIteratorOfListIO It( selected );
1072 for ( ; It.More(); It.Next() ) {
1073 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1074 ctrlDlg->showInfo( It.Value() );
1079 QString functorToString( SMESH::Controls::FunctorPtr f )
1081 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1082 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1083 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1084 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1085 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1086 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1087 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1088 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1089 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1090 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1091 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1092 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1093 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1094 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1095 type = QObject::tr( "WARP_ELEMENTS" );
1096 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1097 type = QObject::tr( "TAPER_ELEMENTS" );
1098 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1099 type = QObject::tr( "SKEW_ELEMENTS" );
1100 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1101 type = QObject::tr( "AREA_ELEMENTS" );
1102 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1103 type = QObject::tr( "LENGTH_EDGES" );
1104 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1105 type = QObject::tr( "LENGTH2D_EDGES" );
1106 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1107 type = QObject::tr( "DEFLECTION2D_FACES" );
1108 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1109 type = QObject::tr( "MULTI_BORDERS" );
1110 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1111 type = QObject::tr( "MULTI2D_BORDERS" );
1112 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1113 type = QObject::tr( "FREE_NODES" );
1114 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1115 type = QObject::tr( "FREE_EDGES" );
1116 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1117 type = QObject::tr( "FREE_BORDERS" );
1118 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1119 type = QObject::tr( "FREE_FACES" );
1120 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1121 type = QObject::tr( "BARE_BORDER_VOLUME" );
1122 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1123 type = QObject::tr( "BARE_BORDER_FACE" );
1124 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1125 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1126 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1127 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1128 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1129 type = QObject::tr( "EQUAL_NODE" );
1130 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1131 type = QObject::tr( "EQUAL_EDGE" );
1132 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1133 type = QObject::tr( "EQUAL_FACE" );
1134 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1135 type = QObject::tr( "EQUAL_VOLUME" );
1136 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1137 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1141 void SaveDistribution()
1143 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1144 SALOME_ListIO selected;
1146 aSel->selectedObjects( selected );
1148 if ( selected.Extent() == 1 ) {
1149 Handle(SALOME_InteractiveObject) anIO = selected.First();
1150 if ( anIO->hasEntry() ) {
1151 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1153 anActor->GetScalarBarActor() &&
1154 anActor->GetControlMode() != SMESH_Actor::eNone )
1156 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1157 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1158 if ( aScalarBarActor && aFunctor ) {
1159 SMESH::Controls::NumericalFunctor* aNumFun =
1160 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1162 std::vector<int> elements;
1163 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1164 if ( mesh->_is_nil() ) {
1165 SMESH::SMESH_IDSource_var idSource =
1166 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1167 if ( !idSource->_is_nil() )
1169 SMESH::long_array_var ids = idSource->GetIDs();
1170 elements.resize( ids->length() );
1171 for ( unsigned i = 0; i < elements.size(); ++i )
1172 elements[i] = ids[i];
1175 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1176 vtkLookupTable* lookupTable =
1177 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1178 double * minmax = lookupTable->GetRange();
1179 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1180 std::vector<int> nbEvents;
1181 std::vector<double> funValues;
1182 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1183 elements, minmax, isLogarithmic );
1184 QString anInitialPath = "";
1185 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1186 anInitialPath = QDir::currentPath();
1187 QString aMeshName = anIO->getName();
1189 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1190 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1191 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1192 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1193 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1196 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1198 if ( !aFilename.isEmpty() ) {
1199 QFile f( aFilename );
1200 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1201 QTextStream out( &f );
1202 out << "# Mesh: " << aMeshName << endl;
1203 out << "# Control: " << functorToString( aFunctor ) << endl;
1205 out.setFieldWidth( 10 );
1206 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1207 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1218 void ShowElement( int theCommandID )
1220 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1221 SALOME_ListIO selected;
1223 aSel->selectedObjects( selected );
1225 if ( selected.Extent() == 1 ) {
1226 Handle(SALOME_InteractiveObject) anIO = selected.First();
1227 if ( anIO->hasEntry() ) {
1228 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1230 anActor->GetScalarBarActor() &&
1231 anActor->GetControlMode() != SMESH_Actor::eNone )
1233 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1234 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1235 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1237 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1238 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1245 #ifndef DISABLE_PLOT2DVIEWER
1246 void PlotDistribution()
1248 SalomeApp_Application* app =
1249 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1253 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1254 SALOME_ListIO selected;
1256 aSel->selectedObjects( selected );
1258 if ( selected.Extent() == 1 ) {
1259 Handle(SALOME_InteractiveObject) anIO = selected.First();
1260 if ( anIO->hasEntry() ) {
1261 //Find Actor by entry before getting Plot2d viewer,
1262 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1263 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1265 SUIT_ViewManager* aViewManager =
1266 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1270 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1274 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1278 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1280 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1281 QString functorName = functorToString( anActor->GetFunctor());
1282 QString aHistogramName("%1 : %2");
1283 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1284 aHistogram->setName(aHistogramName);
1285 aHistogram->setHorTitle(functorName);
1286 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1287 aPlot->displayObject(aHistogram, true);
1292 #endif //DISABLE_PLOT2DVIEWER
1294 void DisableAutoColor()
1296 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1297 SALOME_ListIO selected;
1299 aSel->selectedObjects( selected );
1301 if ( selected.Extent() ) {
1302 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1303 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1304 if ( !aMesh->_is_nil() ) {
1305 aMesh->SetAutoColor( false );
1312 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1313 SALOME_ListIO selected;
1315 aSel->selectedObjects( selected );
1316 if ( selected.Extent() )
1318 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1319 _PTR(Study) aStudy = SMESH::getStudy();
1320 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1322 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1323 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1330 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1332 SALOME_ListIO selected;
1333 SalomeApp_Application* app =
1334 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1338 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1339 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1340 if ( !aSel || !appStudy )
1343 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1344 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1345 aModule->EmitSignalDeactivateDialog();
1346 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1347 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1352 aSel->selectedObjects( selected );
1354 if ( selected.Extent() >= 1 )
1356 switch ( theCommandID ) {
1357 case SMESHOp::OpTransparency:
1359 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1360 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1363 case SMESHOp::OpProperties:
1366 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1367 QColor orientationColor, outlineColor, volumeColor;
1368 int deltaF = 0, deltaV = 0;
1371 double ballScale = 1.0;
1373 int outlineWidth = 1;
1374 double shrinkCoef = 0.0;
1375 double orientationScale = 0.0;
1376 bool orientation3d = false;
1377 VTK::MarkerType markerType = VTK::MT_NONE;
1378 VTK::MarkerScale markerScale = VTK::MS_NONE;
1380 bool hasNodes = false;
1381 int presentEntities = 0;
1382 bool firstTime = true;
1384 SALOME_ListIteratorOfListIO It( selected );
1385 for ( ; It.More(); It.Next() ) {
1386 Handle(SALOME_InteractiveObject) IObject = It.Value();
1387 if ( !IObject->hasEntry() ) continue;
1388 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1389 if ( !anActor || !anActor->GetObject() ) continue;
1392 // nodes: color, marker
1393 anActor->GetNodeColor( color[0], color[1], color[2] );
1394 nodeColor.setRgbF( color[0], color[1], color[2] );
1395 markerType = anActor->GetMarkerType();
1396 markerScale = anActor->GetMarkerScale();
1397 markerId = anActor->GetMarkerTexture();
1398 // edges: color, width
1399 anActor->GetEdgeColor( color[0], color[1], color[2] );
1400 edgeColor.setRgbF( color[0], color[1], color[2] );
1401 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1402 // faces: front color, back color (delta)
1403 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1404 faceColor.setRgbF( color[0], color[1], color[2] );
1405 // faces: front color, back color (delta)
1406 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1407 volumeColor.setRgbF( color[0], color[1], color[2] );
1408 // 0d elements: color, size
1409 anActor->Get0DColor( color[0], color[1], color[2] );
1410 elem0dColor.setRgbF( color[0], color[1], color[2] );
1411 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1412 // balls: color, size
1413 anActor->GetBallColor( color[0], color[1], color[2] );
1414 ballColor.setRgbF( color[0], color[1], color[2] );
1415 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1416 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1418 anActor->GetOutlineColor( color[0], color[1], color[2] );
1419 outlineColor.setRgbF( color[0], color[1], color[2] );
1420 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1421 // orientation vectors: color, scale, 3d flag
1422 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1423 orientationColor.setRgbF( color[0], color[1], color[2] );
1424 orientationScale = anActor->GetFacesOrientationScale();
1425 orientation3d = anActor->GetFacesOrientation3DVectors();
1427 shrinkCoef = anActor->GetShrinkFactor();
1430 firstTime = false; // we only take properties from first object (for performance reasons)
1433 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1434 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1435 presentEntities = presentEntities | SMESH_Actor::eEdges;
1436 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1437 presentEntities = presentEntities | SMESH_Actor::eFaces;
1438 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1439 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1440 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1441 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1442 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1443 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1445 // as we know that all types of elements are present, we can exit the loop
1446 if ( presentEntities == SMESH_Actor::eAllEntity )
1450 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1451 // nodes: color, marker
1452 dlg.setNodeColor( nodeColor );
1453 if( markerType != VTK::MT_USER )
1454 dlg.setNodeMarker( markerType, markerScale );
1456 dlg.setNodeCustomMarker( markerId );
1457 // edges: color, line width
1458 dlg.setEdgeColor( edgeColor );
1459 dlg.setEdgeWidth( edgeWidth );
1460 // faces: front color, back color
1461 dlg.setFaceColor( faceColor, deltaF );
1462 // volumes: normal color, reversed color
1463 dlg.setVolumeColor( volumeColor, deltaV );
1464 // outlines: color, line width
1465 dlg.setOutlineColor( outlineColor );
1466 dlg.setOutlineWidth( outlineWidth );
1467 // 0d elements: color, size
1468 dlg.setElem0dColor( elem0dColor );
1469 dlg.setElem0dSize( elem0dSize );
1470 // balls: color, size
1471 dlg.setBallColor( ballColor );
1472 //dlg.setBallSize( ballSize );
1473 dlg.setBallScale( ballScale );
1474 // orientation: color, scale, 3d flag
1475 dlg.setOrientationColor( orientationColor );
1476 dlg.setOrientationSize( int( orientationScale * 100. ) );
1477 dlg.setOrientation3d( orientation3d );
1478 // shrink: scale factor
1479 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1480 // hide unused controls
1481 dlg.showControls( presentEntities, hasNodes );
1484 nodeColor = dlg.nodeColor();
1485 markerType = dlg.nodeMarkerType();
1486 markerScale = dlg.nodeMarkerScale();
1487 markerId = dlg.nodeMarkerId();
1488 edgeColor = dlg.edgeColor();
1489 edgeWidth = dlg.edgeWidth();
1490 faceColor = dlg.faceColor();
1491 deltaF = dlg.faceColorDelta();
1492 volumeColor = dlg.volumeColor();
1493 deltaV = dlg.volumeColorDelta();
1494 outlineColor = dlg.outlineColor();
1495 outlineWidth = dlg.outlineWidth();
1496 elem0dColor = dlg.elem0dColor();
1497 elem0dSize = dlg.elem0dSize();
1498 ballColor = dlg.ballColor();
1499 // ballSize = dlg.ballSize();
1500 ballScale = dlg.ballScale();
1501 orientationColor = dlg.orientationColor();
1502 orientationScale = dlg.orientationSize() / 100.;
1503 orientation3d = dlg.orientation3d();
1504 shrinkCoef = dlg.shrinkCoef() / 100.;
1506 // store point markers that might be changed by the user
1507 theMarkerMap = dlg.customMarkers();
1509 // set properties from dialog box to the presentations
1510 SALOME_ListIteratorOfListIO It( selected );
1511 for ( ; It.More(); It.Next() ) {
1512 Handle(SALOME_InteractiveObject) IObject = It.Value();
1513 if ( !IObject->hasEntry() ) continue;
1514 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1515 if ( !anActor ) continue;
1517 // nodes: color, marker
1518 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1519 if ( markerType != VTK::MT_USER ) {
1520 anActor->SetMarkerStd( markerType, markerScale );
1523 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1524 if ( iter != theMarkerMap.end() )
1525 anActor->SetMarkerTexture( markerId, iter->second.second );
1527 // volumes: normal color, reversed color (delta)
1528 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1529 // faces: front color, back color (delta)
1530 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1531 // edges: color, width
1532 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1533 anActor->SetLineWidth( edgeWidth );
1535 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1536 anActor->SetOutlineWidth( outlineWidth );
1537 // 0D elements: color, size
1538 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1539 anActor->Set0DSize( elem0dSize );
1540 // balls: color, size
1541 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1542 // anActor->SetBallSize( ballSize );
1543 anActor->SetBallScale( ballScale );
1544 // orientation: color, scale, 3d flag
1545 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1546 anActor->SetFacesOrientationScale( orientationScale );
1547 anActor->SetFacesOrientation3DVectors( orientation3d );
1549 anActor->SetShrinkFactor( shrinkCoef );
1551 // for groups, set also proper color
1552 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1553 if ( !aGroupObject->_is_nil() ) {
1554 SMESH::ElementType anElementType = aGroupObject->GetType();
1556 switch( anElementType ) {
1558 aColor = nodeColor; break;
1560 aColor = edgeColor; break;
1562 aColor = faceColor; break;
1564 aColor = volumeColor; break;
1566 aColor = elem0dColor; break;
1568 aColor = ballColor; break;
1572 if ( aColor.isValid() ) {
1573 SALOMEDS::Color aGroupColor;
1574 aGroupColor.R = aColor.redF();
1575 aGroupColor.G = aColor.greenF();
1576 aGroupColor.B = aColor.blueF();
1577 aGroupObject->SetColor( aGroupColor );
1579 } // if ( !aGroupObject->_is_nil() )
1580 } // for ( ; It.More(); It.Next() )
1581 SMESH::RepaintCurrentView();
1582 } // if ( dlg.exec() )
1584 } // case SMESHOp::OpProperties:
1585 } // switch(theCommandID)
1586 SUIT_OverrideCursor wc;
1587 SALOME_ListIteratorOfListIO It( selected );
1588 for( ; It.More(); It.Next()){
1589 Handle(SALOME_InteractiveObject) IObject = It.Value();
1590 if(IObject->hasEntry()){
1591 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1592 switch(theCommandID){
1593 case SMESHOp::OpDMWireframe:
1594 anActor->SetRepresentation(SMESH_Actor::eEdge);
1596 case SMESHOp::OpDMShading:
1597 anActor->SetRepresentation(SMESH_Actor::eSurface);
1599 case SMESHOp::OpDMShrink:
1600 if(anActor->IsShrunk())
1601 anActor->UnShrink();
1603 anActor->SetShrink();
1605 case SMESHOp::OpDMNodes:
1606 anActor->SetRepresentation(SMESH_Actor::ePoint);
1608 case SMESHOp::OpRepresentationLines:
1609 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1610 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1612 case SMESHOp::OpRepresentationArcs:
1613 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1614 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1620 SMESH::RepaintCurrentView();
1624 int ActionToControl( int theID, bool theReversed )
1626 NCollection_DoubleMap<int,int> ActionControl;
1627 ActionControl.Bind( 0, SMESH_Actor::eNone );
1628 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1629 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1630 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1631 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1632 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1633 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1634 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1635 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1636 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1637 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1638 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1639 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1640 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1641 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1642 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1643 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1644 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1645 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1646 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1647 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1648 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1649 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1650 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1651 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1652 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1653 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1654 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1655 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1657 return theReversed ? ActionControl.Find2( theID ) : ActionControl.Find1( theID );
1660 void Control( int theCommandID )
1662 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1663 _PTR(Study) aStudy = SMESH::getStudy();
1665 SALOME_ListIO selected;
1666 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1667 aSel->selectedObjects( selected );
1669 if ( !selected.IsEmpty() ) {
1670 SALOME_ListIteratorOfListIO It(selected);
1671 for ( ; It.More(); It.Next())
1673 Handle(SALOME_InteractiveObject) anIO = It.Value();
1674 if ( !anIO.IsNull() ) {
1675 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1677 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1678 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1679 if ( !anIDSrc->_is_nil() ) {
1680 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1681 if (( !anActor && selected.Extent() == 1 ) &&
1682 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1684 anActor->SetControlMode( aControl );
1685 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1686 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1690 if ( anActor->GetControlMode() != aControl )
1691 anActor->SetControlMode( aControl );
1692 QString functorName = functorToString( anActor->GetFunctor() );
1693 int anEntitiesCount = anActor->GetNumberControlEntities();
1694 if (anEntitiesCount >= 0)
1695 functorName = functorName + ": " + QString::number(anEntitiesCount);
1696 anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
1697 SMESH::RepaintCurrentView();
1698 #ifndef DISABLE_PLOT2DVIEWER
1699 if ( anActor->GetPlot2Histogram() ) {
1700 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1701 QString aHistogramName("%1 : %2");
1702 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1703 aHistogram->setName( aHistogramName );
1704 aHistogram->setHorTitle( functorName );
1705 SMESH::ProcessIn2DViewers( anActor );
1717 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1718 SMESH::MeshObjectType theType,
1719 const QString theInTypeName,
1720 QString & theOutTypeName)
1722 SMESH_TypeFilter aTypeFilter( theType );
1724 if ( !theIO.IsNull() )
1726 entry = theIO->getEntry();
1727 LightApp_DataOwner owner( entry );
1728 if ( aTypeFilter.isOk( &owner )) {
1729 theOutTypeName = theInTypeName;
1737 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1739 _PTR(Study) aStudy = SMESH::getStudy();
1740 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1742 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1743 CORBA::String_var anID = aSComp->GetID().c_str();
1744 if ( !strcmp(anID.in(),theIO->getEntry()) )
1750 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1751 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1752 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1753 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1754 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1762 // QString CheckHomogeneousSelection()
1764 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1765 // SALOME_ListIO selected;
1767 // aSel->selectedObjects( selected );
1769 // QString RefType = CheckTypeObject(selected.First());
1770 // SALOME_ListIteratorOfListIO It(selected);
1771 // for ( ; It.More(); It.Next())
1773 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1774 // QString Type = CheckTypeObject(IObject);
1775 // if ( Type.compare(RefType) != 0 )
1776 // return "Heterogeneous Selection";
1782 uint randomize( uint size )
1784 static bool initialized = false;
1785 if ( !initialized ) {
1786 qsrand( QDateTime::currentDateTime().toTime_t() );
1790 v = uint( (double)( v ) / RAND_MAX * size );
1791 v = qMax( uint(0), qMin ( v, size-1 ) );
1797 void SMESHGUI::OnEditDelete()
1799 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1800 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1801 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1803 _PTR(Study) aStudy = SMESH::getStudy();
1804 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1805 _PTR(GenericAttribute) anAttr;
1806 _PTR(AttributeIOR) anIOR;
1808 int objectCount = 0;
1810 QString aParentComponent = QString::null;
1811 Handle(SALOME_InteractiveObject) anIO;
1812 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1814 anIO = anIt.Value();
1815 QString cur = anIO->getComponentDataType();
1816 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1818 // check if object is reference
1819 _PTR(SObject) aRefSObj;
1820 aNameList.append("\n - ");
1821 if ( aSO->ReferencedObject( aRefSObj ) ) {
1822 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1823 aNameList.append( aRefName );
1824 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1827 aNameList.append(anIO->getName());
1831 if( aParentComponent.isNull() )
1832 aParentComponent = cur;
1833 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1834 aParentComponent = "";
1837 if ( objectCount == 0 )
1838 return; // No Valid Objects Selected
1840 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1841 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1842 QObject::tr("ERR_ERROR"),
1843 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1846 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1847 if (SUIT_MessageBox::warning
1848 (SMESHGUI::desktop(),
1849 QObject::tr("SMESH_WRN_WARNING"),
1850 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1851 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1852 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1855 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1857 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1858 // then treat them all starting from the deepest objects (at list back)
1859 std::list< _PTR(SObject) > listSO;
1860 SALOME_ListIteratorOfListIO It(selected);
1861 for( ; It.More(); It.Next()) // loop on selected IO's
1863 Handle(SALOME_InteractiveObject) IObject = It.Value();
1864 if(IObject->hasEntry()) {
1865 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1867 // disable removal of "SMESH" component object
1868 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1870 if ( engineIOR() == anIOR->Value().c_str() )
1873 //Check the referenced object
1874 _PTR(SObject) aRefSObject;
1875 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1876 aSO = aRefSObject; // Delete main Object instead of reference
1878 listSO.push_back( aSO );
1879 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1880 for ( ; itSO != listSO.end(); ++itSO ) {
1881 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1882 for (it->InitEx(false); it->More(); it->Next())
1883 listSO.push_back( it->Value() );
1887 // Check if none of objects to delete is referred from outside
1888 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1889 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1891 _PTR(SObject) SO = *ritSO;
1892 if ( !SO ) continue;
1893 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1894 for (size_t i = 0; i < aReferences.size(); i++) {
1895 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1896 std::string type = aComponent->ComponentDataType();
1897 if ( type != "SMESH" )
1899 SUIT_MessageBox::warning( anApp->desktop(),
1900 QObject::tr("WRN_WARNING"),
1901 QObject::tr("DEP_OBJECT") );
1902 return; // outside SMESH, there is an object depending on a SMESH object
1907 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1908 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1910 Handle(SALOME_InteractiveObject) IObject = It.Value();
1911 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1912 if ( !mesh->_is_nil() )
1916 // Treat SO's in the list starting from the back
1917 aStudyBuilder->NewCommand(); // There is a transaction
1918 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1920 _PTR(SObject) SO = *ritSO;
1921 if ( !SO ) continue;
1922 std::string anEntry = SO->GetID();
1924 /** Erase graphical object and remove all its data **/
1925 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1926 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1928 /** Remove an object from data structures **/
1929 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1930 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1931 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1932 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1933 aMesh->RemoveGroup( aGroup );
1935 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1936 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1937 aMesh->RemoveSubMesh( aSubMesh );
1939 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1941 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1944 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1945 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1946 QString objType = CheckTypeObject(IObject);
1947 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1948 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1949 aStudyBuilder->RemoveObjectWithChildren( SO );
1951 else {// default action: remove SObject from the study
1952 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1953 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1955 aStudyBuilder->RemoveObjectWithChildren( SO );
1959 } /* listSO back loop */
1961 aStudyBuilder->CommitCommand();
1963 /* Clear any previous selection */
1965 aSel->setSelectedObjects( l1 );
1967 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1971 SMESHGUI_EXPORT CAM_Module* createModule()
1973 return new SMESHGUI();
1976 SMESHGUI_EXPORT char* getModuleVersion() {
1977 return (char*)SMESH_VERSION_STR;
1981 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1983 //=============================================================================
1987 //=============================================================================
1988 SMESHGUI::SMESHGUI() :
1989 SalomeApp_Module( "SMESH" )
1991 if ( CORBA::is_nil( myComponentSMESH ) )
1993 CORBA::Boolean anIsEmbeddedMode;
1994 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1995 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1997 // 0019923: EDF 765 SMESH : default values of hypothesis
1998 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1999 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2000 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2001 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2002 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2004 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2005 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2006 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2008 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2009 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2013 myActiveDialogBox = 0;
2014 myFilterLibraryDlg = 0;
2018 myEventCallbackCommand = vtkCallbackCommand::New();
2019 myEventCallbackCommand->Delete();
2020 myEventCallbackCommand->SetClientData( this );
2021 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2024 /* load resources for all available meshers */
2025 SMESH::InitAvailableHypotheses();
2028 //=============================================================================
2032 //=============================================================================
2033 SMESHGUI::~SMESHGUI()
2037 //=============================================================================
2041 //=============================================================================
2042 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2044 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2046 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2051 //=============================================================================
2055 //=============================================================================
2056 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2058 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2062 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2063 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2064 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2065 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2066 return autoUpdate && !exceeded;
2069 //=============================================================================
2073 //=============================================================================
2074 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2075 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2077 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2081 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2082 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2083 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2085 SMESH::long_array_var info = theMesh->GetMeshInfo();
2086 long nbOdElems = info[SMDSEntity_0D];
2087 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2088 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2089 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2090 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2091 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2092 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2093 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2094 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2095 info[SMDSEntity_Polyhedra] +
2096 info[SMDSEntity_Hexagonal_Prism];
2097 long nbBalls = info[SMDSEntity_Ball];
2099 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2100 *nbElements = requestedSize;
2102 *entities = SMESH_Actor::eAllEntity;
2105 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2107 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2109 if ( incrementalLimit ) {
2112 if ( nbOdElems > 0 ) {
2113 if ( total + nbOdElems > updateLimit ) {
2114 *entities = *entities & ~SMESH_Actor::e0DElements;
2115 *hidden = *hidden | SMESH_Actor::e0DElements;
2122 if ( nbEdges > 0 ) {
2123 if ( total + nbEdges > updateLimit ) {
2124 *entities = *entities & ~SMESH_Actor::eEdges;
2125 *hidden = *hidden | SMESH_Actor::eEdges;
2132 if ( nbFaces > 0 ) {
2133 if ( total + nbFaces > updateLimit ) {
2134 *entities = *entities & ~SMESH_Actor::eFaces;
2135 *hidden = *hidden | SMESH_Actor::eFaces;
2142 if ( nbVolumes > 0 ) {
2143 if ( total + nbVolumes > updateLimit ) {
2144 *entities = *entities & ~SMESH_Actor::eVolumes;
2145 *hidden = *hidden | SMESH_Actor::eVolumes;
2152 if ( nbBalls > 0 ) {
2153 if ( total + nbBalls > updateLimit ) {
2154 *entities = *entities & ~SMESH_Actor::eBallElem;
2155 *hidden = *hidden | SMESH_Actor::eBallElem;
2163 return autoUpdate && !exceeded;
2166 //=============================================================================
2170 //=============================================================================
2171 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2173 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2176 //=============================================================================
2180 //=============================================================================
2181 SMESHGUI* SMESHGUI::GetSMESHGUI()
2183 SMESHGUI* smeshMod = 0;
2184 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2187 CAM_Module* module = app->module( "Mesh" );
2188 smeshMod = dynamic_cast<SMESHGUI*>( module );
2196 Standard_EXPORT SMESHGUI* GetComponentGUI()
2198 return SMESHGUI::GetSMESHGUI();
2202 //=============================================================================
2206 //=============================================================================
2207 void SMESHGUI::SetState(int aState)
2212 //=============================================================================
2216 //=============================================================================
2217 void SMESHGUI::ResetState()
2222 //=============================================================================
2226 //=============================================================================
2227 void SMESHGUI::EmitSignalDeactivateDialog()
2229 emit SignalDeactivateActiveDialog();
2232 //=============================================================================
2236 //=============================================================================
2237 void SMESHGUI::EmitSignalStudyFrameChanged()
2239 emit SignalStudyFrameChanged();
2242 //=============================================================================
2246 //=============================================================================
2247 void SMESHGUI::EmitSignalCloseAllDialogs()
2249 emit SignalCloseAllDialogs();
2252 //=============================================================================
2256 //=============================================================================
2257 void SMESHGUI::EmitSignalVisibilityChanged()
2259 emit SignalVisibilityChanged();
2262 //=============================================================================
2266 //=============================================================================
2267 void SMESHGUI::EmitSignalCloseView()
2269 emit SignalCloseView();
2272 //=============================================================================
2276 //=============================================================================
2277 void SMESHGUI::EmitSignalActivatedViewManager()
2279 emit SignalActivatedViewManager();
2282 //=============================================================================
2286 //=============================================================================
2287 QDialog *SMESHGUI::GetActiveDialogBox()
2289 return myActiveDialogBox;
2292 //=============================================================================
2296 //=============================================================================
2297 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2299 myActiveDialogBox = (QDialog *) aDlg;
2303 //=============================================================================
2307 //=============================================================================
2308 SUIT_Desktop* SMESHGUI::desktop()
2310 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2312 return app->desktop();
2317 //=============================================================================
2321 //=============================================================================
2322 SalomeApp_Study* SMESHGUI::activeStudy()
2324 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2326 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2331 //=============================================================================
2335 //=============================================================================
2336 void SMESHGUI::Modified( bool theIsUpdateActions )
2338 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2339 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2340 appStudy->Modified();
2341 if( theIsUpdateActions )
2342 app->updateActions();
2347 //=============================================================================
2351 //=============================================================================
2352 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2354 /* Here the position is on the bottom right corner - 10 */
2355 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2357 SUIT_Desktop *PP = desktop();
2358 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2359 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2364 * \brief Verifies whether study of operation is locked
2365 * \param theMess - specifies whether message box must be shown if study is locked
2366 * \return State of study.
2368 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2369 * is locked when corresponding message box appears
2371 bool SMESHGUI::isStudyLocked( bool theMessage )
2373 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2376 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2377 QObject::tr( "WRN_WARNING" ),
2378 QObject::tr( "WRN_STUDY_LOCKED" ) );
2384 //=============================================================================
2388 //=============================================================================
2389 bool SMESHGUI::OnGUIEvent( int theCommandID )
2391 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2395 SUIT_ResourceMgr* mgr = resourceMgr();
2399 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2400 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2402 //QAction* act = action( theCommandID );
2404 switch (theCommandID) {
2405 case SMESHOp::OpDelete:
2406 if(isStudyLocked()) break;
2409 case SMESHOp::OpImportDAT:
2410 case SMESHOp::OpImportUNV:
2411 case SMESHOp::OpImportMED:
2412 case SMESHOp::OpImportSTL:
2413 case SMESHOp::OpImportCGNS:
2414 case SMESHOp::OpImportSAUV:
2415 case SMESHOp::OpImportGMF:
2416 case SMESHOp::OpPopupImportDAT:
2417 case SMESHOp::OpPopupImportUNV:
2418 case SMESHOp::OpPopupImportMED:
2419 case SMESHOp::OpPopupImportSTL:
2420 case SMESHOp::OpPopupImportCGNS:
2421 case SMESHOp::OpPopupImportSAUV:
2422 case SMESHOp::OpPopupImportGMF:
2424 if(isStudyLocked()) break;
2425 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2429 case SMESHOp::OpFileInformation:
2431 SALOME_ListIO selected;
2432 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2434 aSel->selectedObjects( selected );
2435 if( selected.Extent() )
2437 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2438 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2439 if ( !aMesh->_is_nil() )
2441 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2447 case SMESHOp::OpExportDAT:
2448 case SMESHOp::OpExportMED:
2449 case SMESHOp::OpExportUNV:
2450 case SMESHOp::OpExportSTL:
2451 case SMESHOp::OpExportCGNS:
2452 case SMESHOp::OpExportSAUV:
2453 case SMESHOp::OpExportGMF:
2454 case SMESHOp::OpPopupExportDAT:
2455 case SMESHOp::OpPopupExportMED:
2456 case SMESHOp::OpPopupExportUNV:
2457 case SMESHOp::OpPopupExportSTL:
2458 case SMESHOp::OpPopupExportCGNS:
2459 case SMESHOp::OpPopupExportSAUV:
2460 case SMESHOp::OpPopupExportGMF:
2462 ::ExportMeshToFile(theCommandID);
2466 case SMESHOp::OpReset: // SCALAR BAR
2468 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2469 SALOME_ListIO selected;
2471 aSel->selectedObjects( selected );
2473 SALOME_ListIteratorOfListIO it(selected);
2474 for( ; it.More(); it.Next()) {
2475 Handle(SALOME_InteractiveObject) anIO = it.Value();
2476 if( anIO->hasEntry() ) {
2477 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2478 anActor->SetControlMode( SMESH_Actor::eNone );
2479 #ifndef DISABLE_PLOT2DVIEWER
2480 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2485 SMESH::UpdateView();
2488 case SMESHOp::OpScalarBarProperties:
2490 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2493 case SMESHOp::OpShowScalarBar:
2495 // show/hide scalar bar
2496 ::ShowElement(theCommandID);
2499 case SMESHOp::OpSaveDistribution:
2501 // dump control distribution data to the text file
2502 ::SaveDistribution();
2506 case SMESHOp::OpShowDistribution:
2508 // show/hide distribution
2509 ::ShowElement(theCommandID);
2513 #ifndef DISABLE_PLOT2DVIEWER
2514 case SMESHOp::OpPlotDistribution:
2516 // plot distribution
2517 ::PlotDistribution();
2523 case SMESHOp::OpAutoColor:
2527 case SMESHOp::OpDisableAutoColor:
2528 ::DisableAutoColor();
2531 case SMESHOp::OpClipping:
2532 case SMESHOp::OpTransparency:
2533 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2536 case SMESHOp::OpDMWireframe:
2537 case SMESHOp::OpDMShading:
2538 case SMESHOp::OpDMNodes:
2539 case SMESHOp::OpDMShrink:
2540 ::SetDisplayMode(theCommandID, myMarkerMap);
2543 //2D quadratic representation
2544 case SMESHOp::OpRepresentationLines:
2545 case SMESHOp::OpRepresentationArcs:
2546 ::SetDisplayMode(theCommandID, myMarkerMap);
2550 case SMESHOp::OpDE0DElements:
2551 case SMESHOp::OpDEEdges:
2552 case SMESHOp::OpDEFaces:
2553 case SMESHOp::OpDEVolumes:
2554 case SMESHOp::OpDEBalls:
2555 case SMESHOp::OpDEAllEntity:
2556 ::SetDisplayEntity(theCommandID);
2559 // Choose entities to be displayed
2560 case SMESHOp::OpDEChoose:
2562 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2566 case SMESHOp::OpOrientationOnFaces:
2568 SUIT_OverrideCursor wc;
2569 LightApp_SelectionMgr* mgr = selectionMgr();
2570 SALOME_ListIO selected; mgr->selectedObjects( selected );
2572 SALOME_ListIteratorOfListIO it(selected);
2573 for( ; it.More(); it.Next()) {
2574 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2575 if(anIObject->hasEntry()) {
2576 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2577 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2584 case SMESHOp::OpUpdate:
2586 if(isStudyLocked()) break;
2587 SUIT_OverrideCursor wc;
2590 SMESH::UpdateView();
2592 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2593 SMESH::OnVisuException();
2595 catch (...) { // PAL16774 (Crash after display of many groups)
2596 SMESH::OnVisuException();
2600 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2601 aSel->selectedObjects( l );
2602 aSel->setSelectedObjects( l );
2606 case SMESHOp::OpHide:
2607 case SMESHOp::OpShow:
2608 case SMESHOp::OpShowOnly:
2610 SUIT_OverrideCursor wc;
2611 SMESH::EDisplaing anAction;
2612 switch (theCommandID) {
2613 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2614 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2615 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2618 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2619 SALOME_ListIO sel_objects, to_process;
2621 aSel->selectedObjects( sel_objects );
2623 if ( theCommandID==SMESHOp::OpShowOnly )
2625 //MESSAGE("anAction = SMESH::eDisplayOnly");
2626 startOperation( myEraseAll );
2629 extractContainers( sel_objects, to_process );
2634 SALOME_ListIteratorOfListIO It( to_process );
2635 for ( ; It.More(); It.Next())
2637 Handle(SALOME_InteractiveObject) IOS = It.Value();
2638 if ( IOS->hasEntry() )
2640 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2641 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2642 break; // PAL16774 (Crash after display of many groups)
2644 if (anAction == SMESH::eDisplayOnly)
2645 anAction = SMESH::eDisplay;
2650 // PAL13338 + PAL15161 -->
2651 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2652 SMESH::UpdateView();
2653 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2655 // PAL13338 + PAL15161 <--
2657 catch (...) { // PAL16774 (Crash after display of many groups)
2658 SMESH::OnVisuException();
2661 if (anAction == SMESH::eErase) {
2663 aSel->setSelectedObjects( l1 );
2666 aSel->setSelectedObjects( to_process );
2671 case SMESHOp::OpNode:
2673 if(isStudyLocked()) break;
2676 EmitSignalDeactivateDialog();
2678 ( new SMESHGUI_NodesDlg( this ) )->show();
2681 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2686 case SMESHOp::OpCreateMesh:
2687 case SMESHOp::OpCreateSubMesh:
2688 case SMESHOp::OpEditMeshOrSubMesh:
2689 case SMESHOp::OpEditMesh:
2690 case SMESHOp::OpEditSubMesh:
2691 case SMESHOp::OpCompute:
2692 case SMESHOp::OpComputeSubMesh:
2693 case SMESHOp::OpPreCompute:
2694 case SMESHOp::OpEvaluate:
2695 case SMESHOp::OpMeshOrder:
2696 startOperation( theCommandID );
2698 case SMESHOp::OpCopyMesh:
2700 if (isStudyLocked()) break;
2701 EmitSignalDeactivateDialog();
2702 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2705 case SMESHOp::OpBuildCompoundMesh:
2707 if (isStudyLocked()) break;
2708 EmitSignalDeactivateDialog();
2709 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2713 case SMESHOp::OpDiagonalInversion:
2714 case SMESHOp::OpUnionOfTwoTriangle:
2718 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2722 if ( isStudyLocked() )
2725 /*Standard_Boolean aRes;
2726 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2727 if ( aMesh->_is_nil() )
2729 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2730 tr( "SMESH_BAD_SELECTION" ) );
2734 EmitSignalDeactivateDialog();
2735 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2736 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2738 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2741 case SMESHOp::OpOrientation:
2742 case SMESHOp::OpUnionOfTriangles:
2743 case SMESHOp::OpCuttingOfQuadrangles:
2744 case SMESHOp::OpSplitVolumes:
2748 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2752 if ( isStudyLocked() )
2755 EmitSignalDeactivateDialog();
2756 SMESHGUI_MultiEditDlg* aDlg = NULL;
2757 if ( theCommandID == SMESHOp::OpOrientation )
2758 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2759 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2760 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2761 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2762 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2764 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2769 case SMESHOp::OpSmoothing:
2771 if(isStudyLocked()) break;
2773 EmitSignalDeactivateDialog();
2774 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2777 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2781 case SMESHOp::OpExtrusion:
2783 if (isStudyLocked()) break;
2785 EmitSignalDeactivateDialog();
2786 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2788 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2792 case SMESHOp::OpExtrusionAlongAPath:
2794 if (isStudyLocked()) break;
2796 EmitSignalDeactivateDialog();
2797 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2799 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2803 case SMESHOp::OpRevolution:
2805 if(isStudyLocked()) break;
2807 EmitSignalDeactivateDialog();
2808 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2811 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2815 case SMESHOp::OpPatternMapping:
2817 if ( isStudyLocked() )
2821 EmitSignalDeactivateDialog();
2822 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2825 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2829 case SMESHOp::OpSplitBiQuadratic:
2830 case SMESHOp::OpConvertMeshToQuadratic:
2831 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2832 case SMESHOp::OpReorientFaces:
2833 case SMESHOp::OpCreateGeometryGroup:
2835 startOperation( theCommandID );
2838 case SMESHOp::OpCreateGroup:
2842 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2846 if(isStudyLocked()) break;
2847 EmitSignalDeactivateDialog();
2848 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2850 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2851 SALOME_ListIO selected;
2853 aSel->selectedObjects( selected );
2855 int nbSel = selected.Extent();
2857 // check if mesh is selected
2858 aMesh = SMESH::GetMeshByIO( selected.First() );
2860 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2865 case SMESHOp::OpConstructGroup:
2869 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2873 if(isStudyLocked()) break;
2874 EmitSignalDeactivateDialog();
2876 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2877 SALOME_ListIO selected;
2879 aSel->selectedObjects( selected );
2881 int nbSel = selected.Extent();
2883 // check if submesh is selected
2884 Handle(SALOME_InteractiveObject) IObject = selected.First();
2885 if (IObject->hasEntry()) {
2886 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
2888 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2889 if (!aSubMesh->_is_nil()) {
2891 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2892 // get submesh elements list by types
2893 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2894 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2895 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2896 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2897 // create group for each type o elements
2898 QString aName = IObject->getName();
2899 QStringList anEntryList;
2900 if (aNodes->length() > 0) {
2901 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2902 aGroup->Add(aNodes.inout());
2903 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2904 anEntryList.append( aSObject->GetID().c_str() );
2906 if (aEdges->length() > 0) {
2907 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2908 aGroup->Add(aEdges.inout());
2909 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2910 anEntryList.append( aSObject->GetID().c_str() );
2912 if (aFaces->length() > 0) {
2913 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2914 aGroup->Add(aFaces.inout());
2915 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2916 anEntryList.append( aSObject->GetID().c_str() );
2918 if (aVolumes->length() > 0) {
2919 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2920 aGroup->Add(aVolumes.inout());
2921 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2922 anEntryList.append( aSObject->GetID().c_str() );
2925 anApp->browseObjects( anEntryList );
2927 catch(const SALOME::SALOME_Exception & S_ex){
2928 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2935 SUIT_MessageBox::warning(desktop(),
2936 tr("SMESH_WRN_WARNING"),
2937 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2942 case SMESHOp::OpEditGroup:
2946 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2950 if(isStudyLocked()) break;
2951 EmitSignalDeactivateDialog();
2953 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2954 SALOME_ListIO selected;
2956 aSel->selectedObjects( selected );
2958 SALOME_ListIteratorOfListIO It (selected);
2959 int nbSelectedGroups = 0;
2960 for ( ; It.More(); It.Next() )
2962 SMESH::SMESH_GroupBase_var aGroup =
2963 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2964 if (!aGroup->_is_nil()) {
2966 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2970 if (nbSelectedGroups == 0)
2972 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2978 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
2980 if(isStudyLocked()) break;
2981 if (myState == 800) {
2982 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2983 if (aDlg) aDlg->onAdd();
2988 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
2990 if(isStudyLocked()) break;
2991 if (myState == 800) {
2992 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2993 if (aDlg) aDlg->onRemove();
2998 case SMESHOp::OpEditGeomGroupAsGroup:
3002 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3006 if(isStudyLocked()) break;
3007 EmitSignalDeactivateDialog();
3009 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3010 SALOME_ListIO selected;
3012 aSel->selectedObjects( selected );
3014 SALOME_ListIteratorOfListIO It (selected);
3015 for ( ; It.More(); It.Next() )
3017 SMESH::SMESH_GroupOnGeom_var aGroup =
3018 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3019 if (!aGroup->_is_nil()) {
3020 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3025 SMESH::SMESH_GroupOnFilter_var aGroup =
3026 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3027 if (!aGroup->_is_nil()) {
3028 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3036 case SMESHOp::OpUnionGroups:
3037 case SMESHOp::OpIntersectGroups:
3038 case SMESHOp::OpCutGroups:
3042 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3046 if ( isStudyLocked() )
3049 EmitSignalDeactivateDialog();
3051 SMESHGUI_GroupOpDlg* aDlg = 0;
3052 if ( theCommandID == SMESHOp::OpUnionGroups )
3053 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3054 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3055 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3057 aDlg = new SMESHGUI_CutGroupsDlg( this );
3064 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3066 if ( isStudyLocked() )
3069 EmitSignalDeactivateDialog();
3070 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3076 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3080 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3084 if ( isStudyLocked() )
3087 EmitSignalDeactivateDialog();
3089 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3093 case SMESHOp::OpMeshInformation:
3094 case SMESHOp::OpWhatIs:
3096 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3097 EmitSignalDeactivateDialog();
3098 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3099 SALOME_ListIO selected;
3101 aSel->selectedObjects( selected );
3103 if ( selected.Extent() > 1 ) { // a dlg for each IO
3104 SALOME_ListIteratorOfListIO It( selected );
3105 for ( ; It.More(); It.Next() ) {
3106 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3107 dlg->showInfo( It.Value() );
3112 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3118 case SMESHOp::OpFindElementByPoint:
3120 startOperation( theCommandID );
3124 case SMESHOp::OpEditHypothesis:
3126 if(isStudyLocked()) break;
3128 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3129 SALOME_ListIO selected;
3131 aSel->selectedObjects( selected );
3133 int nbSel = selected.Extent();
3136 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3137 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3139 if ( !aHypothesis->_is_nil() )
3141 SMESHGUI_GenericHypothesisCreator* aCreator =
3142 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3145 // set geometry of mesh and sub-mesh to aCreator
3146 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3147 if ( selected.Extent() == 1 )
3149 QString subGeomID, meshGeomID;
3150 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3151 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3153 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3154 aCreator->setShapeEntry( subGeomID );
3155 aCreator->setMainShapeEntry( meshGeomID );
3159 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3169 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3171 if(isStudyLocked()) break;
3172 SUIT_OverrideCursor wc;
3174 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3175 SALOME_ListIO selected;
3177 aSel->selectedObjects( selected, QString::null, false );
3179 SALOME_ListIteratorOfListIO It(selected);
3180 for (int i = 0; It.More(); It.Next(), i++) {
3181 Handle(SALOME_InteractiveObject) IObject = It.Value();
3182 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3185 aSel->setSelectedObjects( l1 );
3190 case SMESHOp::OpElem0D:
3191 case SMESHOp::OpBall:
3192 case SMESHOp::OpEdge:
3193 case SMESHOp::OpTriangle:
3194 case SMESHOp::OpQuadrangle:
3195 case SMESHOp::OpPolygon:
3196 case SMESHOp::OpTetrahedron:
3197 case SMESHOp::OpHexahedron:
3198 case SMESHOp::OpPentahedron:
3199 case SMESHOp::OpPyramid:
3200 case SMESHOp::OpHexagonalPrism:
3202 if(isStudyLocked()) break;
3204 EmitSignalDeactivateDialog();
3205 SMDSAbs_EntityType type = SMDSEntity_Edge;
3206 switch (theCommandID) {
3207 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3208 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3209 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3210 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3211 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3212 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3213 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3214 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3215 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3216 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3219 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3222 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3226 case SMESHOp::OpPolyhedron:
3228 if(isStudyLocked()) break;
3230 EmitSignalDeactivateDialog();
3231 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3234 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3238 case SMESHOp::OpQuadraticEdge:
3239 case SMESHOp::OpQuadraticTriangle:
3240 case SMESHOp::OpBiQuadraticTriangle:
3241 case SMESHOp::OpQuadraticQuadrangle:
3242 case SMESHOp::OpBiQuadraticQuadrangle:
3243 case SMESHOp::OpQuadraticPolygon:
3244 case SMESHOp::OpQuadraticTetrahedron:
3245 case SMESHOp::OpQuadraticPyramid:
3246 case SMESHOp::OpQuadraticPentahedron:
3247 case SMESHOp::OpBiQuadraticPentahedron:
3248 case SMESHOp::OpQuadraticHexahedron:
3249 case SMESHOp::OpTriQuadraticHexahedron:
3251 if(isStudyLocked()) break;
3253 EmitSignalDeactivateDialog();
3254 SMDSAbs_EntityType type = SMDSEntity_Last;
3256 switch (theCommandID) {
3257 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3258 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3259 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3260 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3261 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3262 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3263 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3264 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3265 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3266 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3267 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3268 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3271 if ( type != SMDSEntity_Last )
3272 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3275 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3276 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3280 case SMESHOp::OpRemoveNodes:
3282 if(isStudyLocked()) break;
3284 EmitSignalDeactivateDialog();
3285 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3288 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3289 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3293 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3295 if(isStudyLocked()) break;
3297 EmitSignalDeactivateDialog();
3298 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3302 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3303 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3307 case SMESHOp::OpClearMesh: {
3309 if(isStudyLocked()) break;
3311 SALOME_ListIO selected;
3312 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3313 aSel->selectedObjects( selected );
3315 SUIT_OverrideCursor wc;
3316 SALOME_ListIteratorOfListIO It (selected);
3317 for ( ; It.More(); It.Next() )
3319 Handle(SALOME_InteractiveObject) IOS = It.Value();
3320 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3321 if ( aMesh->_is_nil()) continue;
3324 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3325 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3326 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3327 SMESH::ModifiedMesh( aMeshSObj, false, true);
3328 // hide groups and submeshes
3329 _PTR(ChildIterator) anIter =
3330 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3331 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3333 _PTR(SObject) so = anIter->Value();
3334 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3337 catch (const SALOME::SALOME_Exception& S_ex){
3339 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3343 SMESH::UpdateView();
3347 case SMESHOp::OpRemoveOrphanNodes:
3349 if(isStudyLocked()) break;
3350 SALOME_ListIO selected;
3351 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3352 aSel->selectedObjects( selected );
3353 if ( selected.Extent() == 1 ) {
3354 Handle(SALOME_InteractiveObject) anIO = selected.First();
3355 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3356 if ( !aMesh->_is_nil() ) {
3357 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3358 tr( "SMESH_WARNING" ),
3359 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3360 SUIT_MessageBox::Yes |
3361 SUIT_MessageBox::No,
3362 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3365 SUIT_OverrideCursor wc;
3366 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3367 int removed = aMeshEditor->RemoveOrphanNodes();
3368 SUIT_MessageBox::information(SMESHGUI::desktop(),
3369 tr("SMESH_INFORMATION"),
3370 tr("NB_NODES_REMOVED").arg(removed));
3371 if ( removed > 0 ) {
3372 SMESH::UpdateView();
3373 SMESHGUI::Modified();
3376 catch (const SALOME::SALOME_Exception& S_ex) {
3377 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3386 case SMESHOp::OpRenumberingNodes:
3388 if(isStudyLocked()) break;
3390 EmitSignalDeactivateDialog();
3391 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3395 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3396 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3400 case SMESHOp::OpRenumberingElements:
3402 if(isStudyLocked()) break;
3404 EmitSignalDeactivateDialog();
3405 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3409 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3410 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3414 case SMESHOp::OpTranslation:
3416 if(isStudyLocked()) break;
3418 EmitSignalDeactivateDialog();
3419 ( new SMESHGUI_TranslationDlg( this ) )->show();
3422 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3423 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3427 case SMESHOp::OpRotation:
3429 if(isStudyLocked()) break;
3431 EmitSignalDeactivateDialog();
3432 ( new SMESHGUI_RotationDlg( this ) )->show();
3435 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3436 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3440 case SMESHOp::OpSymmetry:
3442 if(isStudyLocked()) break;
3444 EmitSignalDeactivateDialog();
3445 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3448 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3449 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3453 case SMESHOp::OpScale:
3455 if(isStudyLocked()) break;
3457 EmitSignalDeactivateDialog();
3458 ( new SMESHGUI_ScaleDlg( this ) )->show();
3461 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3462 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3467 case SMESHOp::OpSewing:
3469 if(isStudyLocked()) break;
3471 EmitSignalDeactivateDialog();
3472 ( new SMESHGUI_SewingDlg( this ) )->show();
3475 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3476 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3480 case SMESHOp::OpMergeNodes:
3482 if(isStudyLocked()) break;
3484 EmitSignalDeactivateDialog();
3485 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3488 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3489 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3493 case SMESHOp::OpMergeElements:
3495 if (isStudyLocked()) break;
3497 EmitSignalDeactivateDialog();
3498 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3500 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3501 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3506 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3507 startOperation( SMESHOp::OpMoveNode );
3510 case SMESHOp::OpDuplicateNodes:
3512 if(isStudyLocked()) break;
3514 EmitSignalDeactivateDialog();
3515 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3518 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3519 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3524 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3525 startOperation( SMESHOp::OpElem0DOnElemNodes );
3528 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3530 static QList<int> aTypes;
3531 if ( aTypes.isEmpty() )
3533 aTypes.append( SMESH::NODE );
3534 aTypes.append( SMESH::EDGE );
3535 aTypes.append( SMESH::FACE );
3536 aTypes.append( SMESH::VOLUME );
3538 if (!myFilterLibraryDlg)
3539 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3540 else if (myFilterLibraryDlg->isHidden())
3541 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3542 myFilterLibraryDlg->raise();
3546 case SMESHOp::OpFreeNode:
3547 case SMESHOp::OpEqualNode:
3548 case SMESHOp::OpNodeConnectivityNb:
3549 case SMESHOp::OpFreeEdge:
3550 case SMESHOp::OpFreeBorder:
3551 case SMESHOp::OpLength:
3552 case SMESHOp::OpConnection:
3553 case SMESHOp::OpEqualEdge:
3554 case SMESHOp::OpFreeFace:
3555 case SMESHOp::OpBareBorderFace:
3556 case SMESHOp::OpOverConstrainedFace:
3557 case SMESHOp::OpLength2D:
3558 case SMESHOp::OpDeflection2D:
3559 case SMESHOp::OpConnection2D:
3560 case SMESHOp::OpArea:
3561 case SMESHOp::OpTaper:
3562 case SMESHOp::OpAspectRatio:
3563 case SMESHOp::OpMinimumAngle:
3564 case SMESHOp::OpWarpingAngle:
3565 case SMESHOp::OpSkew:
3566 case SMESHOp::OpMaxElementLength2D:
3567 case SMESHOp::OpEqualFace:
3568 case SMESHOp::OpAspectRatio3D:
3569 case SMESHOp::OpVolume:
3570 case SMESHOp::OpMaxElementLength3D:
3571 case SMESHOp::OpBareBorderVolume:
3572 case SMESHOp::OpOverConstrainedVolume:
3573 case SMESHOp::OpEqualVolume:
3576 LightApp_SelectionMgr* mgr = selectionMgr();
3577 SALOME_ListIO selected; mgr->selectedObjects( selected );
3579 if( !selected.IsEmpty() ) {
3580 SUIT_OverrideCursor wc;
3581 ::Control( theCommandID );
3584 SUIT_MessageBox::warning(desktop(),
3585 tr( "SMESH_WRN_WARNING" ),
3586 tr( "SMESH_BAD_SELECTION" ) );
3590 SUIT_MessageBox::warning(desktop(),
3591 tr( "SMESH_WRN_WARNING" ),
3592 tr( "NOT_A_VTK_VIEWER" ) );
3595 case SMESHOp::OpOverallMeshQuality:
3596 OverallMeshQuality();
3598 case SMESHOp::OpNumberingNodes:
3600 SUIT_OverrideCursor wc;
3601 LightApp_SelectionMgr* mgr = selectionMgr();
3602 SALOME_ListIO selected; mgr->selectedObjects( selected );
3604 SALOME_ListIteratorOfListIO it(selected);
3605 for( ; it.More(); it.Next()) {
3606 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3607 if(anIObject->hasEntry()) {
3608 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3609 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3615 case SMESHOp::OpNumberingElements:
3617 SUIT_OverrideCursor wc;
3618 LightApp_SelectionMgr* mgr = selectionMgr();
3619 SALOME_ListIO selected; mgr->selectedObjects( selected );
3621 SALOME_ListIteratorOfListIO it(selected);
3622 for( ; it.More(); it.Next()) {
3623 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3624 if(anIObject->hasEntry())
3625 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3626 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3631 case SMESHOp::OpPropertiesLength:
3632 case SMESHOp::OpPropertiesArea:
3633 case SMESHOp::OpPropertiesVolume:
3634 case SMESHOp::OpMinimumDistance:
3635 case SMESHOp::OpBoundingBox:
3637 int page = SMESHGUI_MeasureDlg::MinDistance;
3638 if ( theCommandID == SMESHOp::OpBoundingBox )
3639 page = SMESHGUI_MeasureDlg::BoundingBox;
3640 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3641 page = SMESHGUI_MeasureDlg::Length;
3642 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3643 page = SMESHGUI_MeasureDlg::Area;
3644 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3645 page = SMESHGUI_MeasureDlg::Volume;
3647 EmitSignalDeactivateDialog();
3648 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3652 case SMESHOp::OpSortChild:
3658 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3659 //updateObjBrowser();
3663 //=============================================================================
3667 //=============================================================================
3668 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3673 //=============================================================================
3677 //=============================================================================
3678 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3683 //=============================================================================
3687 //=============================================================================
3688 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3693 //=============================================================================
3694 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3695 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3697 //=============================================================================
3698 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3699 SUIT_ViewWindow* wnd )
3701 if(theIO->hasEntry()){
3702 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3703 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3707 //=======================================================================
3708 // function : createSMESHAction
3710 //=======================================================================
3711 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3712 const int key, const bool toggle, const QString& shortcutAction )
3715 QWidget* parent = application()->desktop();
3716 SUIT_ResourceMgr* resMgr = resourceMgr();
3718 if ( !icon_id.isEmpty() )
3719 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3721 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3722 if ( !pix.isNull() )
3723 icon = QIcon( pix );
3725 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3726 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3727 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3729 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3730 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3733 //=======================================================================
3734 // function : createPopupItem
3736 //=======================================================================
3737 void SMESHGUI::createPopupItem( const int id,
3738 const QString& clients,
3739 const QString& types,
3740 const QString& theRule,
3743 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3744 popupMgr()->insert( action( id ), pId, 0 );
3746 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3747 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3748 QString rule = "(%1) and (%2) and (%3)";
3749 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3750 if( clients.isEmpty() )
3751 rule = rule.arg( QString( "true" ) );
3753 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3754 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3757 bool cont = myRules.contains( id );
3759 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3761 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3762 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3765 //=======================================================================
3766 // function : initialize
3768 //=======================================================================
3769 void SMESHGUI::initialize( CAM_Application* app )
3771 SalomeApp_Module::initialize( app );
3773 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3775 /* Automatic Update flag */
3776 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3778 // ----- create actions --------------
3780 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3781 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
3782 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3783 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
3785 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
3787 createSMESHAction( SMESHOp::OpImportSAUV, "IMPORT_SAUV" );
3788 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
3789 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
3790 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
3791 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
3793 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
3795 createSMESHAction( SMESHOp::OpPopupImportSAUV, "IMPORT_SAUV" );
3796 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
3798 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
3799 createSMESHAction( SMESHOp::OpExportMED, "MED" );
3800 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
3801 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
3803 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
3805 createSMESHAction( SMESHOp::OpExportSAUV, "SAUV");
3806 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
3807 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
3808 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
3809 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
3810 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
3812 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
3814 createSMESHAction( SMESHOp::OpPopupExportSAUV, "SAUV");
3815 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
3816 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
3817 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3818 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
3819 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3820 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3821 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
3822 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
3823 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
3824 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3825 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
3826 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
3827 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
3828 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3829 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
3830 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
3831 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3832 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
3833 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3834 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3835 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3836 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
3837 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
3838 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
3839 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
3840 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
3841 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
3842 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
3843 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
3844 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
3845 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3846 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
3848 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3849 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3850 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
3851 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3852 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3853 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
3854 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
3855 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3856 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3857 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3858 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3859 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3860 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
3861 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3862 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
3863 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
3864 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
3865 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
3866 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
3867 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
3868 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3869 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3870 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3871 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3872 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3873 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3874 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3875 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3876 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
3878 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
3879 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
3880 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3881 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
3882 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
3883 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3884 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
3885 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
3886 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
3887 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
3888 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
3889 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
3890 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
3891 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3892 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3893 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3894 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3895 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3896 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3897 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
3898 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3899 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3900 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3901 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
3902 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3903 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3905 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3906 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3907 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3908 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
3910 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3911 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3913 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3914 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
3915 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3916 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
3917 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3918 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
3919 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3920 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3921 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3922 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
3923 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
3924 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3925 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
3926 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
3927 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
3928 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3929 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
3930 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
3931 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
3932 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3933 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
3934 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
3935 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3936 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3938 createSMESHAction( SMESHOp::OpReset, "RESET" );
3939 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
3940 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
3941 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
3942 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
3943 #ifndef DISABLE_PLOT2DVIEWER
3944 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
3946 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
3947 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
3948 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
3949 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
3950 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
3951 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3952 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
3953 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3954 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3955 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
3956 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
3957 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
3958 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
3960 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
3961 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
3963 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
3964 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
3965 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
3966 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
3967 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
3968 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
3969 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
3970 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
3971 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
3973 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3974 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3975 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3976 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3977 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3979 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
3980 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
3981 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
3983 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
3985 QList<int> aCtrlActions;
3986 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
3987 << SMESHOp::OpNodeConnectivityNb // node controls
3988 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
3989 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
3990 << SMESHOp::OpDeflection2D
3991 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
3992 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
3993 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
3994 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
3995 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
3996 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
3997 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
3998 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
3999 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4000 aCtrlGroup->setExclusive( true );
4001 for( int i = 0; i < aCtrlActions.size(); i++ )
4002 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4004 // ----- create menu --------------
4005 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4006 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4007 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4008 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4009 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4010 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4011 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4012 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4014 createMenu( separator(), fileId );
4016 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4017 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4018 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4019 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4020 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4021 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4022 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4023 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4024 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4025 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4026 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4027 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4028 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4030 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4031 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4032 createMenu( SMESHOp::OpImportMED, importId, -1 );
4033 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4035 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4037 createMenu( SMESHOp::OpImportSAUV, importId, -1 );
4038 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4039 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4040 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4041 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4042 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4044 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4046 createMenu( SMESHOp::OpExportSAUV, exportId, -1 );
4047 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4048 createMenu( separator(), fileId, 10 );
4050 createMenu( SMESHOp::OpDelete, editId, -1 );
4052 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4054 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4055 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4056 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4057 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4058 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4059 createMenu( separator(), meshId, -1 );
4060 createMenu( SMESHOp::OpCompute, meshId, -1 );
4061 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4062 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4063 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4064 createMenu( separator(), meshId, -1 );
4065 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4066 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4067 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4068 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4069 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4070 createMenu( separator(), meshId, -1 );
4071 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4072 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4073 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4074 createMenu( separator(), meshId, -1 );
4075 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4076 createMenu( separator(), meshId, -1 );
4077 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4078 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4079 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4080 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4081 createMenu( separator(), meshId, -1 );
4083 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4084 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4085 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4086 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4087 createMenu( SMESHOp::OpLength, edgeId, -1 );
4088 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4089 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4090 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4091 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4092 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4093 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4094 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4095 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4096 createMenu( SMESHOp::OpArea, faceId, -1 );
4097 createMenu( SMESHOp::OpTaper, faceId, -1 );
4098 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4099 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4100 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4101 createMenu( SMESHOp::OpSkew, faceId, -1 );
4102 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4103 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4104 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4105 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4106 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4107 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4108 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4109 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4110 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4111 createMenu( separator(), ctrlId, -1 );
4112 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4113 createMenu( separator(), ctrlId, -1 );
4114 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4116 createMenu( SMESHOp::OpNode, addId, -1 );
4117 createMenu( SMESHOp::OpElem0D, addId, -1 );
4118 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4119 createMenu( SMESHOp::OpBall, addId, -1 );
4120 createMenu( SMESHOp::OpEdge, addId, -1 );
4121 createMenu( SMESHOp::OpTriangle, addId, -1 );
4122 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4123 createMenu( SMESHOp::OpPolygon, addId, -1 );
4124 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4125 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4126 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4127 createMenu( SMESHOp::OpPyramid, addId, -1 );
4128 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4129 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4130 createMenu( separator(), addId, -1 );
4131 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4132 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4133 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4134 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4135 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4136 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4137 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4138 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4139 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4140 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4141 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4142 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4144 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4145 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4146 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4147 createMenu( separator(), removeId, -1 );
4148 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4149 createMenu( separator(), removeId, -1 );
4150 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4152 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4153 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4155 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4156 createMenu( SMESHOp::OpRotation, transfId, -1 );
4157 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4158 createMenu( SMESHOp::OpScale, transfId, -1 );
4159 createMenu( SMESHOp::OpSewing, transfId, -1 );
4160 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4161 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4162 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4164 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4165 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4166 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4167 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4168 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4169 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4170 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4171 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4172 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4173 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4174 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4175 createMenu( SMESHOp::OpExtrusionAlongAPath , modifyId, -1 );
4176 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4177 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4178 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4179 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4181 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4182 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4183 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4184 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4185 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4186 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4188 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4189 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4190 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4191 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4193 // ----- create toolbars --------------
4194 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ),
4195 info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ),
4196 groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ),
4197 ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ),
4198 ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ),
4199 ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ),
4200 ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ),
4201 addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ),
4202 addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ),
4203 remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ),
4204 //renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ),
4205 transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
4206 modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ),
4207 measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ),
4208 dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4210 createTool( SMESHOp::OpCreateMesh, meshTb );
4211 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4212 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4213 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4214 createTool( SMESHOp::OpCopyMesh, meshTb );
4215 createTool( separator(), meshTb );
4216 createTool( SMESHOp::OpCompute, meshTb );
4217 createTool( SMESHOp::OpPreCompute, meshTb );
4218 createTool( SMESHOp::OpEvaluate, meshTb );
4219 createTool( SMESHOp::OpMeshOrder, meshTb );
4221 createTool( SMESHOp::OpCreateGroup, groupTb );
4222 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4223 createTool( SMESHOp::OpConstructGroup, groupTb );
4224 createTool( SMESHOp::OpEditGroup, groupTb );
4226 createTool( SMESHOp::OpMeshInformation, info );
4227 //createTool( SMESHOp::OpStdInfo, meshTb );
4228 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4229 createTool( SMESHOp::OpFindElementByPoint, info );
4231 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4232 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4233 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4235 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4236 createTool( SMESHOp::OpLength, ctrl1dTb );
4237 createTool( SMESHOp::OpConnection, ctrl1dTb );
4238 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4240 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4241 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4242 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4243 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4244 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4245 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4246 createTool( SMESHOp::OpArea, ctrl2dTb );
4247 createTool( SMESHOp::OpTaper, ctrl2dTb );
4248 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4249 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4250 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4251 createTool( SMESHOp::OpSkew, ctrl2dTb );
4252 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4253 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4254 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4256 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4257 createTool( SMESHOp::OpVolume, ctrl3dTb );
4258 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4259 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4260 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4261 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4263 createTool( SMESHOp::OpNode, addElemTb );
4264 createTool( SMESHOp::OpElem0D, addElemTb );
4265 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4266 createTool( SMESHOp::OpBall, addElemTb );
4267 createTool( SMESHOp::OpEdge, addElemTb );
4268 createTool( SMESHOp::OpTriangle, addElemTb );
4269 createTool( SMESHOp::OpQuadrangle, addElemTb );
4270 createTool( SMESHOp::OpPolygon, addElemTb );
4271 createTool( SMESHOp::OpTetrahedron, addElemTb );
4272 createTool( SMESHOp::OpHexahedron, addElemTb );
4273 createTool( SMESHOp::OpPentahedron, addElemTb );
4274 createTool( SMESHOp::OpPyramid, addElemTb );
4275 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4276 createTool( SMESHOp::OpPolyhedron, addElemTb );
4278 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4279 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4280 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4281 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4282 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4283 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4284 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4285 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4286 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4287 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4288 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4289 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4291 createTool( SMESHOp::OpRemoveNodes, remTb );
4292 createTool( SMESHOp::OpRemoveElements, remTb );
4293 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4294 createTool( SMESHOp::OpClearMesh, remTb );
4296 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4297 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4299 createTool( SMESHOp::OpTranslation, transformTb );
4300 createTool( SMESHOp::OpRotation, transformTb );
4301 createTool( SMESHOp::OpSymmetry, transformTb );
4302 createTool( SMESHOp::OpScale, transformTb );
4303 createTool( SMESHOp::OpSewing, transformTb );
4304 createTool( SMESHOp::OpMergeNodes, transformTb );
4305 createTool( SMESHOp::OpMergeElements, transformTb );
4306 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4308 createTool( SMESHOp::OpMoveNode, modifyTb );
4309 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4310 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4311 createTool( SMESHOp::OpOrientation, modifyTb );
4312 createTool( SMESHOp::OpReorientFaces, modifyTb );
4313 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4314 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4315 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4316 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4317 createTool( SMESHOp::OpSmoothing, modifyTb );
4318 createTool( SMESHOp::OpExtrusion, modifyTb );
4319 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4320 createTool( SMESHOp::OpRevolution, modifyTb );
4321 createTool( SMESHOp::OpPatternMapping, modifyTb );
4322 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4323 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4325 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4327 createTool( SMESHOp::OpUpdate, dispModeTb );
4329 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4330 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4334 OB = "'ObjectBrowser'",
4335 View = "'" + SVTK_Viewer::Type() + "'",
4337 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4338 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4339 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4340 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4341 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4342 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4343 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4344 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4345 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4346 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4347 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4348 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4350 mesh_part = mesh + " " + subMesh + " " + group,
4351 mesh_group = mesh + " " + group,
4352 mesh_submesh = mesh + " " + subMesh,
4353 hyp_alg = hypo + " " + algo;
4355 // popup for object browser
4357 isInvisible("not( isVisible )"),
4358 isEmpty("numberOfNodes = 0"),
4359 isNotEmpty("numberOfNodes <> 0"),
4361 // has nodes, edges, etc in VISIBLE! actor
4362 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4363 hasElems("(count( elemTypes ) > 0)"),
4364 hasDifferentElems("(count( elemTypes ) > 1)"),
4365 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4366 hasBalls("({'BallElem'} in elemTypes)"),
4367 hasElems0d("({'Elem0d'} in elemTypes)"),
4368 hasEdges("({'Edge'} in elemTypes)"),
4369 hasFaces("({'Face'} in elemTypes)"),
4370 hasVolumes("({'Volume'} in elemTypes)"),
4371 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4373 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4374 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4375 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4376 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4377 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4378 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4380 popupMgr()->insert( separator(), -1, 0 );
4381 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && isComputable" );
4382 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && isComputable" );
4383 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && isPreComputable" );
4384 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && isComputable" );
4385 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && isComputable && hasGeomReference" );
4386 createPopupItem( SMESHOp::OpUpdate, OB, mesh_part );
4387 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4388 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1" );
4389 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4390 popupMgr()->insert( separator(), -1, 0 );
4391 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4392 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4393 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4394 popupMgr()->insert( separator(), -1, 0 );
4395 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4396 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4397 popupMgr()->insert( separator(), -1, 0 );
4398 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh );
4399 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4400 popupMgr()->insert( separator(), -1, 0 );
4401 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4402 //popupMgr()->insert( separator(), -1, 0 );
4404 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4405 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4406 QString only_one_2D = only_one_non_empty + " && dim>1";
4408 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4409 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4410 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4411 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4413 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4415 createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
4416 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4417 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4418 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4419 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4421 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4422 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4423 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4424 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4426 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4428 createPopupItem( SMESHOp::OpPopupImportSAUV, OB, smesh, "", anId );
4429 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4430 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4431 popupMgr()->insert( separator(), -1, 0 );
4434 createPopupItem( SMESHOp::OpEditGroup, View, group );
4435 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4436 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4438 popupMgr()->insert( separator(), -1, 0 );
4439 createPopupItem( SMESHOp::OpUpdate, View, mesh_part );
4440 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4441 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4442 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
4443 popupMgr()->insert( separator(), -1, 0 );
4445 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4446 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4447 popupMgr()->insert( separator(), -1, 0 );
4449 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4450 QString aType = QString( "%1type in {%2}" ).arg( lc );
4451 aType = aType.arg( mesh_part );
4452 QString aMeshInVTK = aClient + "&&" + aType;
4454 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4455 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4456 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4458 //-------------------------------------------------
4460 //-------------------------------------------------
4461 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4463 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4464 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4465 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4467 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4468 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4469 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4471 popupMgr()->insert( separator(), -1, -1 );
4473 //-------------------------------------------------
4475 //-------------------------------------------------
4476 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4478 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4479 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4480 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4482 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4483 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4484 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4486 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4487 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4488 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4490 popupMgr()->insert( separator(), anId, -1 );
4492 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4493 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4494 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4496 //-------------------------------------------------
4498 //-------------------------------------------------
4499 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4501 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4503 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4504 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4505 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4507 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4508 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4509 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4511 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4512 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4513 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4515 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4516 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4517 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4519 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4520 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4521 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4523 popupMgr()->insert( separator(), anId, -1 );
4525 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4526 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4528 popupMgr()->insert( separator(), anId, -1 );
4530 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4531 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4534 //-------------------------------------------------
4535 // Representation of the 2D Quadratic elements
4536 //-------------------------------------------------
4537 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4538 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4539 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4540 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4542 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4543 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4544 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4546 //-------------------------------------------------
4547 // Orientation of faces
4548 //-------------------------------------------------
4549 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4550 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4551 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4553 //-------------------------------------------------
4555 //-------------------------------------------------
4556 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4557 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4559 //-------------------------------------------------
4561 //-------------------------------------------------
4562 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4563 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4565 //-------------------------------------------------
4567 //-------------------------------------------------
4569 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4570 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4571 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4572 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4574 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4576 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4577 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4579 popupMgr()->insert( separator(), anId, -1 );
4581 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4583 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4584 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4585 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4587 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4588 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4589 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4591 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4592 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4593 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4595 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4597 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4598 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4599 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4601 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4602 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4603 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4605 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4606 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4607 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4608 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4609 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4610 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4612 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4614 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4615 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4616 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4618 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4619 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4620 QtxPopupMgr::VisibleRule );
4621 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4623 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4624 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4625 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4627 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4628 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4629 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4631 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4632 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4633 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4635 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4636 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4637 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4639 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4640 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4641 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4643 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4644 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4645 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4647 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4648 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4649 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4651 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4652 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4653 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4655 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4656 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4657 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4659 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4660 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4661 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4663 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4664 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4665 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4667 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4668 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4669 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4671 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
4672 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
4673 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
4675 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4677 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4678 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4679 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4681 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4682 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4683 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4685 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4686 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4687 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4689 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
4690 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4691 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4693 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
4694 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4695 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4697 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
4698 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4699 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4701 popupMgr()->insert( separator(), anId, -1 );
4703 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
4704 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4705 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
4706 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
4707 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4709 popupMgr()->insert( separator(), anId, -1 );
4711 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4713 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
4714 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4716 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
4717 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4718 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
4720 #ifndef DISABLE_PLOT2DVIEWER
4721 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
4722 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4725 //-------------------------------------------------
4727 //-------------------------------------------------
4728 popupMgr()->insert( separator(), -1, -1 );
4729 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4730 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4731 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
4732 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4734 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
4735 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4737 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
4738 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4740 popupMgr()->insert( separator(), -1, -1 );
4742 //-------------------------------------------------
4744 //-------------------------------------------------
4745 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
4746 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4748 popupMgr()->insert( separator(), -1, -1 );
4750 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
4751 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4752 popupMgr()->insert( separator(), -1, -1 );
4754 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4755 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4757 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4758 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4761 //================================================================================
4763 * \brief Return true if SMESH or GEOM objects are selected.
4764 * Is called form LightApp_Module::activateModule() which clear selection if
4765 * not isSelectionCompatible()
4767 //================================================================================
4769 bool SMESHGUI::isSelectionCompatible()
4771 bool isCompatible = true;
4772 SALOME_ListIO selected;
4773 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4774 Sel->selectedObjects( selected );
4776 SALOME_ListIteratorOfListIO It( selected );
4777 for ( ; isCompatible && It.More(); It.Next())
4779 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4780 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4782 return isCompatible;
4786 bool SMESHGUI::reusableOperation( const int id )
4788 // compute, evaluate and precompute are not reusable operations
4789 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
4792 bool SMESHGUI::activateModule( SUIT_Study* study )
4794 bool res = SalomeApp_Module::activateModule( study );
4796 setMenuShown( true );
4797 setToolShown( true );
4799 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4800 PyGILState_STATE gstate = PyGILState_Ensure();
4801 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4802 if ( !pluginsmanager ) {
4806 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
4811 PyGILState_Release(gstate);
4812 // end of SMESH plugins loading
4814 // Reset actions accelerator keys
4815 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
4817 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4818 GetSMESHGen()->UpdateStudy();
4820 // get all view currently opened in the study and connect their signals to
4821 // the corresponding slots of the class.
4822 SUIT_Desktop* aDesk = study->application()->desktop();
4824 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4825 SUIT_ViewWindow* wnd;
4826 foreach ( wnd, wndList )
4830 Py_XDECREF(pluginsmanager);
4834 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4836 setMenuShown( false );
4837 setToolShown( false );
4839 EmitSignalCloseAllDialogs();
4841 // Unset actions accelerator keys
4842 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
4844 return SalomeApp_Module::deactivateModule( study );
4847 void SMESHGUI::studyClosed( SUIT_Study* s )
4851 SMESH::RemoveVisuData();
4852 SalomeApp_Module::studyClosed( s );
4855 void SMESHGUI::OnGUIEvent()
4857 const QObject* obj = sender();
4858 if ( !obj || !obj->inherits( "QAction" ) )
4860 int id = actionId((QAction*)obj);
4865 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4867 if ( CORBA::is_nil( myComponentSMESH ) )
4869 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4870 return aGUI.myComponentSMESH;
4872 return myComponentSMESH;
4875 QString SMESHGUI::engineIOR() const
4877 CORBA::ORB_var anORB = getApp()->orb();
4878 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4879 return QString( anIOR.in() );
4882 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4884 SalomeApp_Module::contextMenuPopup( client, menu, title );
4886 selectionMgr()->selectedObjects( lst );
4887 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4888 Handle(SALOME_InteractiveObject) io = lst.First();
4889 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4890 _PTR(Study) study = appStudy->studyDS();
4891 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4893 QString aName = QString( SMESH::fromUtf8(obj->GetName()) );
4894 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4895 aName.remove( (aName.length() - 1), 1 );
4901 LightApp_Selection* SMESHGUI::createSelection() const
4903 return new SMESHGUI_Selection();
4906 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4908 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4909 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
4910 #ifndef DISABLE_PYCONSOLE
4911 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4915 void SMESHGUI::viewManagers( QStringList& list ) const
4917 list.append( SVTK_Viewer::Type() );
4920 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4922 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4923 SMESH::UpdateSelectionProp( this );
4925 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4926 for(int i = 0; i < aViews.count() ; i++){
4927 SUIT_ViewWindow *sf = aViews[i];
4930 EmitSignalActivatedViewManager();
4934 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4936 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4937 myClippingPlaneInfoMap.erase( theViewManager );
4940 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4942 theActor->AddObserver( SMESH::DeleteActorEvent,
4943 myEventCallbackCommand.GetPointer(),
4947 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4948 unsigned long theEvent,
4949 void* theClientData,
4952 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4953 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
4954 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4955 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4956 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4957 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4958 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4959 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4960 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4961 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4962 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4963 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4964 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4965 if( anActor == *anIter3 ) {
4966 anActorList.erase( anIter3 );
4977 void SMESHGUI::createPreferences()
4979 // General tab ------------------------------------------------------------------------
4980 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4982 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4983 setPreferenceProperty( autoUpdate, "columns", 2 );
4984 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4985 setPreferenceProperty( lim, "min", 0 );
4986 setPreferenceProperty( lim, "max", 100000000 );
4987 setPreferenceProperty( lim, "step", 1000 );
4988 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4989 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
4991 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
4992 setPreferenceProperty( dispgroup, "columns", 2 );
4993 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4995 modes.append( tr("MEN_WIRE") );
4996 modes.append( tr("MEN_SHADE") );
4997 modes.append( tr("MEN_NODES") );
4998 modes.append( tr("MEN_SHRINK") );
4999 QList<QVariant> indices;
5000 indices.append( 0 );
5001 indices.append( 1 );
5002 indices.append( 2 );
5003 indices.append( 3 );
5004 setPreferenceProperty( dispmode, "strings", modes );
5005 setPreferenceProperty( dispmode, "indexes", indices );
5007 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5008 setPreferenceProperty( arcgroup, "columns", 2 );
5009 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5010 QStringList quadraticModes;
5011 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5012 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5014 indices.append( 0 );
5015 indices.append( 1 );
5016 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5017 setPreferenceProperty( quadraticmode, "indexes", indices );
5019 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5020 "SMESH", "max_angle" );
5021 setPreferenceProperty( maxAngle, "min", 1 );
5022 setPreferenceProperty( maxAngle, "max", 90 );
5024 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5025 setPreferenceProperty( qaGroup, "columns", 2 );
5026 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5027 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5028 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5029 setPreferenceProperty( prec, "min", 0 );
5030 setPreferenceProperty( prec, "max", 100 );
5031 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5032 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5033 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5034 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5035 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5038 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5039 setPreferenceProperty( exportgroup, "columns", 2 );
5040 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5041 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5042 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5044 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5045 setPreferenceProperty( computeGroup, "columns", 2 );
5046 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5048 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5049 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5050 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5052 indices.append( 0 );
5053 indices.append( 1 );
5054 indices.append( 2 );
5055 setPreferenceProperty( notifyMode, "strings", modes );
5056 setPreferenceProperty( notifyMode, "indexes", indices );
5058 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5059 setPreferenceProperty( infoGroup, "columns", 2 );
5060 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5062 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5063 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5065 indices.append( 0 );
5066 indices.append( 1 );
5067 setPreferenceProperty( elemInfo, "strings", modes );
5068 setPreferenceProperty( elemInfo, "indexes", indices );
5069 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5070 setPreferenceProperty( nodesLim, "min", 0 );
5071 setPreferenceProperty( nodesLim, "max", 10000000 );
5072 setPreferenceProperty( nodesLim, "step", 10000 );
5073 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5074 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5075 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5076 setPreferenceProperty( ctrlLim, "min", 0 );
5077 setPreferenceProperty( ctrlLim, "max", 10000000 );
5078 setPreferenceProperty( ctrlLim, "step", 1000 );
5079 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5080 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5081 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5082 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5083 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5085 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5086 setPreferenceProperty( segGroup, "columns", 2 );
5087 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5088 "SMESH", "segmentation" );
5089 setPreferenceProperty( segLen, "min", 1 );
5090 setPreferenceProperty( segLen, "max", 10000000 );
5091 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5092 "SMESH", "nb_segments_per_edge" );
5093 setPreferenceProperty( nbSeg, "min", 1 );
5094 setPreferenceProperty( nbSeg, "max", 10000000 );
5096 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5097 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5098 "SMESH", "forget_mesh_on_hyp_modif" );
5101 // Quantities with individual precision settings
5102 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5103 setPreferenceProperty( precGroup, "columns", 2 );
5105 const int nbQuantities = 6;
5106 int precs[nbQuantities], ii = 0;
5107 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5108 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5109 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5110 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5111 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5112 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5113 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5114 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5115 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5116 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5117 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5118 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5120 // Set property for precision value for spinboxes
5121 for ( ii = 0; ii < nbQuantities; ii++ ){
5122 setPreferenceProperty( precs[ii], "min", -14 );
5123 setPreferenceProperty( precs[ii], "max", 14 );
5124 setPreferenceProperty( precs[ii], "precision", 2 );
5127 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5128 setPreferenceProperty( previewGroup, "columns", 2 );
5129 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5130 setPreferenceProperty( chunkSize, "min", 1 );
5131 setPreferenceProperty( chunkSize, "max", 1000 );
5132 setPreferenceProperty( chunkSize, "step", 50 );
5134 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5135 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5137 // Mesh tab ------------------------------------------------------------------------
5138 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5139 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5140 setPreferenceProperty( nodeGroup, "columns", 3 );
5142 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5144 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5146 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5147 QList<QVariant> aMarkerTypeIndicesList;
5148 QList<QVariant> aMarkerTypeIconsList;
5149 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5150 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5151 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5152 aMarkerTypeIndicesList << i;
5153 aMarkerTypeIconsList << pixmap;
5155 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5156 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5158 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5160 QList<QVariant> aMarkerScaleIndicesList;
5161 QStringList aMarkerScaleValuesList;
5162 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5163 aMarkerScaleIndicesList << i;
5164 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5165 aMarkerScaleValuesList << QString::number( i );
5167 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5168 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5170 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5171 //setPreferenceProperty( elemGroup, "columns", 2 );
5173 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5174 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5175 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5176 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5177 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5178 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5179 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5180 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5181 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5184 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5185 setPreferenceProperty( grpGroup, "columns", 2 );
5187 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5188 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5190 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5191 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5192 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5193 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5194 double ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5195 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5196 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5197 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5198 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5199 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5200 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5201 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5202 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5203 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5205 setPreferenceProperty( size0d, "min", 1 );
5206 setPreferenceProperty( size0d, "max", 10 );
5208 // setPreferenceProperty( ballSize, "min", 1 );
5209 // setPreferenceProperty( ballSize, "max", 10 );
5211 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5212 setPreferenceProperty( ballDiameter, "max", 1e9 );
5213 setPreferenceProperty( ballDiameter, "step", 0.1 );
5215 setPreferenceProperty( ballScale, "min", 1e-2 );
5216 setPreferenceProperty( ballScale, "max", 1e7 );
5217 setPreferenceProperty( ballScale, "step", 0.5 );
5219 setPreferenceProperty( elemW, "min", 1 );
5220 setPreferenceProperty( elemW, "max", 5 );
5222 setPreferenceProperty( outW, "min", 1 );
5223 setPreferenceProperty( outW, "max", 5 );
5225 setPreferenceProperty( shrink, "min", 0 );
5226 setPreferenceProperty( shrink, "max", 100 );
5228 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5229 setPreferenceProperty( numGroup, "columns", 2 );
5231 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5232 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5234 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5235 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5237 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5238 setPreferenceProperty( orientGroup, "columns", 1 );
5240 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5241 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5243 setPreferenceProperty( orientScale, "min", 0.05 );
5244 setPreferenceProperty( orientScale, "max", 0.5 );
5245 setPreferenceProperty( orientScale, "step", 0.05 );
5247 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5249 // Selection tab ------------------------------------------------------------------------
5250 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5252 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5253 setPreferenceProperty( selGroup, "columns", 2 );
5255 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5256 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5258 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5259 setPreferenceProperty( preGroup, "columns", 2 );
5261 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5263 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5264 setPreferenceProperty( precSelGroup, "columns", 2 );
5266 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5267 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5268 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5270 // Scalar Bar tab ------------------------------------------------------------------------
5271 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5272 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5273 setPreferenceProperty( fontGr, "columns", 2 );
5275 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5276 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5278 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5279 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5281 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5282 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5284 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5285 setPreferenceProperty( numcol, "min", 2 );
5286 setPreferenceProperty( numcol, "max", 256 );
5288 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5289 setPreferenceProperty( numlab, "min", 2 );
5290 setPreferenceProperty( numlab, "max", 65 );
5292 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5293 setPreferenceProperty( orientGr, "columns", 2 );
5294 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5295 QStringList orients;
5296 orients.append( tr( "SMESH_VERTICAL" ) );
5297 orients.append( tr( "SMESH_HORIZONTAL" ) );
5298 indices.clear(); indices.append( 0 ); indices.append( 1 );
5299 setPreferenceProperty( orient, "strings", orients );
5300 setPreferenceProperty( orient, "indexes", indices );
5302 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5303 setPreferenceProperty( posVSizeGr, "columns", 2 );
5304 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5305 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5306 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5307 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5308 setPreferenceProperty( xv, "step", 0.1 );
5309 setPreferenceProperty( xv, "min", 0.0 );
5310 setPreferenceProperty( xv, "max", 1.0 );
5311 setPreferenceProperty( yv, "step", 0.1 );
5312 setPreferenceProperty( yv, "min", 0.0 );
5313 setPreferenceProperty( yv, "max", 1.0 );
5314 setPreferenceProperty( wv, "step", 0.1 );
5315 setPreferenceProperty( wv, "min", 0.0 );
5316 setPreferenceProperty( wv, "max", 1.0 );
5317 setPreferenceProperty( hv, "min", 0.0 );
5318 setPreferenceProperty( hv, "max", 1.0 );
5319 setPreferenceProperty( hv, "step", 0.1 );
5321 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5322 setPreferenceProperty( posHSizeGr, "columns", 2 );
5323 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5324 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5325 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5326 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5327 setPreferenceProperty( xv, "min", 0.0 );
5328 setPreferenceProperty( xv, "max", 1.0 );
5329 setPreferenceProperty( xv, "step", 0.1 );
5330 setPreferenceProperty( xh, "min", 0.0 );
5331 setPreferenceProperty( xh, "max", 1.0 );
5332 setPreferenceProperty( xh, "step", 0.1 );
5333 setPreferenceProperty( yh, "min", 0.0 );
5334 setPreferenceProperty( yh, "max", 1.0 );
5335 setPreferenceProperty( yh, "step", 0.1 );
5336 setPreferenceProperty( wh, "min", 0.0 );
5337 setPreferenceProperty( wh, "max", 1.0 );
5338 setPreferenceProperty( wh, "step", 0.1 );
5339 setPreferenceProperty( hh, "min", 0.0 );
5340 setPreferenceProperty( hh, "max", 1.0 );
5341 setPreferenceProperty( hh, "step", 0.1 );
5343 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5344 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5345 setPreferenceProperty( distributionGr, "columns", 3 );
5347 types.append( tr( "SMESH_MONOCOLOR" ) );
5348 types.append( tr( "SMESH_MULTICOLOR" ) );
5349 indices.clear(); indices.append( 0 ); indices.append( 1 );
5350 setPreferenceProperty( coloringType, "strings", types );
5351 setPreferenceProperty( coloringType, "indexes", indices );
5352 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5356 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5358 if ( sect=="SMESH" ) {
5359 float sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5360 float aTol = 1.00000009999999;
5361 std::string aWarning;
5362 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5364 if ( name== "selection_object_color" ||
5365 name=="selection_element_color" ||
5366 name== "highlight_color" ||
5367 name=="selection_precision_node" ||
5368 name=="selection_precision_element" ||
5369 name=="selection_precision_object" )
5371 SMESH::UpdateSelectionProp( this );
5373 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5375 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5376 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5377 if ( sbX1+sbW > aTol ) {
5378 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5381 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5382 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5385 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5387 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5388 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5389 if ( sbY1 + sbH > aTol ) {
5390 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5391 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5392 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5395 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5397 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5398 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5399 if ( sbX1 + sbW > aTol ) {
5400 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5403 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5404 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5407 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5409 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5410 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5411 if ( sbY1 + sbH > aTol ) {
5412 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5415 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5416 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5419 else if ( name == "segmentation" )
5421 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5422 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5424 else if ( name == "nb_segments_per_edge" )
5426 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5427 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5429 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5431 QString val = aResourceMgr->stringValue( "SMESH", name );
5432 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5434 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5436 SMESH::UpdateFontProp( this );
5438 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5440 SMESH::UpdateFontProp( this );
5443 if ( aWarning.size() != 0 ) {
5444 aWarning += "The default values are applied instead.";
5445 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5446 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5447 QObject::tr(aWarning.c_str()));
5452 //================================================================================
5454 * \brief Update something in accordance with update flags
5455 * \param theFlags - update flags
5457 * Update viewer or/and object browser etc. in accordance with update flags ( see
5458 * LightApp_UpdateFlags enumeration ).
5460 //================================================================================
5461 void SMESHGUI::update( const int flags )
5463 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5464 SMESH::UpdateView();
5466 SalomeApp_Module::update( flags );
5469 //================================================================================
5471 * \brief Set default selection mode
5473 * SLOT called when operation committed. Sets default selection mode
5475 //================================================================================
5476 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5478 SVTK_ViewWindow* vtkWnd =
5479 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5481 vtkWnd->SetSelectionMode( ActorSelection );
5484 //================================================================================
5486 * \brief Set default selection mode
5488 * SLOT called when operation aborted. Sets default selection mode
5490 //================================================================================
5491 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5493 SVTK_ViewWindow* vtkWnd =
5494 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5496 vtkWnd->SetSelectionMode( ActorSelection );
5499 //================================================================================
5501 * \brief Creates operation with given identifier
5502 * \param id - identifier of operation to be started
5503 * \return Pointer on created operation or NULL if operation is not created
5505 * Virtual method redefined from the base class creates operation with given id.
5506 * It is called called automatically from startOperation method of base class.
5508 //================================================================================
5509 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5511 LightApp_Operation* op = 0;
5512 // to do : create operation here
5515 case SMESHOp::OpSplitBiQuadratic:
5516 op = new SMESHGUI_SplitBiQuadOp();
5518 case SMESHOp::OpConvertMeshToQuadratic:
5519 op = new SMESHGUI_ConvToQuadOp();
5521 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5522 op = new SMESHGUI_Make2DFrom3DOp();
5524 case SMESHOp::OpReorientFaces:
5525 op = new SMESHGUI_ReorientFacesOp();
5527 case SMESHOp::OpCreateMesh:
5528 op = new SMESHGUI_MeshOp( true, true );
5530 case SMESHOp::OpCreateSubMesh:
5531 op = new SMESHGUI_MeshOp( true, false );
5533 case SMESHOp::OpEditMeshOrSubMesh:
5534 case SMESHOp::OpEditMesh:
5535 case SMESHOp::OpEditSubMesh:
5536 op = new SMESHGUI_MeshOp( false );
5538 case SMESHOp::OpCompute:
5539 case SMESHOp::OpComputeSubMesh:
5540 op = new SMESHGUI_ComputeOp();
5542 case SMESHOp::OpPreCompute:
5543 op = new SMESHGUI_PrecomputeOp();
5545 case SMESHOp::OpEvaluate:
5546 op = new SMESHGUI_EvaluateOp();
5548 case SMESHOp::OpMeshOrder:
5549 op = new SMESHGUI_MeshOrderOp();
5551 case SMESHOp::OpCreateGeometryGroup:
5552 op = new SMESHGUI_GroupOnShapeOp();
5554 case SMESHOp::OpFindElementByPoint:
5555 op = new SMESHGUI_FindElemByPointOp();
5557 case SMESHOp::OpMoveNode: // Make mesh pass through point
5558 op = new SMESHGUI_MakeNodeAtPointOp();
5560 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5561 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5568 op = SalomeApp_Module::createOperation( id );
5572 //================================================================================
5574 * \brief Stops current operations and starts a given one
5575 * \param id - The id of the operation to start
5577 //================================================================================
5579 void SMESHGUI::switchToOperation(int id)
5581 activeStudy()->abortAllOperations();
5582 startOperation( id );
5585 LightApp_Displayer* SMESHGUI::displayer()
5588 myDisplayer = new SMESHGUI_Displayer( getApp() );
5592 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5595 int aTolerance = 64;
5596 int anIterations = 0;
5602 if( anIterations % aPeriod == 0 )
5605 if( aTolerance < 1 )
5609 aHue = (int)( 360.0 * rand() / RAND_MAX );
5612 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5613 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5614 for( ; it != itEnd; ++it )
5616 SALOMEDS::Color anAutoColor = *it;
5617 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5620 aQColor.getHsv( &h, &s, &v );
5621 if( abs( h - aHue ) < aTolerance )
5633 aColor.setHsv( aHue, 255, 255 );
5635 SALOMEDS::Color aSColor;
5636 aSColor.R = aColor.redF();
5637 aSColor.G = aColor.greenF();
5638 aSColor.B = aColor.blueF();
5643 const char* gSeparator = "_"; // character used to separate parameter names
5644 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5645 const char* gPathSep = "|"; // character used to separate paths
5648 * \brief Store visual parameters
5650 * This method is called just before the study document is saved.
5651 * Store visual parameters in AttributeParameter attribue(s)
5653 void SMESHGUI::storeVisualParameters (int savePoint)
5656 Kernel_Utils::Localizer loc;
5658 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5659 if (!appStudy || !appStudy->studyDS())
5661 _PTR(Study) studyDS = appStudy->studyDS();
5663 // componentName is used for encoding of entries when storing them in IParameters
5664 std::string componentName = myComponentSMESH->ComponentDataType();
5665 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5666 //if (!aSComponent) return;
5669 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5670 componentName.c_str(),
5672 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5674 // store custom markers
5675 if( !myMarkerMap.empty() )
5677 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
5678 for( ; anIter != myMarkerMap.end(); anIter++ )
5680 int anId = anIter->first;
5681 VTK::MarkerData aMarkerData = anIter->second;
5682 std::string aMarkerFileName = aMarkerData.first;
5683 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5684 if( aMarkerTexture.size() < 3 )
5685 continue; // should contain at least width, height and the first value
5687 QString aPropertyName( "texture" );
5688 aPropertyName += gSeparator;
5689 aPropertyName += QString::number( anId );
5691 QString aPropertyValue = aMarkerFileName.c_str();
5692 aPropertyValue += gPathSep;
5694 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5695 ushort aWidth = *aTextureIter++;
5696 ushort aHeight = *aTextureIter++;
5697 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5698 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5699 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5700 aPropertyValue += QString::number( *aTextureIter );
5702 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5706 // viewers counters are used for storing view_numbers in IParameters
5709 // main cycle to store parameters of displayed objects
5710 QList<SUIT_ViewManager*> lst;
5711 QList<SUIT_ViewManager*>::Iterator it;
5712 getApp()->viewManagers(lst);
5713 for (it = lst.begin(); it != lst.end(); it++)
5715 SUIT_ViewManager* vman = *it;
5716 QString vType = vman->getType();
5718 // saving VTK actors properties
5719 if (vType == SVTK_Viewer::Type())
5721 // store the clipping planes attached to the view manager
5722 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5723 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5724 if( anIter != myClippingPlaneInfoMap.end() )
5725 aClippingPlaneInfoList = anIter->second;
5727 if( !aClippingPlaneInfoList.empty() ) {
5728 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5729 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5731 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5732 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5734 QString aPropertyName( "ClippingPlane" );
5735 aPropertyName += gSeparator;
5736 aPropertyName += QString::number( vtkViewers );
5737 aPropertyName += gSeparator;
5738 aPropertyName += QString::number( anId );
5740 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5741 aPropertyValue += gDigitsSep;
5742 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5743 aPropertyValue += gDigitsSep;
5744 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5745 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5746 aPropertyValue += gDigitsSep;
5747 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5748 aPropertyValue += gDigitsSep;
5749 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5750 aPropertyValue += gDigitsSep;
5751 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5752 aPropertyValue += gDigitsSep;
5753 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5754 aPropertyValue += gDigitsSep;
5755 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5756 aPropertyValue += gDigitsSep;
5757 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5759 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5760 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5761 aPropertyValue += gDigitsSep;
5762 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5763 aPropertyValue += gDigitsSep;
5764 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5765 aPropertyValue += gDigitsSep;
5766 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5769 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5773 QVector<SUIT_ViewWindow*> views = vman->getViews();
5774 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5776 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5778 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5779 vtkActorCollection* allActors = aCopy.GetActors();
5780 allActors->InitTraversal();
5781 while (vtkActor* actor = allActors->GetNextActor())
5783 if (actor->GetVisibility()) // store only visible actors
5785 SMESH_Actor* aSmeshActor = 0;
5786 if (actor->IsA("SMESH_Actor"))
5787 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5788 if (aSmeshActor && aSmeshActor->hasIO())
5790 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5793 // entry is "encoded" = it does NOT contain component address,
5794 // since it is a subject to change on next component loading
5795 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5797 std::string param, vtkParam = vType.toLatin1().data();
5798 vtkParam += gSeparator;
5799 vtkParam += QString::number(vtkViewers).toLatin1().data();
5800 vtkParam += gSeparator;
5803 param = vtkParam + "Visibility";
5804 ip->setParameter(entry, param, "On");
5807 param = vtkParam + "Representation";
5808 ip->setParameter(entry, param, QString::number
5809 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5812 param = vtkParam + "IsShrunk";
5813 ip->setParameter(entry, param, QString::number
5814 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5816 // Displayed entities
5817 unsigned int aMode = aSmeshActor->GetEntityMode();
5818 bool isE = aMode & SMESH_Actor::eEdges;
5819 bool isF = aMode & SMESH_Actor::eFaces;
5820 bool isV = aMode & SMESH_Actor::eVolumes;
5821 bool is0d = aMode & SMESH_Actor::e0DElements;
5822 bool isB = aMode & SMESH_Actor::eBallElem;
5824 QString modeStr ("e");
5825 modeStr += gDigitsSep; modeStr += QString::number(isE);
5826 modeStr += gDigitsSep; modeStr += "f";
5827 modeStr += gDigitsSep; modeStr += QString::number(isF);
5828 modeStr += gDigitsSep; modeStr += "v";
5829 modeStr += gDigitsSep; modeStr += QString::number(isV);
5830 modeStr += gDigitsSep; modeStr += "0d";
5831 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5832 modeStr += gDigitsSep; modeStr += "b";
5833 modeStr += gDigitsSep; modeStr += QString::number(isB);
5835 param = vtkParam + "Entities";
5836 ip->setParameter(entry, param, modeStr.toLatin1().data());
5842 aSmeshActor->GetSufaceColor(r, g, b, delta);
5843 QStringList colorStr;
5844 colorStr << "surface";
5845 colorStr << QString::number(r);
5846 colorStr << QString::number(g);
5847 colorStr << QString::number(b);
5849 colorStr << "backsurface";
5850 colorStr << QString::number(delta);
5852 aSmeshActor->GetVolumeColor(r, g, b, delta);
5853 colorStr << "volume";
5854 colorStr << QString::number(r);
5855 colorStr << QString::number(g);
5856 colorStr << QString::number(b);
5857 colorStr << QString::number(delta);
5859 aSmeshActor->GetEdgeColor(r, g, b);
5861 colorStr << QString::number(r);
5862 colorStr << QString::number(g);
5863 colorStr << QString::number(b);
5865 aSmeshActor->GetNodeColor(r, g, b);
5867 colorStr << QString::number(r);
5868 colorStr << QString::number(g);
5869 colorStr << QString::number(b);
5871 aSmeshActor->GetOutlineColor(r, g, b);
5872 colorStr << "outline";
5873 colorStr << QString::number(r);
5874 colorStr << QString::number(g);
5875 colorStr << QString::number(b);
5877 aSmeshActor->Get0DColor(r, g, b);
5878 colorStr << "elem0d";
5879 colorStr << QString::number(r);
5880 colorStr << QString::number(g);
5881 colorStr << QString::number(b);
5883 aSmeshActor->GetBallColor(r, g, b);
5885 colorStr << QString::number(r);
5886 colorStr << QString::number(g);
5887 colorStr << QString::number(b);
5889 aSmeshActor->GetFacesOrientationColor(r, g, b);
5890 colorStr << "orientation";
5891 colorStr << QString::number(r);
5892 colorStr << QString::number(g);
5893 colorStr << QString::number(b);
5895 param = vtkParam + "Colors";
5896 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5899 QStringList sizeStr;
5901 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5902 sizeStr << "outline";
5903 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5904 sizeStr << "elem0d";
5905 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5907 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5908 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
5909 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
5910 sizeStr << "shrink";
5911 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5912 sizeStr << "orientation";
5913 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5914 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5916 param = vtkParam + "Sizes";
5917 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5922 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5923 if( aMarkerType == VTK::MT_USER ) {
5924 markerStr += "custom";
5925 markerStr += gDigitsSep;
5926 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5930 markerStr += gDigitsSep;
5931 markerStr += QString::number( (int)aMarkerType );
5932 markerStr += gDigitsSep;
5933 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5936 param = vtkParam + "PointMarker";
5937 ip->setParameter(entry, param, markerStr.toLatin1().data());
5940 param = vtkParam + "Opacity";
5941 ip->setParameter(entry, param,
5942 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5945 param = vtkParam + "ClippingPlane";
5947 if( !aClippingPlaneInfoList.empty() ) {
5948 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5949 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5951 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5952 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5953 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5954 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5955 if( aSmeshActor == *anIter2 ) {
5956 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5957 QString::number( anId ).toLatin1().constData() );
5964 ip->setParameter( entry, param, "Off" );
5965 } // if (io->hasEntry())
5966 } // SMESH_Actor && hasIO
5968 } // while.. actors traversal
5972 } // if (SVTK view model)
5973 } // for (viewManagers)
5976 // data structures for clipping planes processing
5980 bool isOpenGLClipping;
5981 vtkIdType RelativeOrientation;
5984 int AbsoluteOrientation;
5985 double X, Y, Z, Dx, Dy, Dz;
5987 typedef std::list<TPlaneData> TPlaneDataList;
5988 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5990 typedef std::list<vtkActor*> TActorList;
5993 TActorList ActorList;
5994 SUIT_ViewManager* ViewManager;
5996 typedef std::list<TPlaneInfo> TPlaneInfoList;
5997 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6000 * \brief Restore visual parameters
6002 * This method is called after the study document is opened.
6003 * Restore visual parameters from AttributeParameter attribue(s)
6005 void SMESHGUI::restoreVisualParameters (int savePoint)
6008 Kernel_Utils::Localizer loc;
6010 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6011 if (!appStudy || !appStudy->studyDS())
6013 _PTR(Study) studyDS = appStudy->studyDS();
6015 // componentName is used for encoding of entries when storing them in IParameters
6016 std::string componentName = myComponentSMESH->ComponentDataType();
6017 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
6018 //if (!aSComponent) return;
6021 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6022 componentName.c_str(),
6024 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6026 // restore custom markers and map of clipping planes
6027 TPlaneDataMap aPlaneDataMap;
6029 std::vector<std::string> properties = ip->getProperties();
6030 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6032 std::string property = *propIt;
6033 QString aPropertyName( property.c_str() );
6034 QString aPropertyValue( ip->getProperty( property ).c_str() );
6036 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6037 if( aPropertyNameList.isEmpty() )
6040 QString aPropertyType = aPropertyNameList[0];
6041 if( aPropertyType == "texture" )
6043 if( aPropertyNameList.size() != 2 )
6047 int anId = aPropertyNameList[1].toInt( &ok );
6048 if( !ok || anId < 1 )
6051 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6052 if( aPropertyValueList.size() != 2 )
6055 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6056 QString aMarkerTextureString = aPropertyValueList[1];
6057 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6058 if( aMarkerTextureStringList.size() != 3 )
6062 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6067 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6071 VTK::MarkerTexture aMarkerTexture;
6072 aMarkerTexture.push_back( aWidth );
6073 aMarkerTexture.push_back( aHeight );
6075 QString aMarkerTextureData = aMarkerTextureStringList[2];
6076 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6078 QChar aChar = aMarkerTextureData.at( i );
6079 if( aChar.isDigit() )
6080 aMarkerTexture.push_back( aChar.digitValue() );
6083 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6085 else if( aPropertyType == "ClippingPlane" )
6087 if( aPropertyNameList.size() != 3 )
6091 int aViewId = aPropertyNameList[1].toInt( &ok );
6092 if( !ok || aViewId < 0 )
6096 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6097 if( !ok || aClippingPlaneId < 0 )
6100 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6101 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6104 TPlaneData aPlaneData;
6105 aPlaneData.AbsoluteOrientation = false;
6106 aPlaneData.RelativeOrientation = 0;
6107 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6108 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6109 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6111 aPlaneData.Id = aClippingPlaneId;
6114 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6119 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6123 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6126 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6131 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6136 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6141 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6146 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6151 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6156 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6160 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6162 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6167 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6172 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6177 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6182 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6183 aPlaneDataList.push_back( aPlaneData );
6187 TPlaneInfoMap aPlaneInfoMap;
6189 std::vector<std::string> entries = ip->getEntries();
6191 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6193 // entry is a normal entry - it should be "decoded" (setting base address of component)
6194 QString entry (ip->decodeEntry(*entIt).c_str());
6196 // Check that the entry corresponds to a real object in the Study
6197 // as the object may be deleted or modified after the visual state is saved.
6198 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6199 if (!so) continue; //Skip the not existent entry
6201 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6202 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6204 std::vector<std::string>::iterator namesIt = paramNames.begin();
6205 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6207 // actors are stored in a map after displaying of them for
6208 // quicker access in the future: map < viewID to actor >
6209 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6211 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6213 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6214 // '_' is used as separator and should not be used in viewer type or parameter names.
6215 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6216 if (lst.size() != 3)
6219 QString viewerTypStr = lst[0];
6220 QString viewIndexStr = lst[1];
6221 QString paramNameStr = lst[2];
6224 int viewIndex = viewIndexStr.toUInt(&ok);
6225 if (!ok) // bad conversion of view index to integer
6229 if (viewerTypStr == SVTK_Viewer::Type())
6231 SMESH_Actor* aSmeshActor = 0;
6232 if (vtkActors.IsBound(viewIndex))
6233 aSmeshActor = vtkActors.Find(viewIndex);
6235 QList<SUIT_ViewManager*> lst;
6236 getApp()->viewManagers(viewerTypStr, lst);
6238 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6239 SUIT_ViewManager* vman = NULL;
6240 if (viewIndex >= 0 && viewIndex < lst.count())
6241 vman = lst.at(viewIndex);
6243 if (paramNameStr == "Visibility")
6245 if (!aSmeshActor && displayer() && vman)
6247 SUIT_ViewModel* vmodel = vman->getViewModel();
6248 // SVTK view model can be casted to SALOME_View
6249 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6251 // store displayed actor in a temporary map for quicker
6252 // access later when restoring other parameters
6253 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6254 vtkRenderer* Renderer = vtkView->getRenderer();
6255 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6256 vtkActorCollection* theActors = aCopy.GetActors();
6257 theActors->InitTraversal();
6258 bool isFound = false;
6259 vtkActor *ac = theActors->GetNextActor();
6260 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6261 if (ac->IsA("SMESH_Actor")) {
6262 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6263 if (aGeomAc->hasIO()) {
6264 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6265 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6267 vtkActors.Bind(viewIndex, aGeomAc);
6273 } // if (paramNameStr == "Visibility")
6276 // the rest properties "work" with SMESH_Actor
6279 QString val ((*valuesIt).c_str());
6282 if (paramNameStr == "Representation") {
6283 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6286 else if (paramNameStr == "IsShrunk") {
6288 if (!aSmeshActor->IsShrunk())
6289 aSmeshActor->SetShrink();
6292 if (aSmeshActor->IsShrunk())
6293 aSmeshActor->UnShrink();
6296 // Displayed entities
6297 else if (paramNameStr == "Entities") {
6298 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6299 int aEntityMode = SMESH_Actor::eAllEntity;
6300 for ( int i = 0; i < mode.count(); i+=2 ) {
6301 if ( i < mode.count()-1 ) {
6302 QString type = mode[i];
6303 bool val = mode[i+1].toInt();
6304 if ( type == "e" && !val )
6305 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6306 else if ( type == "f" && !val )
6307 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6308 else if ( type == "v" && !val )
6309 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6310 else if ( type == "0d" && !val )
6311 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6312 else if ( type == "b" && !val )
6313 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6316 aSmeshActor->SetEntityMode( aEntityMode );
6319 else if (paramNameStr == "Colors") {
6320 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6327 QColor outlineColor;
6328 QColor orientationColor;
6334 // below lines are required to get default values for delta coefficients
6335 // of backface color for faces and color of reversed volumes
6336 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6337 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6338 for ( int i = 0; i < colors.count(); i++ ) {
6339 QString type = colors[i];
6340 if ( type == "surface" ) {
6341 // face color is set by 3 values r:g:b, where
6342 // - r,g,b - is rgb color components
6343 if ( i+1 >= colors.count() ) break; // format error
6344 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6345 if ( i+2 >= colors.count() ) break; // format error
6346 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6347 if ( i+3 >= colors.count() ) break; // format error
6348 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6349 faceColor.setRgbF( r, g, b );
6352 else if ( type == "backsurface" ) {
6353 // backface color can be defined in several ways
6354 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6355 // - in latest versions, it is set as delta coefficient
6356 bool rgbOk = false, deltaOk;
6357 if ( i+1 >= colors.count() ) break; // format error
6358 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6359 int delta = colors[i+1].toInt( &deltaOk );
6361 if ( i+1 < colors.count() ) // index is shifted to 1
6362 g = colors[i+1].toDouble( &rgbOk );
6363 if ( rgbOk ) i++; // shift index
6364 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6365 b = colors[i+1].toDouble( &rgbOk );
6367 // - as currently there's no way to set directly backsurface color as it was before,
6368 // we ignore old dump where r,g,b triple was set
6369 // - also we check that delta parameter is set properly
6370 if ( !rgbOk && deltaOk )
6373 else if ( type == "volume" ) {
6374 // volume color is set by 4 values r:g:b:delta, where
6375 // - r,g,b - is a normal volume rgb color components
6376 // - delta - is a reversed volume color delta coefficient
6377 if ( i+1 >= colors.count() ) break; // format error
6378 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6379 if ( i+2 >= colors.count() ) break; // format error
6380 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6381 if ( i+3 >= colors.count() ) break; // format error
6382 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6383 if ( i+4 >= colors.count() ) break; // format error
6384 int delta = colors[i+4].toInt( &bOk );
6385 if ( !bOk ) break; // format error
6386 volumeColor.setRgbF( r, g, b );
6390 else if ( type == "edge" ) {
6391 // edge color is set by 3 values r:g:b, where
6392 // - r,g,b - is rgb color components
6393 if ( i+1 >= colors.count() ) break; // format error
6394 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6395 if ( i+2 >= colors.count() ) break; // format error
6396 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6397 if ( i+3 >= colors.count() ) break; // format error
6398 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6399 edgeColor.setRgbF( r, g, b );
6402 else if ( type == "node" ) {
6403 // node color is set by 3 values r:g:b, where
6404 // - r,g,b - is rgb color components
6405 if ( i+1 >= colors.count() ) break; // format error
6406 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6407 if ( i+2 >= colors.count() ) break; // format error
6408 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6409 if ( i+3 >= colors.count() ) break; // format error
6410 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6411 nodeColor.setRgbF( r, g, b );
6414 else if ( type == "elem0d" ) {
6415 // 0d element color is set by 3 values r:g:b, where
6416 // - r,g,b - is rgb color components
6417 if ( i+1 >= colors.count() ) break; // format error
6418 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6419 if ( i+2 >= colors.count() ) break; // format error
6420 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6421 if ( i+3 >= colors.count() ) break; // format error
6422 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6423 elem0dColor.setRgbF( r, g, b );
6426 else if ( type == "ball" ) {
6427 // ball color is set by 3 values r:g:b, where
6428 // - r,g,b - is rgb color components
6429 if ( i+1 >= colors.count() ) break; // format error
6430 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6431 if ( i+2 >= colors.count() ) break; // format error
6432 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6433 if ( i+3 >= colors.count() ) break; // format error
6434 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6435 ballColor.setRgbF( r, g, b );
6438 else if ( type == "outline" ) {
6439 // outline color is set by 3 values r:g:b, where
6440 // - r,g,b - is rgb color components
6441 if ( i+1 >= colors.count() ) break; // format error
6442 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6443 if ( i+2 >= colors.count() ) break; // format error
6444 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6445 if ( i+3 >= colors.count() ) break; // format error
6446 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6447 outlineColor.setRgbF( r, g, b );
6450 else if ( type == "orientation" ) {
6451 // orientation color is set by 3 values r:g:b, where
6452 // - r,g,b - is rgb color components
6453 if ( i+1 >= colors.count() ) break; // format error
6454 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6455 if ( i+2 >= colors.count() ) break; // format error
6456 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6457 if ( i+3 >= colors.count() ) break; // format error
6458 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6459 orientationColor.setRgbF( r, g, b );
6464 if ( nodeColor.isValid() )
6465 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6467 if ( edgeColor.isValid() )
6468 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6470 if ( faceColor.isValid() )
6471 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6473 if ( volumeColor.isValid() )
6474 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6475 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6476 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6478 if ( elem0dColor.isValid() )
6479 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6481 if ( ballColor.isValid() )
6482 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6484 if ( outlineColor.isValid() )
6485 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6486 // orientation color
6487 if ( orientationColor.isValid() )
6488 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6491 else if (paramNameStr == "Sizes") {
6492 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6495 int outlineWidth = -1;
6496 int elem0dSize = -1;
6497 //int ballSize = -1;
6498 double ballDiameter = -1.0;
6499 double ballScale = -1.0;
6500 double shrinkSize = -1;
6501 double orientationSize = -1;
6502 bool orientation3d = false;
6503 for ( int i = 0; i < sizes.count(); i++ ) {
6504 QString type = sizes[i];
6505 if ( type == "line" ) {
6506 // line (wireframe) width is given as single integer value
6507 if ( i+1 >= sizes.count() ) break; // format error
6508 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6512 if ( type == "outline" ) {
6513 // outline width is given as single integer value
6514 if ( i+1 >= sizes.count() ) break; // format error
6515 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6519 else if ( type == "elem0d" ) {
6520 // 0d element size is given as single integer value
6521 if ( i+1 >= sizes.count() ) break; // format error
6522 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6526 else if ( type == "ball" ) {
6527 // balls are specified by two values: size:scale, where
6528 // - size - is a integer value specifying size
6529 // - scale - is a double value specifying scale factor
6530 if ( i+1 >= sizes.count() ) break; // format error
6531 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6532 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6533 if ( i+2 >= sizes.count() ) break; // format error
6534 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6540 else if ( type == "shrink" ) {
6541 // shrink factor is given as single floating point value
6542 if ( i+1 >= sizes.count() ) break; // format error
6543 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6547 else if ( type == "orientation" ) {
6548 // orientation vectors are specified by two values size:3d, where
6549 // - size - is a floating point value specifying scale factor
6550 // - 3d - is a boolean
6551 if ( i+1 >= sizes.count() ) break; // format error
6552 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6553 if ( i+2 >= sizes.count() ) break; // format error
6554 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6555 orientationSize = v1;
6556 orientation3d = (bool)v2;
6560 // line (wireframe) width
6561 if ( lineWidth > 0 )
6562 aSmeshActor->SetLineWidth( lineWidth );
6564 if ( outlineWidth > 0 )
6565 aSmeshActor->SetOutlineWidth( outlineWidth );
6566 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6567 aSmeshActor->SetOutlineWidth( lineWidth );
6569 if ( elem0dSize > 0 )
6570 aSmeshActor->Set0DSize( elem0dSize );
6572 /*if ( ballSize > 0 )
6573 aSmeshActor->SetBallSize( ballSize );*/
6575 if ( ballDiameter > 0 )
6576 aSmeshActor->SetBallSize( ballDiameter );
6578 if ( ballScale > 0.0 )
6579 aSmeshActor->SetBallScale( ballScale );
6581 if ( shrinkSize > 0 )
6582 aSmeshActor->SetShrinkFactor( shrinkSize );
6583 // orientation vectors
6584 if ( orientationSize > 0 ) {
6585 aSmeshActor->SetFacesOrientationScale( orientationSize );
6586 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6590 else if (paramNameStr == "PointMarker") {
6591 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6592 if( data.count() >= 2 ) {
6594 int aParam1 = data[1].toInt( &ok );
6596 if( data[0] == "std" && data.count() == 3 ) {
6597 int aParam2 = data[2].toInt( &ok );
6598 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6600 else if( data[0] == "custom" ) {
6601 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
6602 if( markerIt != myMarkerMap.end() ) {
6603 VTK::MarkerData aMarkerData = markerIt->second;
6604 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6611 else if (paramNameStr == "Opacity") {
6612 aSmeshActor->SetOpacity(val.toFloat());
6615 else if (paramNameStr.startsWith("ClippingPlane")) {
6616 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6617 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6618 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6619 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6620 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6621 // new format - val looks like "Off" or "0" (plane id)
6622 // (note: in new format "Off" value is used only for consistency,
6623 // so it is processed together with values in old format)
6624 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6625 if( anIsOldFormat ) {
6626 if (paramNameStr == "ClippingPlane1" || val == "Off")
6627 aSmeshActor->RemoveAllClippingPlanes();
6629 QList<SUIT_ViewManager*> lst;
6630 getApp()->viewManagers(viewerTypStr, lst);
6631 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6632 if (viewIndex >= 0 && viewIndex < lst.count()) {
6633 SUIT_ViewManager* vman = lst.at(viewIndex);
6634 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6636 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6638 SMESH::TActorList anActorList;
6639 anActorList.push_back( aSmeshActor );
6640 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6641 aPlane->myViewWindow = vtkView;
6642 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6643 aPlane->PlaneMode = aMode;
6644 bool isOpenGLClipping = ( bool )vals[1].toInt();
6645 aPlane->IsOpenGLClipping = isOpenGLClipping;
6646 if ( aMode == SMESH::Absolute ) {
6647 aPlane->myAbsoluteOrientation = vals[2].toInt();
6648 aPlane->X = vals[3].toFloat();
6649 aPlane->Y = vals[4].toFloat();
6650 aPlane->Z = vals[5].toFloat();
6651 aPlane->Dx = vals[6].toFloat();
6652 aPlane->Dy = vals[7].toFloat();
6653 aPlane->Dz = vals[8].toFloat();
6655 else if ( aMode == SMESH::Relative ) {
6656 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6657 aPlane->myDistance = vals[3].toFloat();
6658 aPlane->myAngle[0] = vals[4].toFloat();
6659 aPlane->myAngle[1] = vals[5].toFloat();
6663 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6664 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6665 aClippingPlaneInfo.Plane = aPlane;
6666 aClippingPlaneInfo.ActorList = anActorList;
6667 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6675 int aPlaneId = val.toInt( &ok );
6676 if( ok && aPlaneId >= 0 ) {
6677 bool anIsDefinedPlane = false;
6678 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6679 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6680 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6681 TPlaneInfo& aPlaneInfo = *anIter;
6682 if( aPlaneInfo.PlaneId == aPlaneId ) {
6683 aPlaneInfo.ActorList.push_back( aSmeshActor );
6684 anIsDefinedPlane = true;
6688 if( !anIsDefinedPlane ) {
6689 TPlaneInfo aPlaneInfo;
6690 aPlaneInfo.PlaneId = aPlaneId;
6691 aPlaneInfo.ActorList.push_back( aSmeshActor );
6692 aPlaneInfo.ViewManager = vman;
6694 // to make the list sorted by plane id
6695 anIter = aPlaneInfoList.begin();
6696 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6697 const TPlaneInfo& aPlaneInfoRef = *anIter;
6698 if( aPlaneInfoRef.PlaneId > aPlaneId )
6701 aPlaneInfoList.insert( anIter, aPlaneInfo );
6706 } // if (aSmeshActor)
6707 } // other parameters than Visibility
6709 } // for names/parameters iterator
6710 } // for entries iterator
6712 // take into account planes with empty list of actors referred to them
6713 QList<SUIT_ViewManager*> aVMList;
6714 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6716 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6717 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6718 int aViewId = aPlaneDataIter->first;
6719 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6720 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6722 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6724 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6725 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6726 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6727 const TPlaneData& aPlaneData = *anIter2;
6728 int aPlaneId = aPlaneData.Id;
6730 bool anIsFound = false;
6731 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6732 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6733 const TPlaneInfo& aPlaneInfo = *anIter3;
6734 if( aPlaneInfo.PlaneId == aPlaneId ) {
6741 TPlaneInfo aPlaneInfo; // ActorList field is empty
6742 aPlaneInfo.PlaneId = aPlaneId;
6743 aPlaneInfo.ViewManager = aViewManager;
6745 // to make the list sorted by plane id
6746 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6747 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6748 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6749 if( aPlaneInfoRef.PlaneId > aPlaneId )
6752 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6758 // add clipping planes to actors according to the restored parameters
6759 // and update the clipping plane map
6760 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6761 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6762 int aViewId = anIter1->first;
6763 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6765 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6766 if( anIter2 == aPlaneDataMap.end() )
6768 const TPlaneDataList& aPlaneDataList = anIter2->second;
6770 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6771 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6772 const TPlaneInfo& aPlaneInfo = *anIter3;
6773 int aPlaneId = aPlaneInfo.PlaneId;
6774 const TActorList& anActorList = aPlaneInfo.ActorList;
6775 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6779 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6783 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6785 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6786 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6787 const TPlaneData& aPlaneData = *anIter4;
6788 if( aPlaneData.Id == aPlaneId ) {
6789 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6790 aPlane->myViewWindow = aViewWindow;
6791 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6792 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6793 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6794 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6795 aPlane->X = aPlaneData.X;
6796 aPlane->Y = aPlaneData.Y;
6797 aPlane->Z = aPlaneData.Z;
6798 aPlane->Dx = aPlaneData.Dx;
6799 aPlane->Dy = aPlaneData.Dy;
6800 aPlane->Dz = aPlaneData.Dz;
6802 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6803 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6804 aPlane->myDistance = aPlaneData.Distance;
6805 aPlane->myAngle[0] = aPlaneData.Angle[0];
6806 aPlane->myAngle[1] = aPlaneData.Angle[1];
6809 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6810 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6811 aClippingPlaneInfo.Plane = aPlane;
6812 aClippingPlaneInfo.ActorList = anActorList;
6813 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6824 // update all VTK views
6825 QList<SUIT_ViewManager*> lst;
6826 getApp()->viewManagers(lst);
6827 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6828 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6829 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6830 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6831 // set OpenGL clipping planes
6832 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6833 vtkActorCollection* anAllActors = aCopy.GetActors();
6834 anAllActors->InitTraversal();
6835 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6836 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6837 anActor->SetOpenGLClippingPlane();
6839 vtkView->getRenderer()->ResetCameraClippingRange();
6846 \brief Adds preferences for dfont of VTK viewer
6848 \param pIf group identifier
6849 \param param parameter
6850 \return identifier of preferences
6852 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6854 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6856 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6859 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6860 fam.append( tr( "SMESH_FONT_COURIER" ) );
6861 fam.append( tr( "SMESH_FONT_TIMES" ) );
6863 setPreferenceProperty( tfont, "fonts", fam );
6865 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6866 if ( needSize ) f = f | QtxFontEdit::Size;
6867 setPreferenceProperty( tfont, "features", f );
6873 \brief Actions after hypothesis edition
6874 Updates object browser after hypothesis edition
6876 void SMESHGUI::onHypothesisEdit( int result )
6879 SMESHGUI::Modified();
6880 updateObjBrowser( true );
6884 \brief Actions after choosing menu of control modes
6885 Updates control mode actions according to current selection
6887 void SMESHGUI::onUpdateControlActions()
6889 SALOME_ListIO selected;
6890 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
6891 aSel->selectedObjects( selected );
6893 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
6894 if ( selected.Extent() ) {
6895 if ( selected.First()->hasEntry() ) {
6896 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
6897 aControl = anActor->GetControlMode();
6898 SALOME_ListIteratorOfListIO it(selected);
6899 for ( it.Next(); it.More(); it.Next() ) {
6900 Handle(SALOME_InteractiveObject) anIO = it.Value();
6901 if ( anIO->hasEntry() ) {
6902 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
6903 if ( aControl != anActor->GetControlMode() ) {
6904 aControl = SMESH_Actor::eNone;
6914 int anAction = ActionToControl( aControl, true );
6916 action( anAction )->setChecked( true );
6918 QMenu* send = (QMenu*)sender();
6919 QList<QAction*> actions = send->actions();
6920 for ( int i = 0; i < actions.size(); i++ )
6921 actions[i]->setChecked( false );
6927 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6928 \param pview view being closed
6930 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6931 #ifndef DISABLE_PLOT2DVIEWER
6932 //Crear all Plot2d Viewers if need.
6933 SMESH::ClearPlot2Viewers(pview);
6935 EmitSignalCloseView();
6938 void SMESHGUI::message( const QString& msg )
6941 QStringList data = msg.split("/");
6942 if ( data.count() > 0 ) {
6943 if ( data.first() == "mesh_loading" ) {
6945 QString entry = data.count() > 1 ? data[1] : QString();
6946 if ( entry.isEmpty() )
6949 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6951 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6954 name = SMESH::fromUtf8(obj->GetName());
6955 if ( name.isEmpty() )
6958 if ( data.last() == "stop" )
6959 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6961 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6962 QApplication::processEvents();
6968 \brief Connects or disconnects signals about activating and cloning view on the module slots
6969 \param pview view which is connected/disconnected
6971 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6975 SUIT_ViewManager* viewMgr = pview->getViewManager();
6977 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6978 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6980 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6981 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6986 \brief Return \c true if object can be renamed
6988 bool SMESHGUI::renameAllowed( const QString& entry) const {
6989 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6993 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6997 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7002 if(appStudy->isComponent(entry) || obj->isReference())
7005 // check type to prevent renaming of inappropriate objects
7006 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7007 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7008 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7009 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7010 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7011 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7018 Rename object by entry.
7019 \param entry entry of the object
7020 \param name new name of the object
7021 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7023 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7025 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7029 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7034 _PTR(Study) aStudy = appStudy->studyDS();
7039 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7041 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7046 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7047 _PTR(GenericAttribute) anAttr;
7048 _PTR(AttributeName) aName;
7050 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7052 // check type to prevent renaming of inappropriate objects
7053 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7054 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7055 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7056 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7057 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7058 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7059 if ( !name.isEmpty() ) {
7060 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
7062 // update name of group object and its actor
7063 Handle(SALOME_InteractiveObject) IObject =
7064 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7066 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7067 if( !aGroupObject->_is_nil() ) {
7068 aGroupObject->SetName( qPrintable(name) );
7069 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7070 anActor->setName( qPrintable(name) );
7080 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7082 static QList<QColor> colors;
7084 if ( colors.isEmpty() ) {
7086 for (int s = 0; s < 2 ; s++)
7088 for (int v = 100; v >= 40; v = v - 20)
7090 for (int h = 0; h < 359 ; h = h + 60)
7092 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7097 static int currentColor = randomize( colors.size() );
7099 SALOMEDS::Color color;
7100 color.R = (double)colors[currentColor].red() / 255.0;
7101 color.G = (double)colors[currentColor].green() / 255.0;
7102 color.B = (double)colors[currentColor].blue() / 255.0;
7104 currentColor = (currentColor+1) % colors.count();