1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FieldSelectorWdg.h"
48 #include "SMESHGUI_FileInfoDlg.h"
49 #include "SMESHGUI_FileValidator.h"
50 #include "SMESHGUI_FilterDlg.h"
51 #include "SMESHGUI_FilterLibraryDlg.h"
52 #include "SMESHGUI_FindElemByPointDlg.h"
53 #include "SMESHGUI_GroupDlg.h"
54 #include "SMESHGUI_GroupOnShapeDlg.h"
55 #include "SMESHGUI_GroupOpDlg.h"
56 #include "SMESHGUI_Hypotheses.h"
57 #include "SMESHGUI_Make2DFrom3DOp.h"
58 #include "SMESHGUI_MakeNodeAtPointDlg.h"
59 #include "SMESHGUI_Measurements.h"
60 #include "SMESHGUI_MergeDlg.h"
61 #include "SMESHGUI_MeshInfo.h"
62 #include "SMESHGUI_MeshOp.h"
63 #include "SMESHGUI_MeshOrderOp.h"
64 #include "SMESHGUI_MeshPatternDlg.h"
65 #include "SMESHGUI_MultiEditDlg.h"
66 #include "SMESHGUI_NodesDlg.h"
67 #include "SMESHGUI_Operations.h"
68 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
69 #include "SMESHGUI_PropertiesDlg.h"
70 #include "SMESHGUI_RemoveElementsDlg.h"
71 #include "SMESHGUI_RemoveNodesDlg.h"
72 #include "SMESHGUI_RenumberingDlg.h"
73 #include "SMESHGUI_ReorientFacesDlg.h"
74 #include "SMESHGUI_RevolutionDlg.h"
75 #include "SMESHGUI_RotationDlg.h"
76 #include "SMESHGUI_ScaleDlg.h"
77 #include "SMESHGUI_OffsetDlg.h"
78 #include "SMESHGUI_Selection.h"
79 #include "SMESHGUI_SewingDlg.h"
80 #include "SMESHGUI_SingleEditDlg.h"
81 #include "SMESHGUI_SmoothingDlg.h"
82 #include "SMESHGUI_SymmetryDlg.h"
83 #include "SMESHGUI_TranslationDlg.h"
84 #include "SMESHGUI_TransparencyDlg.h"
85 #include "SMESHGUI_DisplayEntitiesDlg.h"
86 #include "SMESHGUI_SplitBiQuad.h"
88 #include "SMESHGUI_FilterUtils.h"
89 #include "SMESHGUI_GEOMGenUtils.h"
90 #include "SMESHGUI_GroupUtils.h"
91 #include "SMESHGUI_HypothesesUtils.h"
92 #include "SMESHGUI_MeshUtils.h"
93 #include "SMESHGUI_PatternUtils.h"
94 #include "SMESHGUI_Utils.h"
95 #include "SMESHGUI_VTKUtils.h"
97 #include "SMESH_version.h"
99 #include "SMESH_ControlsDef.hxx"
100 #include "SMESH_Actor.h"
101 #include "SMESH_ActorUtils.h"
102 #include "SMESH_Client.hxx"
103 #include "SMESH_ScalarBarActor.h"
104 #include "SMESH_TypeFilter.hxx"
106 // SALOME GUI includes
107 #include <SalomeApp_Application.h>
108 #include <SalomeApp_CheckFileDlg.h>
109 #include <SalomeApp_DataObject.h>
110 #include <SalomeApp_Study.h>
111 #include <SalomeApp_Tools.h>
113 #include <LightApp_DataOwner.h>
114 #include <LightApp_NameDlg.h>
115 #include <LightApp_Preferences.h>
116 #include <LightApp_SelectionMgr.h>
117 #include <LightApp_UpdateFlags.h>
119 #include <SVTK_ViewManager.h>
120 #include <SVTK_ViewModel.h>
121 #include <SVTK_ViewWindow.h>
123 #include <VTKViewer_Algorithm.h>
125 #include <SUIT_Desktop.h>
126 #include <SUIT_FileDlg.h>
127 #include <SUIT_MessageBox.h>
128 #include <SUIT_OverrideCursor.h>
129 #include <SUIT_ResourceMgr.h>
130 #include <SUIT_Session.h>
132 #include <QtxPopupMgr.h>
133 #include <QtxFontEdit.h>
135 #include <SALOME_ListIO.hxx>
137 #ifndef DISABLE_PLOT2DVIEWER
138 #include <SPlot2d_ViewModel.h>
139 #include <SPlot2d_Histogram.h>
143 #include <SALOMEconfig.h>
144 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
145 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
146 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
147 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
150 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
151 #include <QApplication>
153 #include <QTextStream>
158 #include <QDialogButtonBox>
161 #include <boost/shared_ptr.hpp>
164 #include <vtkCallbackCommand.h>
165 #include <vtkCamera.h>
166 #include <vtkLookupTable.h>
167 #include <vtkPlane.h>
168 #include <vtkRenderer.h>
170 // SALOME KERNEL includes
171 #include <SALOMEDSClient_ClientFactory.hxx>
172 #include <SALOMEDSClient_IParameters.hxx>
173 #include <SALOMEDSClient_SComponent.hxx>
174 #include <SALOMEDSClient_StudyBuilder.hxx>
175 #include <SALOMEDS_Study.hxx>
176 #include <SALOMEDS_SObject.hxx>
177 #include "utilities.h"
180 #include <Standard_ErrorHandler.hxx>
181 #include <NCollection_DataMap.hxx>
182 #include <NCollection_DoubleMap.hxx>
184 #include <Basics_Utils.hxx>
186 // Below macro, when uncommented, switches on simplified (more performant) algorithm
187 // of auto-color picking up
188 #define SIMPLE_AUTOCOLOR
193 //=============================================================
194 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
197 void ExportMeshToFile(int theCommandID);
199 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
201 void SetDisplayEntity(int theCommandID);
203 int ActionToControl( int theID, bool theReversed = false );
205 void Control( int theCommandID );
208 //================================================================================
210 * \brief Reads meshes from file
212 //================================================================================
214 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
218 std::string myExtension;
220 if ( theCommandID == SMESHOp::OpImportMED ||
221 theCommandID == SMESHOp::OpPopupImportMED ) {
222 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
223 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
225 else if ( theCommandID == SMESHOp::OpImportUNV ||
226 theCommandID == SMESHOp::OpPopupImportUNV ) {
227 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
229 else if ( theCommandID == SMESHOp::OpImportDAT ||
230 theCommandID == SMESHOp::OpPopupImportDAT ) {
231 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
233 else if ( theCommandID == SMESHOp::OpImportSTL ||
234 theCommandID == SMESHOp::OpPopupImportSTL ) {
235 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
237 else if ( theCommandID == SMESHOp::OpImportCGNS ||
238 theCommandID == SMESHOp::OpPopupImportCGNS ) {
239 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
241 else if ( theCommandID == SMESHOp::OpImportSAUV ||
242 theCommandID == SMESHOp::OpPopupImportSAUV ) {
243 filter.append( QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)" );
244 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
246 else if ( theCommandID == SMESHOp::OpImportGMF ||
247 theCommandID == SMESHOp::OpPopupImportGMF ) {
248 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
249 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
252 QString anInitialPath = "";
253 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
254 anInitialPath = QDir::currentPath();
256 QStringList filenames;
257 bool toCreateGroups = true;
259 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
260 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
261 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
262 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
263 // fd->setNameFilters( filter );
264 // fd->SetChecked( true );
266 // filenames << fd->selectedFile();
267 // toCreateGroups = fd->IsChecked();
273 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
276 QObject::tr( "SMESH_IMPORT_MESH" ) );
278 if ( filenames.count() > 0 )
280 SUIT_OverrideCursor wc;
281 _PTR(Study) aStudy = SMESH::getStudy();
284 QStringList anEntryList;
285 bool isEmpty = false;
286 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
288 QString filename = *it;
289 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
291 switch ( theCommandID ) {
292 case SMESHOp::OpImportDAT:
293 case SMESHOp::OpPopupImportDAT:
295 // DAT format (currently unsupported)
296 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
297 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
300 case SMESHOp::OpImportUNV:
301 case SMESHOp::OpPopupImportUNV:
304 aMeshes->length( 1 );
305 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
306 if ( aMeshes[0]->_is_nil() )
307 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
308 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
311 case SMESHOp::OpImportMED:
312 case SMESHOp::OpPopupImportMED:
315 SMESH::DriverMED_ReadStatus res;
316 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
317 if ( res != SMESH::DRS_OK ) {
318 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
319 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
323 case SMESHOp::OpImportSTL:
324 case SMESHOp::OpPopupImportSTL:
327 aMeshes->length( 1 );
328 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
329 if ( aMeshes[0]->_is_nil() ) {
330 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
331 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
335 case SMESHOp::OpImportCGNS:
336 case SMESHOp::OpPopupImportCGNS:
339 SMESH::DriverMED_ReadStatus res;
340 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
341 if ( res != SMESH::DRS_OK ) {
342 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
343 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
347 case SMESHOp::OpImportSAUV:
348 case SMESHOp::OpPopupImportSAUV:
351 SMESH::DriverMED_ReadStatus res;
352 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
353 if ( res != SMESH::DRS_OK ) {
354 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
355 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
359 case SMESHOp::OpImportGMF:
360 case SMESHOp::OpPopupImportGMF:
363 SMESH::ComputeError_var res;
364 aMeshes->length( 1 );
365 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
368 if ( res->code != SMESH::DRS_OK ) {
369 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
370 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
371 if ( strlen( res->comment.in() ) > 0 ) {
372 errors.back() += ": ";
373 errors.back() += res->comment.in();
380 catch ( const SALOME::SALOME_Exception& S_ex ) {
381 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
382 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
385 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
387 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
389 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
390 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
391 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
392 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
393 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
395 anEntryList.append( aMeshSO->GetID().c_str() );
403 // update Object browser
404 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
406 // browse to the published meshes
407 if( LightApp_Application* anApp =
408 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
409 anApp->browseObjects( anEntryList );
411 // show Error message box if there were errors
412 if ( errors.count() > 0 ) {
413 SUIT_MessageBox::critical( SMESHGUI::desktop(),
414 QObject::tr( "SMESH_ERROR" ),
415 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
418 // show warning message box, if some imported mesh is empty
420 SUIT_MessageBox::warning( SMESHGUI::desktop(),
421 QObject::tr( "SMESH_WRN_WARNING" ),
422 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
427 //================================================================================
429 * \brief Export selected meshes or groups into a file
431 //================================================================================
433 void ExportMeshToFile( int theCommandID )
435 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
436 SALOME_ListIO selected;
438 aSel->selectedObjects( selected );
440 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
441 theCommandID == SMESHOp::OpPopupExportDAT );
442 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
443 theCommandID == SMESHOp::OpPopupExportMED );
444 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
445 theCommandID == SMESHOp::OpPopupExportUNV );
446 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
447 theCommandID == SMESHOp::OpPopupExportSTL );
448 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
449 theCommandID == SMESHOp::OpPopupExportCGNS );
450 const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV ||
451 theCommandID == SMESHOp::OpPopupExportSAUV );
452 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
453 theCommandID == SMESHOp::OpPopupExportGMF );
455 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
456 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
458 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
459 bool aCheckWarn = true;
461 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
462 // get mesh object from selection and check duplication of their names
463 bool hasDuplicatedMeshNames = false;
464 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
465 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
466 SALOME_ListIteratorOfListIO It( selected );
467 for( ; It.More(); It.Next() )
469 Handle(SALOME_InteractiveObject) anIObject = It.Value();
470 SMESH::SMESH_IDSource_var aMeshItem =
471 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
472 if ( aMeshItem->_is_nil() ) {
473 SUIT_MessageBox::warning( SMESHGUI::desktop(),
474 QObject::tr( "SMESH_WRN_WARNING" ),
475 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
478 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
479 if ( aCheckWarn && !aGroup->_is_nil() )
481 QMessageBox msgBox(SUIT_MessageBox::Warning,
482 QObject::tr("SMESH_WRN_WARNING"),
483 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
484 QMessageBox::StandardButton::NoButton,
485 SMESHGUI::desktop());
486 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
487 msgBox.addButton(QMessageBox::Ok);
488 msgBox.addButton(QMessageBox::Cancel);
489 msgBox.setDefaultButton(QMessageBox::Cancel);
490 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
491 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
492 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
493 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
494 if(msgBox.exec() == QMessageBox::Ok)
496 if(dontShowCheckBox.checkState() == Qt::Checked)
499 resMgr->setValue( "SMESH", "show_warning", false);
507 QString aMeshName = anIObject->getName();
509 // check for name duplications
510 if ( !hasDuplicatedMeshNames )
511 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
512 if( aMeshName == (*aMeshIter).second ) {
513 hasDuplicatedMeshNames = true;
518 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
521 if( hasDuplicatedMeshNames && isMED ) {
522 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
523 QObject::tr("SMESH_WRN_WARNING"),
524 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
525 QObject::tr("SMESH_BUT_YES"),
526 QObject::tr("SMESH_BUT_NO"), 0, 1);
531 aMeshIter = aMeshList.begin();
532 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
533 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
534 QString aMeshName = (*aMeshIter).second;
536 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
538 // check for equal group names within each mesh
539 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
540 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
541 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
542 int aRet = SUIT_MessageBox::warning
543 (SMESHGUI::desktop(),
544 QObject::tr("SMESH_WRN_WARNING"),
545 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
546 QObject::tr("SMESH_BUT_YES"),
547 QObject::tr("SMESH_BUT_NO"), 0, 1);
554 // Warn the user about presence of not supported elements
556 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
560 notSupportedElemTypes.push_back( SMESH::Entity_0D );
561 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
566 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
567 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
568 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
569 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
570 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
571 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
572 notSupportedElemTypes.push_back( SMESH::Entity_0D );
573 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
578 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
579 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
580 notSupportedElemTypes.push_back( SMESH::Entity_0D );
581 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
586 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
591 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
592 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
593 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
594 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
595 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
596 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
597 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
598 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
603 notSupportedElemTypes.push_back( SMESH::Entity_0D );
604 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
605 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
606 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
607 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
608 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
609 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
610 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
611 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
612 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
614 if ( ! notSupportedElemTypes.empty() )
616 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
617 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
618 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
619 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
621 if ( !presentNotSupported.empty() )
624 const char* typeMsg[] = {
625 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
626 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
627 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
628 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
629 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
630 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
631 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
632 "SMESH_BIQUADRATIC_PENTAHEDRONS",
633 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
635 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
636 const int nbTypes = sizeof( typeMsg ) / sizeof( const char* );
637 int _assert[( nbTypes == SMESH::Entity_Last ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
639 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
640 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
641 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
642 if ( iType != presentNotSupported.size() - 1 )
643 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
645 int aRet = SUIT_MessageBox::warning
646 (SMESHGUI::desktop(),
647 QObject::tr("SMESH_WRN_WARNING"),
648 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
649 QObject::tr("SMESH_BUT_YES"),
650 QObject::tr("SMESH_BUT_NO"), 0, 1);
655 // Get parameters of export operation
658 // Init the parameters with the default values
659 bool aIsASCII_STL = true;
660 bool toCreateGroups = false;
662 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
663 bool toOverwrite = true;
664 bool toFindOutDim = true;
666 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
667 QString anInitialPath = "";
668 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
669 anInitialPath = QDir::currentPath();
671 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
673 // Get a file name to write in and additional otions
674 if ( isUNV || isDAT || isGMF ) // Export w/o options
677 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
679 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
681 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
682 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
683 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
684 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
685 anInitialPath + QString("/") + aMeshName,
686 aFilter, aTitle, false);
688 else if ( isCGNS )// Export to CGNS
690 const char* theByTypeResource = "cgns_group_elems_by_type";
691 toCreateGroups = SMESHGUI::resourceMgr()->booleanValue( "SMESH", theByTypeResource, false );
693 QStringList checkBoxes;
694 checkBoxes << QObject::tr("CGNS_EXPORT_ELEMS_BY_TYPE");
696 SalomeApp_CheckFileDlg* fd =
697 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
698 fd->setWindowTitle( aTitle );
699 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
700 if ( !anInitialPath.isEmpty() )
701 fd->setDirectory( anInitialPath );
702 fd->selectFile(aMeshName);
703 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
704 fd->setValidator( fv );
705 fd->SetChecked( toCreateGroups, 0 );
708 aFilename = fd->selectedFile();
709 toOverwrite = fv->isOverwrite();
710 toCreateGroups = fd->IsChecked(0);
711 SMESHGUI::resourceMgr()->setValue("SMESH", theByTypeResource, toCreateGroups );
715 else if ( isSTL ) // Export to STL
717 QMap<QString, int> aFilterMap;
718 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
719 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
722 QMap<QString, int>::const_iterator it = aFilterMap.begin();
723 for ( ; it != aFilterMap.end(); ++it )
724 filters.push_back( it.key() );
726 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
727 fd->setWindowTitle( aTitle );
728 fd->setNameFilters( filters );
729 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
730 if ( !anInitialPath.isEmpty() )
731 fd->setDirectory( anInitialPath );
732 fd->selectFile(aMeshName);
736 aFilename = fd->selectedFile();
737 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
742 else if ( isMED || isSAUV ) // Export to MED or SAUV
746 filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
749 filters << QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)";
752 QStringList checkBoxes;
753 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
755 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
756 QList< QWidget* > wdgList;
757 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
758 wdgList.append( fieldSelWdg );
760 SalomeApp_CheckFileDlg* fd =
761 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
762 fd->setWindowTitle( aTitle );
763 fd->setNameFilters( filters );
764 fd->SetChecked( toCreateGroups, 0 );
765 fd->SetChecked( toFindOutDim, 1 );
766 if ( !anInitialPath.isEmpty() )
767 fd->setDirectory( anInitialPath );
768 fd->selectFile(aMeshName);
771 QListView *lview = fd->findChild<QListView*>("listView");
773 lview->setMinimumHeight(200);
775 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
777 tview->setMinimumHeight(200);
780 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
781 fd->setValidator( fv );
786 aFilename = fd->selectedFile();
788 aFilename = QString::null;
791 toOverwrite = fv->isOverwrite();
793 if ( !aFilename.isEmpty() ) {
795 // can't append to an existing using other format
796 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckCompatibility( aFilename.toUtf8().constData() );
797 if ( !isVersionOk ) {
798 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
799 QObject::tr("SMESH_WRN_WARNING"),
800 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
801 QObject::tr("SMESH_BUT_YES"),
802 QObject::tr("SMESH_BUT_NO"), 0, 1);
809 QStringList aMeshNamesCollisionList;
810 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
811 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
812 QString anExistingMeshName( aMeshNames[ i ] );
813 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
814 QString anExportMeshName = (*aMeshIter).second;
815 if( anExportMeshName == anExistingMeshName ) {
816 aMeshNamesCollisionList.append( anExportMeshName );
821 if( !aMeshNamesCollisionList.isEmpty() ) {
822 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
823 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
824 QObject::tr("SMESH_WRN_WARNING"),
825 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
826 QObject::tr("SMESH_BUT_YES"),
827 QObject::tr("SMESH_BUT_NO"),
828 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
837 toCreateGroups = fd->IsChecked(0);
838 toFindOutDim = fd->IsChecked(1);
839 fieldSelWdg->GetSelectedFields();
840 if ( !fieldSelWdg->parent() )
851 if ( !aFilename.isEmpty() ) {
852 // Check whether the file already exists and delete it if yes
853 QFile aFile( aFilename );
854 if ( aFile.exists() && toOverwrite )
856 SUIT_OverrideCursor wc;
859 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
860 // bool Renumber = false;
861 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
863 // Renumber= resMgr->booleanValue("renumbering");
865 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
866 // aMeshEditor->RenumberNodes();
867 // aMeshEditor->RenumberElements();
868 // if ( SMESHGUI::automaticUpdate() )
869 // SMESH::UpdateView();
873 aMeshIter = aMeshList.begin();
874 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
876 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
877 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
878 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
879 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
880 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
881 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
882 aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups,
883 toOverwrite && aMeshIndex == 0, toFindOutDim );
885 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
886 toOverwrite && aMeshIndex == 0, toFindOutDim,
887 fields, geoAssFields.toLatin1().data() );
892 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
894 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
895 if( !aMeshItem->_is_nil() )
896 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
901 if ( aMeshOrGroup->_is_equivalent( aMesh ))
902 aMesh->ExportDAT( aFilename.toUtf8().data() );
904 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
908 if ( aMeshOrGroup->_is_equivalent( aMesh ))
909 aMesh->ExportUNV( aFilename.toUtf8().data() );
911 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
915 if ( aMeshOrGroup->_is_equivalent( aMesh ))
916 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
918 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
922 aMeshIter = aMeshList.begin();
923 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
925 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
926 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
927 aMeshItem->ExportCGNS( aMeshOrGroup,
928 aFilename.toUtf8().data(),
929 toOverwrite && aMeshIndex == 0,
935 toCreateGroups = true;
936 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
939 catch (const SALOME::SALOME_Exception& S_ex){
941 SUIT_MessageBox::warning(SMESHGUI::desktop(),
942 QObject::tr("SMESH_WRN_WARNING"),
943 QObject::tr("SMESH_EXPORT_FAILED"));
949 inline void InverseEntityMode(unsigned int& theOutputMode,
950 unsigned int theMode)
952 bool anIsNotPresent = ~theOutputMode & theMode;
954 theOutputMode |= theMode;
956 theOutputMode &= ~theMode;
959 void SetDisplayEntity(int theCommandID)
961 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
962 SALOME_ListIO selected;
964 aSel->selectedObjects( selected );
966 if ( selected.Extent() >= 1 ) {
967 SUIT_OverrideCursor wc;
968 SALOME_ListIteratorOfListIO It( selected );
969 for( ; It.More(); It.Next()){
970 Handle(SALOME_InteractiveObject) IObject = It.Value();
971 if(IObject->hasEntry()){
972 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
973 unsigned int aMode = anActor->GetEntityMode();
974 switch(theCommandID){
975 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
976 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
977 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
978 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
979 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
980 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
983 anActor->SetEntityMode(aMode);
992 SalomeApp_Application* app =
993 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
997 LightApp_SelectionMgr* aSel = app->selectionMgr();
998 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
999 if ( !aSel || !appStudy )
1002 SALOME_ListIO selected;
1003 aSel->selectedObjects( selected );
1004 if ( selected.IsEmpty() )
1007 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1009 _PTR(Study) aStudy = appStudy->studyDS();
1010 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1011 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1012 if ( aMainObject->_is_nil() )
1015 SUIT_OverrideCursor wc;
1017 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1019 QList<SALOMEDS::Color> aReservedColors;
1021 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1022 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1024 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1026 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1027 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1028 #else // old algorithm for auto-colors
1029 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1030 aReservedColors.append( aColor );
1031 #endif // SIMPLE_AUTOCOLOR
1032 aGroupObject->SetColor( aColor );
1034 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1035 if ( aGroupSObject ) {
1038 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1039 switch ( aGroupObject->GetType ()) {
1041 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1043 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1045 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1047 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1049 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1050 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1053 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1054 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1060 SMESH::RepaintCurrentView();
1063 void OverallMeshQuality()
1065 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1066 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1067 SALOME_ListIO selected;
1069 aSel->selectedObjects( selected );
1071 if ( selected.IsEmpty() ) return;
1072 SALOME_ListIteratorOfListIO It( selected );
1073 for ( ; It.More(); It.Next() ) {
1074 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1075 ctrlDlg->showInfo( It.Value() );
1080 QString functorToString( SMESH::Controls::FunctorPtr f )
1082 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1083 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1084 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1085 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1086 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1087 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1088 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1089 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1090 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1091 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1092 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1093 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1094 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1095 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1096 type = QObject::tr( "WARP_ELEMENTS" );
1097 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1098 type = QObject::tr( "TAPER_ELEMENTS" );
1099 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1100 type = QObject::tr( "SKEW_ELEMENTS" );
1101 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1102 type = QObject::tr( "AREA_ELEMENTS" );
1103 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1104 type = QObject::tr( "LENGTH_EDGES" );
1105 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1106 type = QObject::tr( "LENGTH2D_EDGES" );
1107 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1108 type = QObject::tr( "DEFLECTION2D_FACES" );
1109 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1110 type = QObject::tr( "MULTI_BORDERS" );
1111 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1112 type = QObject::tr( "MULTI2D_BORDERS" );
1113 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1114 type = QObject::tr( "FREE_NODES" );
1115 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1116 type = QObject::tr( "FREE_EDGES" );
1117 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1118 type = QObject::tr( "FREE_BORDERS" );
1119 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1120 type = QObject::tr( "FREE_FACES" );
1121 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1122 type = QObject::tr( "BARE_BORDER_VOLUME" );
1123 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1124 type = QObject::tr( "BARE_BORDER_FACE" );
1125 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1126 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1127 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1128 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1129 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1130 type = QObject::tr( "EQUAL_NODE" );
1131 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1132 type = QObject::tr( "EQUAL_EDGE" );
1133 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1134 type = QObject::tr( "EQUAL_FACE" );
1135 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1136 type = QObject::tr( "EQUAL_VOLUME" );
1137 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1138 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1142 void SaveDistribution()
1144 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1145 SALOME_ListIO selected;
1147 aSel->selectedObjects( selected );
1149 if ( selected.Extent() == 1 ) {
1150 Handle(SALOME_InteractiveObject) anIO = selected.First();
1151 if ( anIO->hasEntry() ) {
1152 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1154 anActor->GetScalarBarActor() &&
1155 anActor->GetControlMode() != SMESH_Actor::eNone )
1157 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1158 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1159 if ( aScalarBarActor && aFunctor ) {
1160 SMESH::Controls::NumericalFunctor* aNumFun =
1161 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1163 std::vector<int> elements;
1164 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1165 if ( mesh->_is_nil() ) {
1166 SMESH::SMESH_IDSource_var idSource =
1167 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1168 if ( !idSource->_is_nil() )
1170 SMESH::long_array_var ids = idSource->GetIDs();
1171 elements.resize( ids->length() );
1172 for ( unsigned i = 0; i < elements.size(); ++i )
1173 elements[i] = ids[i];
1176 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1177 vtkLookupTable* lookupTable =
1178 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1179 double * minmax = lookupTable->GetRange();
1180 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1181 std::vector<int> nbEvents;
1182 std::vector<double> funValues;
1183 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1184 elements, minmax, isLogarithmic );
1185 QString anInitialPath = "";
1186 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1187 anInitialPath = QDir::currentPath();
1188 QString aMeshName = anIO->getName();
1190 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1191 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1192 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1193 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1194 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1197 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1199 if ( !aFilename.isEmpty() ) {
1200 QFile f( aFilename );
1201 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1202 QTextStream out( &f );
1203 out << "# Mesh: " << aMeshName << endl;
1204 out << "# Control: " << functorToString( aFunctor ) << endl;
1206 out.setFieldWidth( 10 );
1207 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1208 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1219 void ShowElement( int theCommandID )
1221 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1222 SALOME_ListIO selected;
1224 aSel->selectedObjects( selected );
1226 if ( selected.Extent() == 1 ) {
1227 Handle(SALOME_InteractiveObject) anIO = selected.First();
1228 if ( anIO->hasEntry() ) {
1229 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1231 anActor->GetScalarBarActor() &&
1232 anActor->GetControlMode() != SMESH_Actor::eNone )
1234 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1235 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1236 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1238 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1239 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1246 #ifndef DISABLE_PLOT2DVIEWER
1247 void PlotDistribution()
1249 SalomeApp_Application* app =
1250 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1254 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1255 SALOME_ListIO selected;
1257 aSel->selectedObjects( selected );
1259 if ( selected.Extent() == 1 ) {
1260 Handle(SALOME_InteractiveObject) anIO = selected.First();
1261 if ( anIO->hasEntry() ) {
1262 //Find Actor by entry before getting Plot2d viewer,
1263 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1264 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1266 SUIT_ViewManager* aViewManager =
1267 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1271 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1275 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1279 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1281 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1282 QString functorName = functorToString( anActor->GetFunctor());
1283 QString aHistogramName("%1 : %2");
1284 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1285 aHistogram->setName(aHistogramName);
1286 aHistogram->setHorTitle(functorName);
1287 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1288 aPlot->displayObject(aHistogram, true);
1293 #endif //DISABLE_PLOT2DVIEWER
1295 void DisableAutoColor()
1297 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1298 SALOME_ListIO selected;
1300 aSel->selectedObjects( selected );
1302 if ( selected.Extent() ) {
1303 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1304 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1305 if ( !aMesh->_is_nil() ) {
1306 aMesh->SetAutoColor( false );
1313 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1314 SALOME_ListIO selected;
1316 aSel->selectedObjects( selected );
1317 if ( selected.Extent() )
1319 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1320 _PTR(Study) aStudy = SMESH::getStudy();
1321 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1323 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1324 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1331 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1333 SALOME_ListIO selected;
1334 SalomeApp_Application* app =
1335 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1339 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1340 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1341 if ( !aSel || !appStudy )
1344 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1345 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1346 aModule->EmitSignalDeactivateDialog();
1347 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1348 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1353 aSel->selectedObjects( selected );
1355 if ( selected.Extent() >= 1 )
1357 switch ( theCommandID ) {
1358 case SMESHOp::OpTransparency:
1360 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1361 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1364 case SMESHOp::OpProperties:
1367 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1368 QColor orientationColor, outlineColor, volumeColor;
1369 int deltaF = 0, deltaV = 0;
1372 double ballScale = 1.0;
1374 int outlineWidth = 1;
1375 double shrinkCoef = 0.0;
1376 double orientationScale = 0.0;
1377 bool orientation3d = false;
1378 VTK::MarkerType markerType = VTK::MT_NONE;
1379 VTK::MarkerScale markerScale = VTK::MS_NONE;
1381 bool hasNodes = false;
1382 int presentEntities = 0;
1383 bool firstTime = true;
1385 SALOME_ListIteratorOfListIO It( selected );
1386 for ( ; It.More(); It.Next() ) {
1387 Handle(SALOME_InteractiveObject) IObject = It.Value();
1388 if ( !IObject->hasEntry() ) continue;
1389 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1390 if ( !anActor || !anActor->GetObject() ) continue;
1393 // nodes: color, marker
1394 anActor->GetNodeColor( color[0], color[1], color[2] );
1395 nodeColor.setRgbF( color[0], color[1], color[2] );
1396 markerType = anActor->GetMarkerType();
1397 markerScale = anActor->GetMarkerScale();
1398 markerId = anActor->GetMarkerTexture();
1399 // edges: color, width
1400 anActor->GetEdgeColor( color[0], color[1], color[2] );
1401 edgeColor.setRgbF( color[0], color[1], color[2] );
1402 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1403 // faces: front color, back color (delta)
1404 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1405 faceColor.setRgbF( color[0], color[1], color[2] );
1406 // faces: front color, back color (delta)
1407 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1408 volumeColor.setRgbF( color[0], color[1], color[2] );
1409 // 0d elements: color, size
1410 anActor->Get0DColor( color[0], color[1], color[2] );
1411 elem0dColor.setRgbF( color[0], color[1], color[2] );
1412 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1413 // balls: color, size
1414 anActor->GetBallColor( color[0], color[1], color[2] );
1415 ballColor.setRgbF( color[0], color[1], color[2] );
1416 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1417 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1419 anActor->GetOutlineColor( color[0], color[1], color[2] );
1420 outlineColor.setRgbF( color[0], color[1], color[2] );
1421 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1422 // orientation vectors: color, scale, 3d flag
1423 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1424 orientationColor.setRgbF( color[0], color[1], color[2] );
1425 orientationScale = anActor->GetFacesOrientationScale();
1426 orientation3d = anActor->GetFacesOrientation3DVectors();
1428 shrinkCoef = anActor->GetShrinkFactor();
1431 firstTime = false; // we only take properties from first object (for performance reasons)
1434 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1435 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1436 presentEntities = presentEntities | SMESH_Actor::eEdges;
1437 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1438 presentEntities = presentEntities | SMESH_Actor::eFaces;
1439 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1440 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1441 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1442 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1443 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1444 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1446 // as we know that all types of elements are present, we can exit the loop
1447 if ( presentEntities == SMESH_Actor::eAllEntity )
1451 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1452 // nodes: color, marker
1453 dlg.setNodeColor( nodeColor );
1454 if( markerType != VTK::MT_USER )
1455 dlg.setNodeMarker( markerType, markerScale );
1457 dlg.setNodeCustomMarker( markerId );
1458 // edges: color, line width
1459 dlg.setEdgeColor( edgeColor );
1460 dlg.setEdgeWidth( edgeWidth );
1461 // faces: front color, back color
1462 dlg.setFaceColor( faceColor, deltaF );
1463 // volumes: normal color, reversed color
1464 dlg.setVolumeColor( volumeColor, deltaV );
1465 // outlines: color, line width
1466 dlg.setOutlineColor( outlineColor );
1467 dlg.setOutlineWidth( outlineWidth );
1468 // 0d elements: color, size
1469 dlg.setElem0dColor( elem0dColor );
1470 dlg.setElem0dSize( elem0dSize );
1471 // balls: color, size
1472 dlg.setBallColor( ballColor );
1473 //dlg.setBallSize( ballSize );
1474 dlg.setBallScale( ballScale );
1475 // orientation: color, scale, 3d flag
1476 dlg.setOrientationColor( orientationColor );
1477 dlg.setOrientationSize( int( orientationScale * 100. ) );
1478 dlg.setOrientation3d( orientation3d );
1479 // shrink: scale factor
1480 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1481 // hide unused controls
1482 dlg.showControls( presentEntities, hasNodes );
1485 nodeColor = dlg.nodeColor();
1486 markerType = dlg.nodeMarkerType();
1487 markerScale = dlg.nodeMarkerScale();
1488 markerId = dlg.nodeMarkerId();
1489 edgeColor = dlg.edgeColor();
1490 edgeWidth = dlg.edgeWidth();
1491 faceColor = dlg.faceColor();
1492 deltaF = dlg.faceColorDelta();
1493 volumeColor = dlg.volumeColor();
1494 deltaV = dlg.volumeColorDelta();
1495 outlineColor = dlg.outlineColor();
1496 outlineWidth = dlg.outlineWidth();
1497 elem0dColor = dlg.elem0dColor();
1498 elem0dSize = dlg.elem0dSize();
1499 ballColor = dlg.ballColor();
1500 // ballSize = dlg.ballSize();
1501 ballScale = dlg.ballScale();
1502 orientationColor = dlg.orientationColor();
1503 orientationScale = dlg.orientationSize() / 100.;
1504 orientation3d = dlg.orientation3d();
1505 shrinkCoef = dlg.shrinkCoef() / 100.;
1507 // store point markers that might be changed by the user
1508 theMarkerMap = dlg.customMarkers();
1510 // set properties from dialog box to the presentations
1511 SALOME_ListIteratorOfListIO It( selected );
1512 for ( ; It.More(); It.Next() ) {
1513 Handle(SALOME_InteractiveObject) IObject = It.Value();
1514 if ( !IObject->hasEntry() ) continue;
1515 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1516 if ( !anActor ) continue;
1518 // nodes: color, marker
1519 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1520 if ( markerType != VTK::MT_USER ) {
1521 anActor->SetMarkerStd( markerType, markerScale );
1524 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1525 if ( iter != theMarkerMap.end() )
1526 anActor->SetMarkerTexture( markerId, iter->second.second );
1528 // volumes: normal color, reversed color (delta)
1529 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1530 // faces: front color, back color (delta)
1531 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1532 // edges: color, width
1533 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1534 anActor->SetLineWidth( edgeWidth );
1536 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1537 anActor->SetOutlineWidth( outlineWidth );
1538 // 0D elements: color, size
1539 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1540 anActor->Set0DSize( elem0dSize );
1541 // balls: color, size
1542 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1543 // anActor->SetBallSize( ballSize );
1544 anActor->SetBallScale( ballScale );
1545 // orientation: color, scale, 3d flag
1546 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1547 anActor->SetFacesOrientationScale( orientationScale );
1548 anActor->SetFacesOrientation3DVectors( orientation3d );
1550 anActor->SetShrinkFactor( shrinkCoef );
1552 // for groups, set also proper color
1553 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1554 if ( !aGroupObject->_is_nil() ) {
1555 SMESH::ElementType anElementType = aGroupObject->GetType();
1557 switch( anElementType ) {
1559 aColor = nodeColor; break;
1561 aColor = edgeColor; break;
1563 aColor = faceColor; break;
1565 aColor = volumeColor; break;
1567 aColor = elem0dColor; break;
1569 aColor = ballColor; break;
1573 if ( aColor.isValid() ) {
1574 SALOMEDS::Color aGroupColor;
1575 aGroupColor.R = aColor.redF();
1576 aGroupColor.G = aColor.greenF();
1577 aGroupColor.B = aColor.blueF();
1578 aGroupObject->SetColor( aGroupColor );
1580 } // if ( !aGroupObject->_is_nil() )
1581 } // for ( ; It.More(); It.Next() )
1582 SMESH::RepaintCurrentView();
1583 } // if ( dlg.exec() )
1585 } // case SMESHOp::OpProperties:
1586 } // switch(theCommandID)
1587 SUIT_OverrideCursor wc;
1588 SALOME_ListIteratorOfListIO It( selected );
1589 for( ; It.More(); It.Next()){
1590 Handle(SALOME_InteractiveObject) IObject = It.Value();
1591 if(IObject->hasEntry()){
1592 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1593 switch(theCommandID){
1594 case SMESHOp::OpDMWireframe:
1595 anActor->SetRepresentation(SMESH_Actor::eEdge);
1597 case SMESHOp::OpDMShading:
1598 anActor->SetRepresentation(SMESH_Actor::eSurface);
1600 case SMESHOp::OpDMShrink:
1601 if(anActor->IsShrunk())
1602 anActor->UnShrink();
1604 anActor->SetShrink();
1606 case SMESHOp::OpDMNodes:
1607 anActor->SetRepresentation(SMESH_Actor::ePoint);
1609 case SMESHOp::OpRepresentationLines:
1610 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1611 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1613 case SMESHOp::OpRepresentationArcs:
1614 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1615 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1621 SMESH::RepaintCurrentView();
1625 int ActionToControl( int theID, bool theReversed )
1627 NCollection_DoubleMap<int,int> ActionControl;
1628 ActionControl.Bind( 0, SMESH_Actor::eNone );
1629 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1630 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1631 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1632 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1633 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1634 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1635 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1636 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1637 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1638 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1639 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1640 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1641 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1642 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1643 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1644 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1645 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1646 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1647 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1648 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1649 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1650 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1651 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1652 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1653 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1654 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1655 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1656 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1659 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1660 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1663 void Control( int theCommandID )
1665 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1666 _PTR(Study) aStudy = SMESH::getStudy();
1668 SALOME_ListIO selected;
1669 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1670 aSel->selectedObjects( selected );
1672 if ( !selected.IsEmpty() ) {
1673 SALOME_ListIteratorOfListIO It(selected);
1674 for ( ; It.More(); It.Next())
1676 Handle(SALOME_InteractiveObject) anIO = It.Value();
1677 if ( !anIO.IsNull() ) {
1678 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1680 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1681 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1682 if ( !anIDSrc->_is_nil() ) {
1683 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1684 if (( !anActor && selected.Extent() == 1 ) &&
1685 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1687 anActor->SetControlMode( aControl );
1688 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1689 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1693 if ( anActor->GetControlMode() != aControl )
1694 anActor->SetControlMode( aControl );
1695 QString functorName = functorToString( anActor->GetFunctor() );
1696 int anEntitiesCount = anActor->GetNumberControlEntities();
1697 if (anEntitiesCount >= 0)
1698 functorName = functorName + ": " + QString::number(anEntitiesCount);
1699 anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
1700 SMESH::RepaintCurrentView();
1701 #ifndef DISABLE_PLOT2DVIEWER
1702 if ( anActor->GetPlot2Histogram() ) {
1703 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1704 QString aHistogramName("%1 : %2");
1705 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1706 aHistogram->setName( aHistogramName );
1707 aHistogram->setHorTitle( functorName );
1708 SMESH::ProcessIn2DViewers( anActor );
1720 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1721 SMESH::MeshObjectType theType,
1722 const QString theInTypeName,
1723 QString & theOutTypeName)
1725 SMESH_TypeFilter aTypeFilter( theType );
1727 if ( !theIO.IsNull() )
1729 entry = theIO->getEntry();
1730 LightApp_DataOwner owner( entry );
1731 if ( aTypeFilter.isOk( &owner )) {
1732 theOutTypeName = theInTypeName;
1740 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1742 _PTR(Study) aStudy = SMESH::getStudy();
1743 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1745 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1746 CORBA::String_var anID = aSComp->GetID().c_str();
1747 if ( !strcmp(anID.in(),theIO->getEntry()) )
1753 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1754 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1755 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1756 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1757 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1765 // QString CheckHomogeneousSelection()
1767 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1768 // SALOME_ListIO selected;
1770 // aSel->selectedObjects( selected );
1772 // QString RefType = CheckTypeObject(selected.First());
1773 // SALOME_ListIteratorOfListIO It(selected);
1774 // for ( ; It.More(); It.Next())
1776 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1777 // QString Type = CheckTypeObject(IObject);
1778 // if ( Type.compare(RefType) != 0 )
1779 // return "Heterogeneous Selection";
1785 uint randomize( uint size )
1787 static bool initialized = false;
1788 if ( !initialized ) {
1789 qsrand( QDateTime::currentDateTime().toTime_t() );
1793 v = uint( (double)( v ) / RAND_MAX * size );
1794 v = qMax( uint(0), qMin ( v, size-1 ) );
1800 void SMESHGUI::OnEditDelete()
1802 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1803 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1804 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1806 _PTR(Study) aStudy = SMESH::getStudy();
1807 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1808 _PTR(GenericAttribute) anAttr;
1809 _PTR(AttributeIOR) anIOR;
1811 int objectCount = 0;
1813 QString aParentComponent = QString::null;
1815 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1817 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
1818 if ( anIO.IsNull() ) continue;
1820 QString father = "unknown";
1822 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
1824 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
1825 // check if object is reference
1826 _PTR(SObject) aRefSObj;
1827 aNameList.append("\n - ");
1828 if ( aSO->ReferencedObject( aRefSObj ) ) {
1829 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1830 aNameList.append( aRefName );
1831 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1834 aNameList.append(anIO->getName());
1838 if( aParentComponent.isNull() )
1839 aParentComponent = father;
1840 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
1841 aParentComponent = "";
1844 if ( objectCount == 0 )
1845 return; // No Valid Objects Selected
1847 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1848 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1849 QObject::tr("ERR_ERROR"),
1850 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1853 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1854 if (SUIT_MessageBox::warning
1855 (SMESHGUI::desktop(),
1856 QObject::tr("SMESH_WRN_WARNING"),
1857 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1858 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1859 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1862 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1864 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1865 // then treat them all starting from the deepest objects (at list back)
1866 std::list< _PTR(SObject) > listSO;
1867 SALOME_ListIteratorOfListIO It(selected);
1868 for( ; It.More(); It.Next()) // loop on selected IO's
1870 Handle(SALOME_InteractiveObject) IObject = It.Value();
1871 if(IObject->hasEntry()) {
1872 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1874 // disable removal of "SMESH" component object
1875 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1877 if ( engineIOR() == anIOR->Value().c_str() )
1880 //Check the referenced object
1881 _PTR(SObject) aRefSObject;
1882 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1883 aSO = aRefSObject; // Delete main Object instead of reference
1885 listSO.push_back( aSO );
1886 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1887 for ( ; itSO != listSO.end(); ++itSO ) {
1888 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1889 for (it->InitEx(false); it->More(); it->Next())
1890 listSO.push_back( it->Value() );
1894 // Check if none of objects to delete is referred from outside
1895 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1896 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1898 _PTR(SObject) SO = *ritSO;
1899 if ( !SO ) continue;
1900 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1901 for (size_t i = 0; i < aReferences.size(); i++) {
1902 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1903 std::string type = aComponent->ComponentDataType();
1904 if ( type != "SMESH" )
1906 SUIT_MessageBox::warning( anApp->desktop(),
1907 QObject::tr("WRN_WARNING"),
1908 QObject::tr("DEP_OBJECT") );
1909 return; // outside SMESH, there is an object depending on a SMESH object
1914 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1915 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1917 Handle(SALOME_InteractiveObject) IObject = It.Value();
1918 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1919 if ( !mesh->_is_nil() )
1923 // Treat SO's in the list starting from the back
1924 aStudyBuilder->NewCommand(); // There is a transaction
1925 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1927 _PTR(SObject) SO = *ritSO;
1928 if ( !SO ) continue;
1929 std::string anEntry = SO->GetID();
1931 /** Erase graphical object and remove all its data **/
1932 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1933 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1935 /** Remove an object from data structures **/
1936 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1937 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1938 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1939 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1940 aMesh->RemoveGroup( aGroup );
1942 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1943 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1944 aMesh->RemoveSubMesh( aSubMesh );
1947 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1948 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1949 QString objType = CheckTypeObject(IObject);
1950 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1951 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1952 aStudyBuilder->RemoveObjectWithChildren( SO );
1954 else {// default action: remove SObject from the study
1955 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1956 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1958 aStudyBuilder->RemoveObjectWithChildren( SO );
1962 } /* listSO back loop */
1964 aStudyBuilder->CommitCommand();
1966 /* Clear any previous selection */
1968 aSel->setSelectedObjects( l1 );
1970 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1974 SMESHGUI_EXPORT CAM_Module* createModule()
1976 return new SMESHGUI();
1979 SMESHGUI_EXPORT char* getModuleVersion() {
1980 return (char*)SMESH_VERSION_STR;
1984 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1986 //=============================================================================
1990 //=============================================================================
1991 SMESHGUI::SMESHGUI() :
1992 SalomeApp_Module( "SMESH" )
1994 if ( CORBA::is_nil( myComponentSMESH ) )
1996 CORBA::Boolean anIsEmbeddedMode;
1997 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1998 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2000 // 0019923: EDF 765 SMESH : default values of hypothesis
2001 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2002 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2003 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2004 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2005 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2007 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2008 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2009 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2011 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2012 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2016 myActiveDialogBox = 0;
2017 myFilterLibraryDlg = 0;
2021 myEventCallbackCommand = vtkCallbackCommand::New();
2022 myEventCallbackCommand->Delete();
2023 myEventCallbackCommand->SetClientData( this );
2024 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2027 /* load resources for all available meshers */
2028 SMESH::InitAvailableHypotheses();
2031 //=============================================================================
2035 //=============================================================================
2036 SMESHGUI::~SMESHGUI()
2040 //=============================================================================
2044 //=============================================================================
2045 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2047 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2049 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2054 //=============================================================================
2058 //=============================================================================
2059 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2061 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2065 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2066 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2067 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2068 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2069 return autoUpdate && !exceeded;
2072 //=============================================================================
2076 //=============================================================================
2077 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2078 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2080 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2084 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2085 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2086 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2088 SMESH::long_array_var info = theMesh->GetMeshInfo();
2089 long nbOdElems = info[SMDSEntity_0D];
2090 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2091 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2092 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2093 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2094 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2095 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2096 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2097 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2098 info[SMDSEntity_Polyhedra] +
2099 info[SMDSEntity_Hexagonal_Prism];
2100 long nbBalls = info[SMDSEntity_Ball];
2102 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2103 *nbElements = requestedSize;
2105 *entities = SMESH_Actor::eAllEntity;
2108 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2110 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2112 if ( incrementalLimit ) {
2115 if ( nbOdElems > 0 ) {
2116 if ( total + nbOdElems > updateLimit ) {
2117 *entities = *entities & ~SMESH_Actor::e0DElements;
2118 *hidden = *hidden | SMESH_Actor::e0DElements;
2125 if ( nbEdges > 0 ) {
2126 if ( total + nbEdges > updateLimit ) {
2127 *entities = *entities & ~SMESH_Actor::eEdges;
2128 *hidden = *hidden | SMESH_Actor::eEdges;
2135 if ( nbFaces > 0 ) {
2136 if ( total + nbFaces > updateLimit ) {
2137 *entities = *entities & ~SMESH_Actor::eFaces;
2138 *hidden = *hidden | SMESH_Actor::eFaces;
2145 if ( nbVolumes > 0 ) {
2146 if ( total + nbVolumes > updateLimit ) {
2147 *entities = *entities & ~SMESH_Actor::eVolumes;
2148 *hidden = *hidden | SMESH_Actor::eVolumes;
2155 if ( nbBalls > 0 ) {
2156 if ( total + nbBalls > updateLimit ) {
2157 *entities = *entities & ~SMESH_Actor::eBallElem;
2158 *hidden = *hidden | SMESH_Actor::eBallElem;
2166 return autoUpdate && !exceeded;
2169 //=============================================================================
2173 //=============================================================================
2174 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2176 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2179 //=============================================================================
2183 //=============================================================================
2184 SMESHGUI* SMESHGUI::GetSMESHGUI()
2186 SMESHGUI* smeshMod = 0;
2187 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2190 CAM_Module* module = app->module( "Mesh" );
2191 smeshMod = dynamic_cast<SMESHGUI*>( module );
2199 Standard_EXPORT SMESHGUI* GetComponentGUI()
2201 return SMESHGUI::GetSMESHGUI();
2205 //=============================================================================
2209 //=============================================================================
2210 void SMESHGUI::SetState(int aState)
2215 //=============================================================================
2219 //=============================================================================
2220 void SMESHGUI::ResetState()
2225 //=============================================================================
2229 //=============================================================================
2230 void SMESHGUI::EmitSignalDeactivateDialog()
2232 emit SignalDeactivateActiveDialog();
2235 //=============================================================================
2239 //=============================================================================
2240 void SMESHGUI::EmitSignalStudyFrameChanged()
2242 emit SignalStudyFrameChanged();
2245 //=============================================================================
2249 //=============================================================================
2250 void SMESHGUI::EmitSignalCloseAllDialogs()
2252 emit SignalCloseAllDialogs();
2255 //=============================================================================
2259 //=============================================================================
2260 void SMESHGUI::EmitSignalVisibilityChanged()
2262 emit SignalVisibilityChanged();
2265 //=============================================================================
2269 //=============================================================================
2270 void SMESHGUI::EmitSignalCloseView()
2272 emit SignalCloseView();
2275 //=============================================================================
2279 //=============================================================================
2280 void SMESHGUI::EmitSignalActivatedViewManager()
2282 emit SignalActivatedViewManager();
2285 //=============================================================================
2289 //=============================================================================
2290 QDialog *SMESHGUI::GetActiveDialogBox()
2292 return myActiveDialogBox;
2295 //=============================================================================
2299 //=============================================================================
2300 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2302 myActiveDialogBox = (QDialog *) aDlg;
2306 //=============================================================================
2310 //=============================================================================
2311 SUIT_Desktop* SMESHGUI::desktop()
2313 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2315 return app->desktop();
2320 //=============================================================================
2324 //=============================================================================
2325 SalomeApp_Study* SMESHGUI::activeStudy()
2327 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2329 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2334 //=============================================================================
2338 //=============================================================================
2339 void SMESHGUI::Modified( bool theIsUpdateActions )
2341 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2342 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2343 appStudy->Modified();
2344 if( theIsUpdateActions )
2345 app->updateActions();
2350 //=============================================================================
2354 //=============================================================================
2355 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2357 /* Here the position is on the bottom right corner - 10 */
2358 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2360 SUIT_Desktop *PP = desktop();
2361 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2362 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2367 * \brief Verifies whether study of operation is locked
2368 * \param theMess - specifies whether message box must be shown if study is locked
2369 * \return State of study.
2371 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2372 * is locked when corresponding message box appears
2374 bool SMESHGUI::isStudyLocked( bool theMessage )
2376 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2379 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2380 QObject::tr( "WRN_WARNING" ),
2381 QObject::tr( "WRN_STUDY_LOCKED" ) );
2387 //=============================================================================
2391 //=============================================================================
2392 bool SMESHGUI::OnGUIEvent( int theCommandID )
2394 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2398 SUIT_ResourceMgr* mgr = resourceMgr();
2402 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2403 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2405 //QAction* act = action( theCommandID );
2407 switch (theCommandID) {
2408 case SMESHOp::OpDelete:
2409 if(isStudyLocked()) break;
2412 case SMESHOp::OpImportDAT:
2413 case SMESHOp::OpImportUNV:
2414 case SMESHOp::OpImportMED:
2415 case SMESHOp::OpImportSTL:
2416 case SMESHOp::OpImportCGNS:
2417 case SMESHOp::OpImportSAUV:
2418 case SMESHOp::OpImportGMF:
2419 case SMESHOp::OpPopupImportDAT:
2420 case SMESHOp::OpPopupImportUNV:
2421 case SMESHOp::OpPopupImportMED:
2422 case SMESHOp::OpPopupImportSTL:
2423 case SMESHOp::OpPopupImportCGNS:
2424 case SMESHOp::OpPopupImportSAUV:
2425 case SMESHOp::OpPopupImportGMF:
2427 if(isStudyLocked()) break;
2428 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2432 case SMESHOp::OpFileInformation:
2434 SALOME_ListIO selected;
2435 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2437 aSel->selectedObjects( selected );
2438 if( selected.Extent() )
2440 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2441 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2442 if ( !aMesh->_is_nil() )
2444 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2450 case SMESHOp::OpExportDAT:
2451 case SMESHOp::OpExportMED:
2452 case SMESHOp::OpExportUNV:
2453 case SMESHOp::OpExportSTL:
2454 case SMESHOp::OpExportCGNS:
2455 case SMESHOp::OpExportSAUV:
2456 case SMESHOp::OpExportGMF:
2457 case SMESHOp::OpPopupExportDAT:
2458 case SMESHOp::OpPopupExportMED:
2459 case SMESHOp::OpPopupExportUNV:
2460 case SMESHOp::OpPopupExportSTL:
2461 case SMESHOp::OpPopupExportCGNS:
2462 case SMESHOp::OpPopupExportSAUV:
2463 case SMESHOp::OpPopupExportGMF:
2465 ::ExportMeshToFile(theCommandID);
2469 case SMESHOp::OpReset: // SCALAR BAR
2471 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2472 SALOME_ListIO selected;
2474 aSel->selectedObjects( selected );
2476 SALOME_ListIteratorOfListIO it(selected);
2477 for( ; it.More(); it.Next()) {
2478 Handle(SALOME_InteractiveObject) anIO = it.Value();
2479 if( anIO->hasEntry() ) {
2480 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2481 anActor->SetControlMode( SMESH_Actor::eNone );
2482 #ifndef DISABLE_PLOT2DVIEWER
2483 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2488 SMESH::UpdateView();
2491 case SMESHOp::OpScalarBarProperties:
2493 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2496 case SMESHOp::OpShowScalarBar:
2498 // show/hide scalar bar
2499 ::ShowElement(theCommandID);
2502 case SMESHOp::OpSaveDistribution:
2504 // dump control distribution data to the text file
2505 ::SaveDistribution();
2509 case SMESHOp::OpShowDistribution:
2511 // show/hide distribution
2512 ::ShowElement(theCommandID);
2516 #ifndef DISABLE_PLOT2DVIEWER
2517 case SMESHOp::OpPlotDistribution:
2519 // plot distribution
2520 ::PlotDistribution();
2526 case SMESHOp::OpAutoColor:
2530 case SMESHOp::OpDisableAutoColor:
2531 ::DisableAutoColor();
2534 case SMESHOp::OpClipping:
2535 case SMESHOp::OpTransparency:
2536 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2539 case SMESHOp::OpDMWireframe:
2540 case SMESHOp::OpDMShading:
2541 case SMESHOp::OpDMNodes:
2542 case SMESHOp::OpDMShrink:
2543 ::SetDisplayMode(theCommandID, myMarkerMap);
2546 //2D quadratic representation
2547 case SMESHOp::OpRepresentationLines:
2548 case SMESHOp::OpRepresentationArcs:
2549 ::SetDisplayMode(theCommandID, myMarkerMap);
2553 case SMESHOp::OpDE0DElements:
2554 case SMESHOp::OpDEEdges:
2555 case SMESHOp::OpDEFaces:
2556 case SMESHOp::OpDEVolumes:
2557 case SMESHOp::OpDEBalls:
2558 case SMESHOp::OpDEAllEntity:
2559 ::SetDisplayEntity(theCommandID);
2562 // Choose entities to be displayed
2563 case SMESHOp::OpDEChoose:
2565 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2569 case SMESHOp::OpOrientationOnFaces:
2571 SUIT_OverrideCursor wc;
2572 LightApp_SelectionMgr* mgr = selectionMgr();
2573 SALOME_ListIO selected; mgr->selectedObjects( selected );
2575 SALOME_ListIteratorOfListIO it(selected);
2576 for( ; it.More(); it.Next()) {
2577 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2578 if(anIObject->hasEntry()) {
2579 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2580 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2587 case SMESHOp::OpUpdate:
2589 if(isStudyLocked()) break;
2590 SUIT_OverrideCursor wc;
2593 SMESH::UpdateView();
2595 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2596 SMESH::OnVisuException();
2598 catch (...) { // PAL16774 (Crash after display of many groups)
2599 SMESH::OnVisuException();
2603 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2604 aSel->selectedObjects( l );
2605 aSel->setSelectedObjects( l );
2609 case SMESHOp::OpHide:
2610 case SMESHOp::OpShow:
2611 case SMESHOp::OpShowOnly:
2613 SUIT_OverrideCursor wc;
2614 SMESH::EDisplaing anAction;
2615 switch (theCommandID) {
2616 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2617 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2618 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2621 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2622 SALOME_ListIO sel_objects, to_process;
2624 aSel->selectedObjects( sel_objects );
2626 if ( theCommandID==SMESHOp::OpShowOnly )
2628 //MESSAGE("anAction = SMESH::eDisplayOnly");
2629 startOperation( myEraseAll );
2632 extractContainers( sel_objects, to_process );
2637 SALOME_ListIteratorOfListIO It( to_process );
2638 for ( ; It.More(); It.Next())
2640 Handle(SALOME_InteractiveObject) IOS = It.Value();
2641 if ( IOS->hasEntry() )
2643 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2644 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2645 break; // PAL16774 (Crash after display of many groups)
2647 if (anAction == SMESH::eDisplayOnly)
2648 anAction = SMESH::eDisplay;
2653 // PAL13338 + PAL15161 -->
2654 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2655 SMESH::UpdateView();
2656 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2658 // PAL13338 + PAL15161 <--
2660 catch (...) { // PAL16774 (Crash after display of many groups)
2661 SMESH::OnVisuException();
2664 if (anAction == SMESH::eErase) {
2666 aSel->setSelectedObjects( l1 );
2669 aSel->setSelectedObjects( to_process );
2674 case SMESHOp::OpNode:
2676 if(isStudyLocked()) break;
2679 EmitSignalDeactivateDialog();
2681 ( new SMESHGUI_NodesDlg( this ) )->show();
2684 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2689 case SMESHOp::OpCreateMesh:
2690 case SMESHOp::OpCreateSubMesh:
2691 case SMESHOp::OpEditMeshOrSubMesh:
2692 case SMESHOp::OpEditMesh:
2693 case SMESHOp::OpEditSubMesh:
2694 case SMESHOp::OpCompute:
2695 case SMESHOp::OpComputeSubMesh:
2696 case SMESHOp::OpPreCompute:
2697 case SMESHOp::OpEvaluate:
2698 case SMESHOp::OpMeshOrder:
2699 startOperation( theCommandID );
2701 case SMESHOp::OpCopyMesh:
2703 if (isStudyLocked()) break;
2704 EmitSignalDeactivateDialog();
2705 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2708 case SMESHOp::OpBuildCompoundMesh:
2710 if (isStudyLocked()) break;
2711 EmitSignalDeactivateDialog();
2712 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2716 case SMESHOp::OpDiagonalInversion:
2717 case SMESHOp::OpUnionOfTwoTriangle:
2721 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2725 if ( isStudyLocked() )
2728 /*Standard_Boolean aRes;
2729 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2730 if ( aMesh->_is_nil() )
2732 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2733 tr( "SMESH_BAD_SELECTION" ) );
2737 EmitSignalDeactivateDialog();
2738 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2739 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2741 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2744 case SMESHOp::OpOrientation:
2745 case SMESHOp::OpUnionOfTriangles:
2746 case SMESHOp::OpCuttingOfQuadrangles:
2747 case SMESHOp::OpSplitVolumes:
2751 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2755 if ( isStudyLocked() )
2758 EmitSignalDeactivateDialog();
2759 SMESHGUI_MultiEditDlg* aDlg = NULL;
2760 if ( theCommandID == SMESHOp::OpOrientation )
2761 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2762 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2763 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2764 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2765 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2767 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2772 case SMESHOp::OpSmoothing:
2774 if(isStudyLocked()) break;
2776 EmitSignalDeactivateDialog();
2777 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2780 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2784 case SMESHOp::OpExtrusion:
2786 if (isStudyLocked()) break;
2788 EmitSignalDeactivateDialog();
2789 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2791 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2795 case SMESHOp::OpExtrusionAlongAPath:
2797 if (isStudyLocked()) break;
2799 EmitSignalDeactivateDialog();
2800 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2802 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2806 case SMESHOp::OpRevolution:
2808 if(isStudyLocked()) break;
2810 EmitSignalDeactivateDialog();
2811 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2814 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2818 case SMESHOp::OpPatternMapping:
2820 if ( isStudyLocked() )
2824 EmitSignalDeactivateDialog();
2825 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2828 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2832 case SMESHOp::OpSplitBiQuadratic:
2833 case SMESHOp::OpConvertMeshToQuadratic:
2834 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2835 case SMESHOp::OpReorientFaces:
2836 case SMESHOp::OpCreateGeometryGroup:
2838 startOperation( theCommandID );
2841 case SMESHOp::OpCreateGroup:
2845 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2849 if(isStudyLocked()) break;
2850 EmitSignalDeactivateDialog();
2851 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2853 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2854 SALOME_ListIO selected;
2856 aSel->selectedObjects( selected );
2858 int nbSel = selected.Extent();
2860 // check if mesh is selected
2861 aMesh = SMESH::GetMeshByIO( selected.First() );
2863 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2868 case SMESHOp::OpConstructGroup:
2872 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2876 if(isStudyLocked()) break;
2877 EmitSignalDeactivateDialog();
2879 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2880 SALOME_ListIO selected;
2882 aSel->selectedObjects( selected );
2884 int nbSel = selected.Extent();
2886 // check if submesh is selected
2887 Handle(SALOME_InteractiveObject) IObject = selected.First();
2888 if (IObject->hasEntry()) {
2889 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
2891 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2892 if (!aSubMesh->_is_nil()) {
2894 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2895 // get submesh elements list by types
2896 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2897 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2898 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2899 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2900 // create group for each type o elements
2901 QString aName = IObject->getName();
2902 QStringList anEntryList;
2903 if (aNodes->length() > 0) {
2904 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2905 aGroup->Add(aNodes.inout());
2906 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2907 anEntryList.append( aSObject->GetID().c_str() );
2909 if (aEdges->length() > 0) {
2910 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2911 aGroup->Add(aEdges.inout());
2912 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2913 anEntryList.append( aSObject->GetID().c_str() );
2915 if (aFaces->length() > 0) {
2916 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2917 aGroup->Add(aFaces.inout());
2918 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2919 anEntryList.append( aSObject->GetID().c_str() );
2921 if (aVolumes->length() > 0) {
2922 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2923 aGroup->Add(aVolumes.inout());
2924 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2925 anEntryList.append( aSObject->GetID().c_str() );
2928 anApp->browseObjects( anEntryList );
2930 catch(const SALOME::SALOME_Exception & S_ex){
2931 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2938 SUIT_MessageBox::warning(desktop(),
2939 tr("SMESH_WRN_WARNING"),
2940 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2945 case SMESHOp::OpEditGroup:
2949 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2953 if(isStudyLocked()) break;
2954 EmitSignalDeactivateDialog();
2956 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2957 SALOME_ListIO selected;
2959 aSel->selectedObjects( selected );
2961 SALOME_ListIteratorOfListIO It (selected);
2962 int nbSelectedGroups = 0;
2963 for ( ; It.More(); It.Next() )
2965 SMESH::SMESH_GroupBase_var aGroup =
2966 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2967 if (!aGroup->_is_nil()) {
2969 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2973 if (nbSelectedGroups == 0)
2975 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2981 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
2983 if(isStudyLocked()) break;
2984 if (myState == 800) {
2985 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2986 if (aDlg) aDlg->onAdd();
2991 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
2993 if(isStudyLocked()) break;
2994 if (myState == 800) {
2995 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2996 if (aDlg) aDlg->onRemove();
3001 case SMESHOp::OpEditGeomGroupAsGroup:
3005 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3009 if(isStudyLocked()) break;
3010 EmitSignalDeactivateDialog();
3012 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3013 SALOME_ListIO selected;
3015 aSel->selectedObjects( selected );
3017 SALOME_ListIteratorOfListIO It (selected);
3018 for ( ; It.More(); It.Next() )
3020 SMESH::SMESH_GroupOnGeom_var aGroup =
3021 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3022 if (!aGroup->_is_nil()) {
3023 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3028 SMESH::SMESH_GroupOnFilter_var aGroup =
3029 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3030 if (!aGroup->_is_nil()) {
3031 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3039 case SMESHOp::OpUnionGroups:
3040 case SMESHOp::OpIntersectGroups:
3041 case SMESHOp::OpCutGroups:
3045 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3049 if ( isStudyLocked() )
3052 EmitSignalDeactivateDialog();
3054 SMESHGUI_GroupOpDlg* aDlg = 0;
3055 if ( theCommandID == SMESHOp::OpUnionGroups )
3056 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3057 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3058 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3060 aDlg = new SMESHGUI_CutGroupsDlg( this );
3067 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3069 if ( isStudyLocked() )
3072 EmitSignalDeactivateDialog();
3073 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3079 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3083 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3087 if ( isStudyLocked() )
3090 EmitSignalDeactivateDialog();
3092 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3096 case SMESHOp::OpMeshInformation:
3097 case SMESHOp::OpWhatIs:
3099 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3100 EmitSignalDeactivateDialog();
3101 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3102 SALOME_ListIO selected;
3104 aSel->selectedObjects( selected );
3106 if ( selected.Extent() > 1 ) { // a dlg for each IO
3107 SALOME_ListIteratorOfListIO It( selected );
3108 for ( ; It.More(); It.Next() ) {
3109 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3110 dlg->showInfo( It.Value() );
3115 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3121 case SMESHOp::OpFindElementByPoint:
3123 startOperation( theCommandID );
3127 case SMESHOp::OpEditHypothesis:
3129 if(isStudyLocked()) break;
3131 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3132 SALOME_ListIO selected;
3134 aSel->selectedObjects( selected );
3136 int nbSel = selected.Extent();
3139 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3140 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3142 if ( !aHypothesis->_is_nil() )
3144 SMESHGUI_GenericHypothesisCreator* aCreator =
3145 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3148 // set geometry of mesh and sub-mesh to aCreator
3149 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3150 if ( selected.Extent() == 1 )
3152 QString subGeomID, meshGeomID;
3153 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3154 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3156 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3157 aCreator->setShapeEntry( subGeomID );
3158 aCreator->setMainShapeEntry( meshGeomID );
3162 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3172 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3174 if(isStudyLocked()) break;
3175 SUIT_OverrideCursor wc;
3177 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3178 SALOME_ListIO selected;
3180 aSel->selectedObjects( selected, QString::null, false );
3182 SALOME_ListIteratorOfListIO It(selected);
3183 for (int i = 0; It.More(); It.Next(), i++) {
3184 Handle(SALOME_InteractiveObject) IObject = It.Value();
3185 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3188 aSel->setSelectedObjects( l1 );
3193 case SMESHOp::OpElem0D:
3194 case SMESHOp::OpBall:
3195 case SMESHOp::OpEdge:
3196 case SMESHOp::OpTriangle:
3197 case SMESHOp::OpQuadrangle:
3198 case SMESHOp::OpPolygon:
3199 case SMESHOp::OpTetrahedron:
3200 case SMESHOp::OpHexahedron:
3201 case SMESHOp::OpPentahedron:
3202 case SMESHOp::OpPyramid:
3203 case SMESHOp::OpHexagonalPrism:
3205 if(isStudyLocked()) break;
3207 EmitSignalDeactivateDialog();
3208 SMDSAbs_EntityType type = SMDSEntity_Edge;
3209 switch (theCommandID) {
3210 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3211 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3212 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3213 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3214 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3215 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3216 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3217 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3218 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3219 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3222 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3225 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3229 case SMESHOp::OpPolyhedron:
3231 if(isStudyLocked()) break;
3233 EmitSignalDeactivateDialog();
3234 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3237 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3241 case SMESHOp::OpQuadraticEdge:
3242 case SMESHOp::OpQuadraticTriangle:
3243 case SMESHOp::OpBiQuadraticTriangle:
3244 case SMESHOp::OpQuadraticQuadrangle:
3245 case SMESHOp::OpBiQuadraticQuadrangle:
3246 case SMESHOp::OpQuadraticPolygon:
3247 case SMESHOp::OpQuadraticTetrahedron:
3248 case SMESHOp::OpQuadraticPyramid:
3249 case SMESHOp::OpQuadraticPentahedron:
3250 case SMESHOp::OpBiQuadraticPentahedron:
3251 case SMESHOp::OpQuadraticHexahedron:
3252 case SMESHOp::OpTriQuadraticHexahedron:
3254 if(isStudyLocked()) break;
3256 EmitSignalDeactivateDialog();
3257 SMDSAbs_EntityType type = SMDSEntity_Last;
3259 switch (theCommandID) {
3260 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3261 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3262 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3263 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3264 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3265 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3266 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3267 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3268 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3269 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3270 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3271 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3274 if ( type != SMDSEntity_Last )
3275 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3278 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3279 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3283 case SMESHOp::OpRemoveNodes:
3285 if(isStudyLocked()) break;
3287 EmitSignalDeactivateDialog();
3288 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3291 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3292 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3296 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3298 if(isStudyLocked()) break;
3300 EmitSignalDeactivateDialog();
3301 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3305 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3306 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3310 case SMESHOp::OpClearMesh: {
3312 if(isStudyLocked()) break;
3314 SALOME_ListIO selected;
3315 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3316 aSel->selectedObjects( selected );
3318 SUIT_OverrideCursor wc;
3319 SALOME_ListIteratorOfListIO It (selected);
3320 for ( ; It.More(); It.Next() )
3322 Handle(SALOME_InteractiveObject) IOS = It.Value();
3323 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3324 if ( aMesh->_is_nil()) continue;
3327 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3328 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3329 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3330 // hide groups and submeshes
3331 _PTR(ChildIterator) anIter =
3332 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3333 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3335 _PTR(SObject) so = anIter->Value();
3336 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3339 catch (const SALOME::SALOME_Exception& S_ex){
3341 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3345 SMESH::UpdateView();
3349 case SMESHOp::OpRemoveOrphanNodes:
3351 if(isStudyLocked()) break;
3352 SALOME_ListIO selected;
3353 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3354 aSel->selectedObjects( selected );
3355 if ( selected.Extent() == 1 ) {
3356 Handle(SALOME_InteractiveObject) anIO = selected.First();
3357 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3358 if ( !aMesh->_is_nil() ) {
3359 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3360 tr( "SMESH_WARNING" ),
3361 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3362 SUIT_MessageBox::Yes |
3363 SUIT_MessageBox::No,
3364 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3367 SUIT_OverrideCursor wc;
3368 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3369 int removed = aMeshEditor->RemoveOrphanNodes();
3370 SUIT_MessageBox::information(SMESHGUI::desktop(),
3371 tr("SMESH_INFORMATION"),
3372 tr("NB_NODES_REMOVED").arg(removed));
3373 if ( removed > 0 ) {
3374 SMESH::UpdateView();
3375 SMESHGUI::Modified();
3378 catch (const SALOME::SALOME_Exception& S_ex) {
3379 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3388 case SMESHOp::OpRenumberingNodes:
3390 if(isStudyLocked()) break;
3392 EmitSignalDeactivateDialog();
3393 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3397 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3398 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3402 case SMESHOp::OpRenumberingElements:
3404 if(isStudyLocked()) break;
3406 EmitSignalDeactivateDialog();
3407 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3411 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3412 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3416 case SMESHOp::OpTranslation:
3418 if(isStudyLocked()) break;
3420 EmitSignalDeactivateDialog();
3421 ( new SMESHGUI_TranslationDlg( this ) )->show();
3424 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3425 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3429 case SMESHOp::OpRotation:
3431 if(isStudyLocked()) break;
3433 EmitSignalDeactivateDialog();
3434 ( new SMESHGUI_RotationDlg( this ) )->show();
3437 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3438 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3442 case SMESHOp::OpSymmetry:
3444 if(isStudyLocked()) break;
3446 EmitSignalDeactivateDialog();
3447 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3450 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3451 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3455 case SMESHOp::OpScale:
3457 if(isStudyLocked()) break;
3459 EmitSignalDeactivateDialog();
3460 ( new SMESHGUI_ScaleDlg( this ) )->show();
3463 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3464 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3469 case SMESHOp::OpOffset:
3471 if(isStudyLocked()) break;
3473 EmitSignalDeactivateDialog();
3474 ( new SMESHGUI_OffsetDlg( this ) )->show();
3477 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3478 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3483 case SMESHOp::OpSewing:
3485 if(isStudyLocked()) break;
3487 EmitSignalDeactivateDialog();
3488 ( new SMESHGUI_SewingDlg( this ) )->show();
3491 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3492 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3496 case SMESHOp::OpMergeNodes:
3498 if(isStudyLocked()) break;
3500 EmitSignalDeactivateDialog();
3501 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3504 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3505 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3509 case SMESHOp::OpMergeElements:
3511 if (isStudyLocked()) break;
3513 EmitSignalDeactivateDialog();
3514 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3516 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3517 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3522 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3523 startOperation( SMESHOp::OpMoveNode );
3526 case SMESHOp::OpDuplicateNodes:
3528 if(isStudyLocked()) break;
3530 EmitSignalDeactivateDialog();
3531 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3534 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3535 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3540 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3541 startOperation( SMESHOp::OpElem0DOnElemNodes );
3544 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3546 static QList<int> aTypes;
3547 if ( aTypes.isEmpty() )
3549 aTypes.append( SMESH::NODE );
3550 aTypes.append( SMESH::EDGE );
3551 aTypes.append( SMESH::FACE );
3552 aTypes.append( SMESH::VOLUME );
3554 if (!myFilterLibraryDlg)
3555 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3556 else if (myFilterLibraryDlg->isHidden())
3557 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3558 myFilterLibraryDlg->raise();
3562 case SMESHOp::OpFreeNode:
3563 case SMESHOp::OpEqualNode:
3564 case SMESHOp::OpNodeConnectivityNb:
3565 case SMESHOp::OpFreeEdge:
3566 case SMESHOp::OpFreeBorder:
3567 case SMESHOp::OpLength:
3568 case SMESHOp::OpConnection:
3569 case SMESHOp::OpEqualEdge:
3570 case SMESHOp::OpFreeFace:
3571 case SMESHOp::OpBareBorderFace:
3572 case SMESHOp::OpOverConstrainedFace:
3573 case SMESHOp::OpLength2D:
3574 case SMESHOp::OpDeflection2D:
3575 case SMESHOp::OpConnection2D:
3576 case SMESHOp::OpArea:
3577 case SMESHOp::OpTaper:
3578 case SMESHOp::OpAspectRatio:
3579 case SMESHOp::OpMinimumAngle:
3580 case SMESHOp::OpWarpingAngle:
3581 case SMESHOp::OpSkew:
3582 case SMESHOp::OpMaxElementLength2D:
3583 case SMESHOp::OpEqualFace:
3584 case SMESHOp::OpAspectRatio3D:
3585 case SMESHOp::OpVolume:
3586 case SMESHOp::OpMaxElementLength3D:
3587 case SMESHOp::OpBareBorderVolume:
3588 case SMESHOp::OpOverConstrainedVolume:
3589 case SMESHOp::OpEqualVolume:
3592 LightApp_SelectionMgr* mgr = selectionMgr();
3593 SALOME_ListIO selected; mgr->selectedObjects( selected );
3595 if( !selected.IsEmpty() ) {
3596 SUIT_OverrideCursor wc;
3597 ::Control( theCommandID );
3600 SUIT_MessageBox::warning(desktop(),
3601 tr( "SMESH_WRN_WARNING" ),
3602 tr( "SMESH_BAD_SELECTION" ) );
3606 SUIT_MessageBox::warning(desktop(),
3607 tr( "SMESH_WRN_WARNING" ),
3608 tr( "NOT_A_VTK_VIEWER" ) );
3611 case SMESHOp::OpOverallMeshQuality:
3612 OverallMeshQuality();
3614 case SMESHOp::OpNumberingNodes:
3616 SUIT_OverrideCursor wc;
3617 LightApp_SelectionMgr* mgr = selectionMgr();
3618 SALOME_ListIO selected; mgr->selectedObjects( selected );
3620 SALOME_ListIteratorOfListIO it(selected);
3621 for( ; it.More(); it.Next()) {
3622 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3623 if(anIObject->hasEntry()) {
3624 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3625 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3631 case SMESHOp::OpNumberingElements:
3633 SUIT_OverrideCursor wc;
3634 LightApp_SelectionMgr* mgr = selectionMgr();
3635 SALOME_ListIO selected; mgr->selectedObjects( selected );
3637 SALOME_ListIteratorOfListIO it(selected);
3638 for( ; it.More(); it.Next()) {
3639 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3640 if(anIObject->hasEntry())
3641 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3642 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3647 case SMESHOp::OpPropertiesLength:
3648 case SMESHOp::OpPropertiesArea:
3649 case SMESHOp::OpPropertiesVolume:
3650 case SMESHOp::OpMinimumDistance:
3651 case SMESHOp::OpBoundingBox:
3653 int page = SMESHGUI_MeasureDlg::MinDistance;
3654 if ( theCommandID == SMESHOp::OpBoundingBox )
3655 page = SMESHGUI_MeasureDlg::BoundingBox;
3656 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3657 page = SMESHGUI_MeasureDlg::Length;
3658 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3659 page = SMESHGUI_MeasureDlg::Area;
3660 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3661 page = SMESHGUI_MeasureDlg::Volume;
3663 EmitSignalDeactivateDialog();
3664 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3668 case SMESHOp::OpSortChild:
3674 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3675 //updateObjBrowser();
3679 //=============================================================================
3683 //=============================================================================
3684 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3689 //=============================================================================
3693 //=============================================================================
3694 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3699 //=============================================================================
3703 //=============================================================================
3704 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3709 //=============================================================================
3710 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3711 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3713 //=============================================================================
3714 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3715 SUIT_ViewWindow* wnd )
3717 if(theIO->hasEntry()){
3718 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3719 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3723 //=======================================================================
3724 // function : createSMESHAction
3726 //=======================================================================
3727 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3728 const int key, const bool toggle, const QString& shortcutAction )
3731 QWidget* parent = application()->desktop();
3732 SUIT_ResourceMgr* resMgr = resourceMgr();
3734 if ( !icon_id.isEmpty() )
3735 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3737 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3738 if ( !pix.isNull() )
3739 icon = QIcon( pix );
3741 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3742 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3743 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3745 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3746 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3749 //=======================================================================
3750 // function : createPopupItem
3752 //=======================================================================
3753 void SMESHGUI::createPopupItem( const int id,
3754 const QString& clients,
3755 const QString& types,
3756 const QString& theRule,
3759 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3760 popupMgr()->insert( action( id ), pId, 0 );
3762 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3763 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3764 QString rule = "(%1) and (%2) and (%3)";
3765 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3766 if( clients.isEmpty() )
3767 rule = rule.arg( QString( "true" ) );
3769 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3770 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3773 bool cont = myRules.contains( id );
3775 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3777 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3778 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3781 //=======================================================================
3782 // function : initialize
3784 //=======================================================================
3785 void SMESHGUI::initialize( CAM_Application* app )
3787 SalomeApp_Module::initialize( app );
3789 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3791 /* Automatic Update flag */
3792 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3794 // ----- create actions --------------
3796 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3797 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
3798 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3799 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
3801 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
3803 createSMESHAction( SMESHOp::OpImportSAUV, "IMPORT_SAUV" );
3804 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
3805 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
3806 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
3807 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
3809 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
3811 createSMESHAction( SMESHOp::OpPopupImportSAUV, "IMPORT_SAUV" );
3812 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
3814 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
3815 createSMESHAction( SMESHOp::OpExportMED, "MED" );
3816 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
3817 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
3819 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
3821 createSMESHAction( SMESHOp::OpExportSAUV, "SAUV");
3822 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
3823 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
3824 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
3825 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
3826 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
3828 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
3830 createSMESHAction( SMESHOp::OpPopupExportSAUV, "SAUV");
3831 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
3832 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
3833 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3834 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
3835 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3836 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3837 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
3838 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
3839 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
3840 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3841 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
3842 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
3843 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
3844 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3845 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
3846 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
3847 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3848 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
3849 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3850 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3851 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3852 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
3853 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
3854 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
3855 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
3856 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
3857 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
3858 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
3859 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
3860 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
3861 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3862 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
3864 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3865 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3866 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
3867 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3868 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3869 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
3870 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
3871 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3872 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3873 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3874 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3875 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3876 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
3877 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3878 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
3879 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
3880 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
3881 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
3882 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
3883 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
3884 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3885 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3886 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3887 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3888 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3889 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3890 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3891 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3892 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
3894 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
3895 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
3896 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3897 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
3898 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
3899 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3900 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
3901 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
3902 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
3903 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
3904 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
3905 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
3906 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
3907 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3908 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3909 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3910 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3911 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3912 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3913 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
3914 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3915 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3916 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3917 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
3918 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3919 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3921 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3922 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3923 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3924 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
3926 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3927 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3929 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3930 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
3931 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3932 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
3933 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
3934 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3935 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
3936 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3937 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3938 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3939 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
3940 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
3941 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3942 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
3943 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
3944 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
3945 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3946 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
3947 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
3948 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
3949 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3950 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
3951 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
3952 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3953 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3955 createSMESHAction( SMESHOp::OpReset, "RESET" );
3956 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
3957 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
3958 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
3959 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
3960 #ifndef DISABLE_PLOT2DVIEWER
3961 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
3963 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
3964 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
3965 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
3966 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
3967 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
3968 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3969 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
3970 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3971 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3972 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
3973 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
3974 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
3975 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
3977 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
3978 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
3980 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
3981 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
3982 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
3983 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
3984 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
3985 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
3986 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
3987 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
3988 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
3990 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3991 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3992 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
3993 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
3994 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
3996 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
3997 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
3998 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4000 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4002 QList<int> aCtrlActions;
4003 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4004 << SMESHOp::OpNodeConnectivityNb // node controls
4005 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4006 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4007 << SMESHOp::OpDeflection2D
4008 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4009 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4010 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4011 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4012 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4013 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4014 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4015 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4016 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4017 aCtrlGroup->setExclusive( true );
4018 for( int i = 0; i < aCtrlActions.size(); i++ )
4019 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4021 // ----- create menu --------------
4022 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4023 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4024 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4025 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4026 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4027 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4028 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4029 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4031 createMenu( separator(), fileId );
4033 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4034 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4035 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4036 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4037 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4038 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4039 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4040 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4041 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4042 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4043 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4044 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4045 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4047 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4048 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4049 createMenu( SMESHOp::OpImportMED, importId, -1 );
4050 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4052 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4054 createMenu( SMESHOp::OpImportSAUV, importId, -1 );
4055 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4056 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4057 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4058 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4059 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4061 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4063 createMenu( SMESHOp::OpExportSAUV, exportId, -1 );
4064 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4065 createMenu( separator(), fileId, 10 );
4067 createMenu( SMESHOp::OpDelete, editId, -1 );
4069 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4071 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4072 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4073 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4074 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4075 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4076 createMenu( separator(), meshId, -1 );
4077 createMenu( SMESHOp::OpCompute, meshId, -1 );
4078 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4079 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4080 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4081 createMenu( separator(), meshId, -1 );
4082 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4083 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4084 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4085 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4086 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4087 createMenu( separator(), meshId, -1 );
4088 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4089 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4090 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4091 createMenu( separator(), meshId, -1 );
4092 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4093 createMenu( separator(), meshId, -1 );
4094 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4095 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4096 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4097 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4098 createMenu( separator(), meshId, -1 );
4100 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4101 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4102 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4103 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4104 createMenu( SMESHOp::OpLength, edgeId, -1 );
4105 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4106 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4107 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4108 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4109 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4110 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4111 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4112 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4113 createMenu( SMESHOp::OpArea, faceId, -1 );
4114 createMenu( SMESHOp::OpTaper, faceId, -1 );
4115 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4116 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4117 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4118 createMenu( SMESHOp::OpSkew, faceId, -1 );
4119 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4120 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4121 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4122 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4123 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4124 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4125 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4126 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4127 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4128 createMenu( separator(), ctrlId, -1 );
4129 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4130 createMenu( separator(), ctrlId, -1 );
4131 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4133 createMenu( SMESHOp::OpNode, addId, -1 );
4134 createMenu( SMESHOp::OpElem0D, addId, -1 );
4135 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4136 createMenu( SMESHOp::OpBall, addId, -1 );
4137 createMenu( SMESHOp::OpEdge, addId, -1 );
4138 createMenu( SMESHOp::OpTriangle, addId, -1 );
4139 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4140 createMenu( SMESHOp::OpPolygon, addId, -1 );
4141 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4142 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4143 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4144 createMenu( SMESHOp::OpPyramid, addId, -1 );
4145 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4146 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4147 createMenu( separator(), addId, -1 );
4148 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4149 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4150 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4151 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4152 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4153 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4154 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4155 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4156 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4157 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4158 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4159 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4161 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4162 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4163 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4164 createMenu( separator(), removeId, -1 );
4165 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4166 createMenu( separator(), removeId, -1 );
4167 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4169 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4170 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4172 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4173 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4174 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4175 createMenu( SMESHOp::OpRotation, transfId, -1 );
4176 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4177 createMenu( SMESHOp::OpScale, transfId, -1 );
4178 createMenu( SMESHOp::OpOffset, transfId, -1 );
4179 createMenu( SMESHOp::OpSewing, transfId, -1 );
4180 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4182 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4183 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4184 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4185 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4186 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4187 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4188 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4189 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4190 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4191 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4192 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4193 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4194 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4195 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4196 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4197 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4199 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4200 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4201 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4202 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4203 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4204 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4206 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4207 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4208 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4209 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4211 // ----- create toolbars --------------
4212 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ),
4213 info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ),
4214 groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ),
4215 ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ),
4216 ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ),
4217 ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ),
4218 ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ),
4219 addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ),
4220 addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ),
4221 remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ),
4222 //renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ),
4223 transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
4224 modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ),
4225 measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ),
4226 dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4228 createTool( SMESHOp::OpCreateMesh, meshTb );
4229 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4230 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4231 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4232 createTool( SMESHOp::OpCopyMesh, meshTb );
4233 createTool( separator(), meshTb );
4234 createTool( SMESHOp::OpCompute, meshTb );
4235 createTool( SMESHOp::OpPreCompute, meshTb );
4236 createTool( SMESHOp::OpEvaluate, meshTb );
4237 createTool( SMESHOp::OpMeshOrder, meshTb );
4239 createTool( SMESHOp::OpCreateGroup, groupTb );
4240 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4241 createTool( SMESHOp::OpConstructGroup, groupTb );
4242 createTool( SMESHOp::OpEditGroup, groupTb );
4244 createTool( SMESHOp::OpMeshInformation, info );
4245 //createTool( SMESHOp::OpStdInfo, meshTb );
4246 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4247 createTool( SMESHOp::OpFindElementByPoint, info );
4249 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4250 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4251 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4253 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4254 createTool( SMESHOp::OpLength, ctrl1dTb );
4255 createTool( SMESHOp::OpConnection, ctrl1dTb );
4256 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4258 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4259 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4260 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4261 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4262 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4263 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4264 createTool( SMESHOp::OpArea, ctrl2dTb );
4265 createTool( SMESHOp::OpTaper, ctrl2dTb );
4266 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4267 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4268 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4269 createTool( SMESHOp::OpSkew, ctrl2dTb );
4270 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4271 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4272 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4274 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4275 createTool( SMESHOp::OpVolume, ctrl3dTb );
4276 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4277 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4278 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4279 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4281 createTool( SMESHOp::OpNode, addElemTb );
4282 createTool( SMESHOp::OpElem0D, addElemTb );
4283 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4284 createTool( SMESHOp::OpBall, addElemTb );
4285 createTool( SMESHOp::OpEdge, addElemTb );
4286 createTool( SMESHOp::OpTriangle, addElemTb );
4287 createTool( SMESHOp::OpQuadrangle, addElemTb );
4288 createTool( SMESHOp::OpPolygon, addElemTb );
4289 createTool( SMESHOp::OpTetrahedron, addElemTb );
4290 createTool( SMESHOp::OpHexahedron, addElemTb );
4291 createTool( SMESHOp::OpPentahedron, addElemTb );
4292 createTool( SMESHOp::OpPyramid, addElemTb );
4293 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4294 createTool( SMESHOp::OpPolyhedron, addElemTb );
4296 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4297 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4298 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4299 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4300 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4301 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4302 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4303 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4304 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4305 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4306 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4307 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4309 createTool( SMESHOp::OpRemoveNodes, remTb );
4310 createTool( SMESHOp::OpRemoveElements, remTb );
4311 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4312 createTool( SMESHOp::OpClearMesh, remTb );
4314 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4315 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4317 createTool( SMESHOp::OpMergeNodes, transformTb );
4318 createTool( SMESHOp::OpMergeElements, transformTb );
4319 createTool( SMESHOp::OpTranslation, transformTb );
4320 createTool( SMESHOp::OpRotation, transformTb );
4321 createTool( SMESHOp::OpSymmetry, transformTb );
4322 createTool( SMESHOp::OpScale, transformTb );
4323 createTool( SMESHOp::OpOffset, transformTb );
4324 createTool( SMESHOp::OpSewing, transformTb );
4325 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4327 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4328 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4329 createTool( SMESHOp::OpExtrusion, modifyTb );
4330 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4331 createTool( SMESHOp::OpRevolution, modifyTb );
4332 createTool( SMESHOp::OpOrientation, modifyTb );
4333 createTool( SMESHOp::OpReorientFaces, modifyTb );
4334 createTool( SMESHOp::OpMoveNode, modifyTb );
4335 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4336 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4337 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4338 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4339 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4340 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4341 createTool( SMESHOp::OpSmoothing, modifyTb );
4342 createTool( SMESHOp::OpPatternMapping, modifyTb );
4344 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4346 createTool( SMESHOp::OpUpdate, dispModeTb );
4348 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4349 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4353 OB = "'ObjectBrowser'",
4354 View = "'" + SVTK_Viewer::Type() + "'",
4356 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4357 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4358 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4359 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4360 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4361 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4362 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4363 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4364 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4365 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4366 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4367 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4369 mesh_part = mesh + " " + subMesh + " " + group,
4370 mesh_group = mesh + " " + group,
4371 mesh_submesh = mesh + " " + subMesh,
4372 hyp_alg = hypo + " " + algo;
4374 // popup for object browser
4376 isInvisible("not( isVisible )"),
4377 isEmpty("numberOfNodes = 0"),
4378 isNotEmpty("numberOfNodes <> 0"),
4380 // has nodes, edges, etc in VISIBLE! actor
4381 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4382 hasElems("(count( elemTypes ) > 0)"),
4383 hasDifferentElems("(count( elemTypes ) > 1)"),
4384 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4385 hasBalls("({'BallElem'} in elemTypes)"),
4386 hasElems0d("({'Elem0d'} in elemTypes)"),
4387 hasEdges("({'Edge'} in elemTypes)"),
4388 hasFaces("({'Face'} in elemTypes)"),
4389 hasVolumes("({'Volume'} in elemTypes)"),
4390 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4392 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4393 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4394 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4395 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4396 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4397 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4399 popupMgr()->insert( separator(), -1, 0 );
4400 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && isComputable" );
4401 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && isComputable" );
4402 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && isPreComputable" );
4403 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && isComputable" );
4404 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && isComputable && hasGeomReference" );
4405 createPopupItem( SMESHOp::OpUpdate, OB, mesh_part );
4406 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4407 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1" );
4408 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4409 popupMgr()->insert( separator(), -1, 0 );
4410 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4411 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4412 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4413 popupMgr()->insert( separator(), -1, 0 );
4414 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4415 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4416 popupMgr()->insert( separator(), -1, 0 );
4417 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh );
4418 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4419 popupMgr()->insert( separator(), -1, 0 );
4420 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4421 //popupMgr()->insert( separator(), -1, 0 );
4423 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4424 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4425 QString only_one_2D = only_one_non_empty + " && dim>1";
4427 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4428 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4429 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4430 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4432 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4434 createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
4435 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4436 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4437 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4438 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4440 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4441 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4442 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4443 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4445 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4447 createPopupItem( SMESHOp::OpPopupImportSAUV, OB, smesh, "", anId );
4448 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4449 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4450 popupMgr()->insert( separator(), -1, 0 );
4453 createPopupItem( SMESHOp::OpEditGroup, View, group );
4454 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4455 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4457 popupMgr()->insert( separator(), -1, 0 );
4458 createPopupItem( SMESHOp::OpUpdate, View, mesh_part );
4459 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4460 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4461 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
4462 popupMgr()->insert( separator(), -1, 0 );
4464 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4465 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4466 popupMgr()->insert( separator(), -1, 0 );
4468 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4469 QString aType = QString( "%1type in {%2}" ).arg( lc );
4470 aType = aType.arg( mesh_part );
4471 QString aMeshInVTK = aClient + "&&" + aType;
4473 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4474 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4475 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4477 //-------------------------------------------------
4479 //-------------------------------------------------
4480 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4482 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4483 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4484 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4486 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4487 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4488 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4490 popupMgr()->insert( separator(), -1, -1 );
4492 //-------------------------------------------------
4494 //-------------------------------------------------
4495 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4497 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4498 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4499 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4501 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4502 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4503 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4505 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4506 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4507 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4509 popupMgr()->insert( separator(), anId, -1 );
4511 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4512 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4513 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4515 //-------------------------------------------------
4517 //-------------------------------------------------
4518 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4520 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4522 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4523 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4524 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4526 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4527 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4528 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4530 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4531 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4532 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4534 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4535 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4536 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4538 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4539 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4540 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4542 popupMgr()->insert( separator(), anId, -1 );
4544 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4545 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4547 popupMgr()->insert( separator(), anId, -1 );
4549 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4550 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4553 //-------------------------------------------------
4554 // Representation of the 2D Quadratic elements
4555 //-------------------------------------------------
4556 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4557 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4558 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4559 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4561 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4562 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4563 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4565 //-------------------------------------------------
4566 // Orientation of faces
4567 //-------------------------------------------------
4568 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4569 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4570 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4572 //-------------------------------------------------
4574 //-------------------------------------------------
4575 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4576 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4578 //-------------------------------------------------
4580 //-------------------------------------------------
4581 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4582 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4584 //-------------------------------------------------
4586 //-------------------------------------------------
4588 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4589 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4590 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4591 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4593 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4595 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4596 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4598 popupMgr()->insert( separator(), anId, -1 );
4600 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4602 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4603 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4604 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4606 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4607 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4608 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4610 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4611 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4612 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4614 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4616 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4617 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4618 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4620 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4621 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4622 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4624 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4625 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4626 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4627 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4628 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4629 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4631 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4633 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4634 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4635 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4637 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4638 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4639 QtxPopupMgr::VisibleRule );
4640 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4642 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4643 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4644 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4646 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4647 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4648 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4650 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4651 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4652 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4654 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4655 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4656 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4658 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4659 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4660 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4662 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4663 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4664 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4666 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4667 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4668 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4670 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4671 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4672 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4674 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4675 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4676 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4678 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4679 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4680 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4682 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4683 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4684 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4686 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4687 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4688 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4690 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
4691 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
4692 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
4694 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4696 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4697 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4698 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4700 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4701 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4702 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4704 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4705 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4706 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4708 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
4709 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4710 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4712 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
4713 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4714 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4716 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
4717 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4718 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4720 popupMgr()->insert( separator(), anId, -1 );
4722 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
4723 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4724 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
4725 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
4726 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4728 popupMgr()->insert( separator(), anId, -1 );
4730 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4732 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
4733 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4735 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
4736 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4737 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
4739 #ifndef DISABLE_PLOT2DVIEWER
4740 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
4741 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4744 //-------------------------------------------------
4746 //-------------------------------------------------
4747 popupMgr()->insert( separator(), -1, -1 );
4748 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4749 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4750 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
4751 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4753 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
4754 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4756 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
4757 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4759 popupMgr()->insert( separator(), -1, -1 );
4761 //-------------------------------------------------
4763 //-------------------------------------------------
4764 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
4765 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4767 popupMgr()->insert( separator(), -1, -1 );
4769 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
4770 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4771 popupMgr()->insert( separator(), -1, -1 );
4773 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4774 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4776 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4777 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4780 //================================================================================
4782 * \brief Return true if SMESH or GEOM objects are selected.
4783 * Is called form LightApp_Module::activateModule() which clear selection if
4784 * not isSelectionCompatible()
4786 //================================================================================
4788 bool SMESHGUI::isSelectionCompatible()
4790 bool isCompatible = true;
4791 SALOME_ListIO selected;
4792 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4793 Sel->selectedObjects( selected );
4795 SALOME_ListIteratorOfListIO It( selected );
4796 for ( ; isCompatible && It.More(); It.Next())
4798 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4799 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4801 return isCompatible;
4805 bool SMESHGUI::reusableOperation( const int id )
4807 // compute, evaluate and precompute are not reusable operations
4808 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
4811 bool SMESHGUI::activateModule( SUIT_Study* study )
4813 bool res = SalomeApp_Module::activateModule( study );
4815 setMenuShown( true );
4816 setToolShown( true );
4818 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4819 PyGILState_STATE gstate = PyGILState_Ensure();
4820 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4821 if ( !pluginsmanager ) {
4825 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
4830 PyGILState_Release(gstate);
4831 // end of SMESH plugins loading
4833 // Reset actions accelerator keys
4834 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
4836 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4837 GetSMESHGen()->UpdateStudy();
4839 // get all view currently opened in the study and connect their signals to
4840 // the corresponding slots of the class.
4841 SUIT_Desktop* aDesk = study->application()->desktop();
4843 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4844 SUIT_ViewWindow* wnd;
4845 foreach ( wnd, wndList )
4849 Py_XDECREF(pluginsmanager);
4853 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4855 setMenuShown( false );
4856 setToolShown( false );
4858 EmitSignalCloseAllDialogs();
4860 // Unset actions accelerator keys
4861 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
4863 return SalomeApp_Module::deactivateModule( study );
4866 void SMESHGUI::studyClosed( SUIT_Study* s )
4870 SMESH::RemoveVisuData();
4871 SalomeApp_Module::studyClosed( s );
4874 void SMESHGUI::OnGUIEvent()
4876 const QObject* obj = sender();
4877 if ( !obj || !obj->inherits( "QAction" ) )
4879 int id = actionId((QAction*)obj);
4884 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4886 if ( CORBA::is_nil( myComponentSMESH ) )
4888 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4889 return aGUI.myComponentSMESH;
4891 return myComponentSMESH;
4894 QString SMESHGUI::engineIOR() const
4896 CORBA::ORB_var anORB = getApp()->orb();
4897 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4898 return QString( anIOR.in() );
4901 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4903 SalomeApp_Module::contextMenuPopup( client, menu, title );
4905 selectionMgr()->selectedObjects( lst );
4906 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4907 Handle(SALOME_InteractiveObject) io = lst.First();
4908 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4909 _PTR(Study) study = appStudy->studyDS();
4910 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4912 QString aName = QString( SMESH::fromUtf8(obj->GetName()) );
4913 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4914 aName.remove( (aName.length() - 1), 1 );
4920 LightApp_Selection* SMESHGUI::createSelection() const
4922 return new SMESHGUI_Selection();
4925 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4927 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4928 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
4929 #ifndef DISABLE_PYCONSOLE
4930 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4934 void SMESHGUI::viewManagers( QStringList& list ) const
4936 list.append( SVTK_Viewer::Type() );
4939 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4941 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4942 SMESH::UpdateSelectionProp( this );
4944 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4945 for(int i = 0; i < aViews.count() ; i++){
4946 SUIT_ViewWindow *sf = aViews[i];
4949 EmitSignalActivatedViewManager();
4953 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4955 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4956 myClippingPlaneInfoMap.erase( theViewManager );
4959 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4961 theActor->AddObserver( SMESH::DeleteActorEvent,
4962 myEventCallbackCommand.GetPointer(),
4966 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4967 unsigned long theEvent,
4968 void* theClientData,
4971 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4972 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
4973 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4974 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4975 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4976 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4977 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4978 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4979 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4980 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4981 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4982 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4983 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4984 if( anActor == *anIter3 ) {
4985 anActorList.erase( anIter3 );
4996 void SMESHGUI::createPreferences()
4998 // General tab ------------------------------------------------------------------------
4999 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5001 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5002 setPreferenceProperty( autoUpdate, "columns", 2 );
5003 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5004 setPreferenceProperty( lim, "min", 0 );
5005 setPreferenceProperty( lim, "max", 100000000 );
5006 setPreferenceProperty( lim, "step", 1000 );
5007 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5008 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5010 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5011 setPreferenceProperty( dispgroup, "columns", 2 );
5012 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5014 modes.append( tr("MEN_WIRE") );
5015 modes.append( tr("MEN_SHADE") );
5016 modes.append( tr("MEN_NODES") );
5017 modes.append( tr("MEN_SHRINK") );
5018 QList<QVariant> indices;
5019 indices.append( 0 );
5020 indices.append( 1 );
5021 indices.append( 2 );
5022 indices.append( 3 );
5023 setPreferenceProperty( dispmode, "strings", modes );
5024 setPreferenceProperty( dispmode, "indexes", indices );
5026 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5027 setPreferenceProperty( arcgroup, "columns", 2 );
5028 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5029 QStringList quadraticModes;
5030 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5031 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5033 indices.append( 0 );
5034 indices.append( 1 );
5035 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5036 setPreferenceProperty( quadraticmode, "indexes", indices );
5038 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5039 "SMESH", "max_angle" );
5040 setPreferenceProperty( maxAngle, "min", 1 );
5041 setPreferenceProperty( maxAngle, "max", 90 );
5043 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5044 setPreferenceProperty( qaGroup, "columns", 2 );
5045 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5046 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5047 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5048 setPreferenceProperty( prec, "min", 0 );
5049 setPreferenceProperty( prec, "max", 100 );
5050 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5051 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5052 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5053 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5054 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5057 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5058 setPreferenceProperty( exportgroup, "columns", 2 );
5059 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5060 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5061 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5063 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5064 setPreferenceProperty( computeGroup, "columns", 2 );
5065 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5067 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5068 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5069 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5071 indices.append( 0 );
5072 indices.append( 1 );
5073 indices.append( 2 );
5074 setPreferenceProperty( notifyMode, "strings", modes );
5075 setPreferenceProperty( notifyMode, "indexes", indices );
5077 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5078 setPreferenceProperty( infoGroup, "columns", 2 );
5079 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5081 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5082 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5084 indices.append( 0 );
5085 indices.append( 1 );
5086 setPreferenceProperty( elemInfo, "strings", modes );
5087 setPreferenceProperty( elemInfo, "indexes", indices );
5088 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5089 setPreferenceProperty( nodesLim, "min", 0 );
5090 setPreferenceProperty( nodesLim, "max", 10000000 );
5091 setPreferenceProperty( nodesLim, "step", 10000 );
5092 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5093 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5094 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5095 setPreferenceProperty( ctrlLim, "min", 0 );
5096 setPreferenceProperty( ctrlLim, "max", 10000000 );
5097 setPreferenceProperty( ctrlLim, "step", 1000 );
5098 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5099 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5100 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5101 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5102 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5104 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5105 setPreferenceProperty( segGroup, "columns", 2 );
5106 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5107 "SMESH", "segmentation" );
5108 setPreferenceProperty( segLen, "min", 1 );
5109 setPreferenceProperty( segLen, "max", 10000000 );
5110 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5111 "SMESH", "nb_segments_per_edge" );
5112 setPreferenceProperty( nbSeg, "min", 1 );
5113 setPreferenceProperty( nbSeg, "max", 10000000 );
5115 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5116 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5117 "SMESH", "forget_mesh_on_hyp_modif" );
5120 // Quantities with individual precision settings
5121 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5122 setPreferenceProperty( precGroup, "columns", 2 );
5124 const int nbQuantities = 6;
5125 int precs[nbQuantities], ii = 0;
5126 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5127 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5128 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5129 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5130 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5131 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5132 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5133 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5134 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5135 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5136 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5137 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5139 // Set property for precision value for spinboxes
5140 for ( ii = 0; ii < nbQuantities; ii++ ){
5141 setPreferenceProperty( precs[ii], "min", -14 );
5142 setPreferenceProperty( precs[ii], "max", 14 );
5143 setPreferenceProperty( precs[ii], "precision", 2 );
5146 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5147 setPreferenceProperty( previewGroup, "columns", 2 );
5148 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5149 setPreferenceProperty( chunkSize, "min", 1 );
5150 setPreferenceProperty( chunkSize, "max", 1000 );
5151 setPreferenceProperty( chunkSize, "step", 50 );
5153 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5154 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5156 // Mesh tab ------------------------------------------------------------------------
5157 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5158 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5159 setPreferenceProperty( nodeGroup, "columns", 3 );
5161 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5163 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5165 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5166 QList<QVariant> aMarkerTypeIndicesList;
5167 QList<QVariant> aMarkerTypeIconsList;
5168 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5169 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5170 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5171 aMarkerTypeIndicesList << i;
5172 aMarkerTypeIconsList << pixmap;
5174 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5175 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5177 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5179 QList<QVariant> aMarkerScaleIndicesList;
5180 QStringList aMarkerScaleValuesList;
5181 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5182 aMarkerScaleIndicesList << i;
5183 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5184 aMarkerScaleValuesList << QString::number( i );
5186 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5187 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5189 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5190 //setPreferenceProperty( elemGroup, "columns", 2 );
5192 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5193 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5194 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5195 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5196 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5197 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5198 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5199 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5200 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5203 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5204 setPreferenceProperty( grpGroup, "columns", 2 );
5206 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5207 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5209 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5210 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5211 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5212 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5213 double ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5214 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5215 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5216 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5217 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5218 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5219 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5220 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5221 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5222 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5224 setPreferenceProperty( size0d, "min", 1 );
5225 setPreferenceProperty( size0d, "max", 10 );
5227 // setPreferenceProperty( ballSize, "min", 1 );
5228 // setPreferenceProperty( ballSize, "max", 10 );
5230 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5231 setPreferenceProperty( ballDiameter, "max", 1e9 );
5232 setPreferenceProperty( ballDiameter, "step", 0.1 );
5234 setPreferenceProperty( ballScale, "min", 1e-2 );
5235 setPreferenceProperty( ballScale, "max", 1e7 );
5236 setPreferenceProperty( ballScale, "step", 0.5 );
5238 setPreferenceProperty( elemW, "min", 1 );
5239 setPreferenceProperty( elemW, "max", 5 );
5241 setPreferenceProperty( outW, "min", 1 );
5242 setPreferenceProperty( outW, "max", 5 );
5244 setPreferenceProperty( shrink, "min", 0 );
5245 setPreferenceProperty( shrink, "max", 100 );
5247 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5248 setPreferenceProperty( numGroup, "columns", 2 );
5250 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5251 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5253 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5254 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5256 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5257 setPreferenceProperty( orientGroup, "columns", 1 );
5259 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5260 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5262 setPreferenceProperty( orientScale, "min", 0.05 );
5263 setPreferenceProperty( orientScale, "max", 0.5 );
5264 setPreferenceProperty( orientScale, "step", 0.05 );
5266 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5268 // Selection tab ------------------------------------------------------------------------
5269 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5271 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5272 setPreferenceProperty( selGroup, "columns", 2 );
5274 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5275 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5277 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5278 setPreferenceProperty( preGroup, "columns", 2 );
5280 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5282 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5283 setPreferenceProperty( precSelGroup, "columns", 2 );
5285 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5286 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5287 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5289 // Scalar Bar tab ------------------------------------------------------------------------
5290 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5291 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5292 setPreferenceProperty( fontGr, "columns", 2 );
5294 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5295 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5297 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5298 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5300 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5301 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5303 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5304 setPreferenceProperty( numcol, "min", 2 );
5305 setPreferenceProperty( numcol, "max", 256 );
5307 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5308 setPreferenceProperty( numlab, "min", 2 );
5309 setPreferenceProperty( numlab, "max", 65 );
5311 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5312 setPreferenceProperty( orientGr, "columns", 2 );
5313 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5314 QStringList orients;
5315 orients.append( tr( "SMESH_VERTICAL" ) );
5316 orients.append( tr( "SMESH_HORIZONTAL" ) );
5317 indices.clear(); indices.append( 0 ); indices.append( 1 );
5318 setPreferenceProperty( orient, "strings", orients );
5319 setPreferenceProperty( orient, "indexes", indices );
5321 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5322 setPreferenceProperty( posVSizeGr, "columns", 2 );
5323 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5324 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5325 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5326 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5327 setPreferenceProperty( xv, "step", 0.1 );
5328 setPreferenceProperty( xv, "min", 0.0 );
5329 setPreferenceProperty( xv, "max", 1.0 );
5330 setPreferenceProperty( yv, "step", 0.1 );
5331 setPreferenceProperty( yv, "min", 0.0 );
5332 setPreferenceProperty( yv, "max", 1.0 );
5333 setPreferenceProperty( wv, "step", 0.1 );
5334 setPreferenceProperty( wv, "min", 0.0 );
5335 setPreferenceProperty( wv, "max", 1.0 );
5336 setPreferenceProperty( hv, "min", 0.0 );
5337 setPreferenceProperty( hv, "max", 1.0 );
5338 setPreferenceProperty( hv, "step", 0.1 );
5340 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5341 setPreferenceProperty( posHSizeGr, "columns", 2 );
5342 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5343 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5344 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5345 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5346 setPreferenceProperty( xv, "min", 0.0 );
5347 setPreferenceProperty( xv, "max", 1.0 );
5348 setPreferenceProperty( xv, "step", 0.1 );
5349 setPreferenceProperty( xh, "min", 0.0 );
5350 setPreferenceProperty( xh, "max", 1.0 );
5351 setPreferenceProperty( xh, "step", 0.1 );
5352 setPreferenceProperty( yh, "min", 0.0 );
5353 setPreferenceProperty( yh, "max", 1.0 );
5354 setPreferenceProperty( yh, "step", 0.1 );
5355 setPreferenceProperty( wh, "min", 0.0 );
5356 setPreferenceProperty( wh, "max", 1.0 );
5357 setPreferenceProperty( wh, "step", 0.1 );
5358 setPreferenceProperty( hh, "min", 0.0 );
5359 setPreferenceProperty( hh, "max", 1.0 );
5360 setPreferenceProperty( hh, "step", 0.1 );
5362 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5363 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5364 setPreferenceProperty( distributionGr, "columns", 3 );
5366 types.append( tr( "SMESH_MONOCOLOR" ) );
5367 types.append( tr( "SMESH_MULTICOLOR" ) );
5368 indices.clear(); indices.append( 0 ); indices.append( 1 );
5369 setPreferenceProperty( coloringType, "strings", types );
5370 setPreferenceProperty( coloringType, "indexes", indices );
5371 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5375 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5377 if ( sect=="SMESH" ) {
5378 float sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5379 float aTol = 1.00000009999999;
5380 std::string aWarning;
5381 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5383 if ( name== "selection_object_color" ||
5384 name=="selection_element_color" ||
5385 name== "highlight_color" ||
5386 name=="selection_precision_node" ||
5387 name=="selection_precision_element" ||
5388 name=="selection_precision_object" )
5390 SMESH::UpdateSelectionProp( this );
5392 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5394 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5395 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5396 if ( sbX1+sbW > aTol ) {
5397 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5400 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5401 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5404 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5406 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5407 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5408 if ( sbY1 + sbH > aTol ) {
5409 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5410 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5411 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5414 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5416 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5417 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5418 if ( sbX1 + sbW > aTol ) {
5419 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5422 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5423 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5426 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5428 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5429 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5430 if ( sbY1 + sbH > aTol ) {
5431 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5434 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5435 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5438 else if ( name == "segmentation" )
5440 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5441 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5443 else if ( name == "nb_segments_per_edge" )
5445 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5446 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5448 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5450 QString val = aResourceMgr->stringValue( "SMESH", name );
5451 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5453 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5455 SMESH::UpdateFontProp( this );
5457 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5459 SMESH::UpdateFontProp( this );
5462 if ( aWarning.size() != 0 ) {
5463 aWarning += "The default values are applied instead.";
5464 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5465 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5466 QObject::tr(aWarning.c_str()));
5471 //================================================================================
5473 * \brief Update something in accordance with update flags
5474 * \param theFlags - update flags
5476 * Update viewer or/and object browser etc. in accordance with update flags ( see
5477 * LightApp_UpdateFlags enumeration ).
5479 //================================================================================
5480 void SMESHGUI::update( const int flags )
5482 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5483 SMESH::UpdateView();
5485 SalomeApp_Module::update( flags );
5488 //================================================================================
5490 * \brief Set default selection mode
5492 * SLOT called when operation committed. Sets default selection mode
5494 //================================================================================
5495 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5497 SVTK_ViewWindow* vtkWnd =
5498 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5500 vtkWnd->SetSelectionMode( ActorSelection );
5503 //================================================================================
5505 * \brief Set default selection mode
5507 * SLOT called when operation aborted. Sets default selection mode
5509 //================================================================================
5510 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5512 SVTK_ViewWindow* vtkWnd =
5513 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5515 vtkWnd->SetSelectionMode( ActorSelection );
5518 //================================================================================
5520 * \brief Creates operation with given identifier
5521 * \param id - identifier of operation to be started
5522 * \return Pointer on created operation or NULL if operation is not created
5524 * Virtual method redefined from the base class creates operation with given id.
5525 * It is called called automatically from startOperation method of base class.
5527 //================================================================================
5528 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5530 LightApp_Operation* op = 0;
5531 // to do : create operation here
5534 case SMESHOp::OpSplitBiQuadratic:
5535 op = new SMESHGUI_SplitBiQuadOp();
5537 case SMESHOp::OpConvertMeshToQuadratic:
5538 op = new SMESHGUI_ConvToQuadOp();
5540 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5541 op = new SMESHGUI_Make2DFrom3DOp();
5543 case SMESHOp::OpReorientFaces:
5544 op = new SMESHGUI_ReorientFacesOp();
5546 case SMESHOp::OpCreateMesh:
5547 op = new SMESHGUI_MeshOp( true, true );
5549 case SMESHOp::OpCreateSubMesh:
5550 op = new SMESHGUI_MeshOp( true, false );
5552 case SMESHOp::OpEditMeshOrSubMesh:
5553 case SMESHOp::OpEditMesh:
5554 case SMESHOp::OpEditSubMesh:
5555 op = new SMESHGUI_MeshOp( false );
5557 case SMESHOp::OpCompute:
5558 case SMESHOp::OpComputeSubMesh:
5559 op = new SMESHGUI_ComputeOp();
5561 case SMESHOp::OpPreCompute:
5562 op = new SMESHGUI_PrecomputeOp();
5564 case SMESHOp::OpEvaluate:
5565 op = new SMESHGUI_EvaluateOp();
5567 case SMESHOp::OpMeshOrder:
5568 op = new SMESHGUI_MeshOrderOp();
5570 case SMESHOp::OpCreateGeometryGroup:
5571 op = new SMESHGUI_GroupOnShapeOp();
5573 case SMESHOp::OpFindElementByPoint:
5574 op = new SMESHGUI_FindElemByPointOp();
5576 case SMESHOp::OpMoveNode: // Make mesh pass through point
5577 op = new SMESHGUI_MakeNodeAtPointOp();
5579 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5580 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5587 op = SalomeApp_Module::createOperation( id );
5591 //================================================================================
5593 * \brief Stops current operations and starts a given one
5594 * \param id - The id of the operation to start
5596 //================================================================================
5598 void SMESHGUI::switchToOperation(int id)
5600 activeStudy()->abortAllOperations();
5601 startOperation( id );
5604 LightApp_Displayer* SMESHGUI::displayer()
5607 myDisplayer = new SMESHGUI_Displayer( getApp() );
5611 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5614 int aTolerance = 64;
5615 int anIterations = 0;
5621 if( anIterations % aPeriod == 0 )
5624 if( aTolerance < 1 )
5628 aHue = (int)( 360.0 * rand() / RAND_MAX );
5631 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5632 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5633 for( ; it != itEnd; ++it )
5635 SALOMEDS::Color anAutoColor = *it;
5636 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5639 aQColor.getHsv( &h, &s, &v );
5640 if( abs( h - aHue ) < aTolerance )
5652 aColor.setHsv( aHue, 255, 255 );
5654 SALOMEDS::Color aSColor;
5655 aSColor.R = aColor.redF();
5656 aSColor.G = aColor.greenF();
5657 aSColor.B = aColor.blueF();
5662 const char* gSeparator = "_"; // character used to separate parameter names
5663 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5664 const char* gPathSep = "|"; // character used to separate paths
5667 * \brief Store visual parameters
5669 * This method is called just before the study document is saved.
5670 * Store visual parameters in AttributeParameter attribue(s)
5672 void SMESHGUI::storeVisualParameters (int savePoint)
5675 Kernel_Utils::Localizer loc;
5677 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5678 if (!appStudy || !appStudy->studyDS())
5680 _PTR(Study) studyDS = appStudy->studyDS();
5682 // componentName is used for encoding of entries when storing them in IParameters
5683 std::string componentName = myComponentSMESH->ComponentDataType();
5684 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5685 //if (!aSComponent) return;
5688 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5689 componentName.c_str(),
5691 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5693 // store custom markers
5694 if( !myMarkerMap.empty() )
5696 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
5697 for( ; anIter != myMarkerMap.end(); anIter++ )
5699 int anId = anIter->first;
5700 VTK::MarkerData aMarkerData = anIter->second;
5701 std::string aMarkerFileName = aMarkerData.first;
5702 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5703 if( aMarkerTexture.size() < 3 )
5704 continue; // should contain at least width, height and the first value
5706 QString aPropertyName( "texture" );
5707 aPropertyName += gSeparator;
5708 aPropertyName += QString::number( anId );
5710 QString aPropertyValue = aMarkerFileName.c_str();
5711 aPropertyValue += gPathSep;
5713 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5714 ushort aWidth = *aTextureIter++;
5715 ushort aHeight = *aTextureIter++;
5716 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5717 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5718 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5719 aPropertyValue += QString::number( *aTextureIter );
5721 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5725 // viewers counters are used for storing view_numbers in IParameters
5728 // main cycle to store parameters of displayed objects
5729 QList<SUIT_ViewManager*> lst;
5730 QList<SUIT_ViewManager*>::Iterator it;
5731 getApp()->viewManagers(lst);
5732 for (it = lst.begin(); it != lst.end(); it++)
5734 SUIT_ViewManager* vman = *it;
5735 QString vType = vman->getType();
5737 // saving VTK actors properties
5738 if (vType == SVTK_Viewer::Type())
5740 // store the clipping planes attached to the view manager
5741 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5742 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5743 if( anIter != myClippingPlaneInfoMap.end() )
5744 aClippingPlaneInfoList = anIter->second;
5746 if( !aClippingPlaneInfoList.empty() ) {
5747 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5748 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5750 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5751 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5753 QString aPropertyName( "ClippingPlane" );
5754 aPropertyName += gSeparator;
5755 aPropertyName += QString::number( vtkViewers );
5756 aPropertyName += gSeparator;
5757 aPropertyName += QString::number( anId );
5759 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5760 aPropertyValue += gDigitsSep;
5761 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5762 aPropertyValue += gDigitsSep;
5763 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5764 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5765 aPropertyValue += gDigitsSep;
5766 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5767 aPropertyValue += gDigitsSep;
5768 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5769 aPropertyValue += gDigitsSep;
5770 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5771 aPropertyValue += gDigitsSep;
5772 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5773 aPropertyValue += gDigitsSep;
5774 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5775 aPropertyValue += gDigitsSep;
5776 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5778 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5779 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5780 aPropertyValue += gDigitsSep;
5781 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5782 aPropertyValue += gDigitsSep;
5783 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5784 aPropertyValue += gDigitsSep;
5785 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5788 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5792 QVector<SUIT_ViewWindow*> views = vman->getViews();
5793 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5795 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5797 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5798 vtkActorCollection* allActors = aCopy.GetActors();
5799 allActors->InitTraversal();
5800 while (vtkActor* actor = allActors->GetNextActor())
5802 if (actor->GetVisibility()) // store only visible actors
5804 SMESH_Actor* aSmeshActor = 0;
5805 if (actor->IsA("SMESH_Actor"))
5806 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5807 if (aSmeshActor && aSmeshActor->hasIO())
5809 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5812 // entry is "encoded" = it does NOT contain component address,
5813 // since it is a subject to change on next component loading
5814 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5816 std::string param, vtkParam = vType.toLatin1().data();
5817 vtkParam += gSeparator;
5818 vtkParam += QString::number(vtkViewers).toLatin1().data();
5819 vtkParam += gSeparator;
5822 param = vtkParam + "Visibility";
5823 ip->setParameter(entry, param, "On");
5826 param = vtkParam + "Representation";
5827 ip->setParameter(entry, param, QString::number
5828 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5831 param = vtkParam + "IsShrunk";
5832 ip->setParameter(entry, param, QString::number
5833 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5835 // Displayed entities
5836 unsigned int aMode = aSmeshActor->GetEntityMode();
5837 bool isE = aMode & SMESH_Actor::eEdges;
5838 bool isF = aMode & SMESH_Actor::eFaces;
5839 bool isV = aMode & SMESH_Actor::eVolumes;
5840 bool is0d = aMode & SMESH_Actor::e0DElements;
5841 bool isB = aMode & SMESH_Actor::eBallElem;
5843 QString modeStr ("e");
5844 modeStr += gDigitsSep; modeStr += QString::number(isE);
5845 modeStr += gDigitsSep; modeStr += "f";
5846 modeStr += gDigitsSep; modeStr += QString::number(isF);
5847 modeStr += gDigitsSep; modeStr += "v";
5848 modeStr += gDigitsSep; modeStr += QString::number(isV);
5849 modeStr += gDigitsSep; modeStr += "0d";
5850 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5851 modeStr += gDigitsSep; modeStr += "b";
5852 modeStr += gDigitsSep; modeStr += QString::number(isB);
5854 param = vtkParam + "Entities";
5855 ip->setParameter(entry, param, modeStr.toLatin1().data());
5861 aSmeshActor->GetSufaceColor(r, g, b, delta);
5862 QStringList colorStr;
5863 colorStr << "surface";
5864 colorStr << QString::number(r);
5865 colorStr << QString::number(g);
5866 colorStr << QString::number(b);
5868 colorStr << "backsurface";
5869 colorStr << QString::number(delta);
5871 aSmeshActor->GetVolumeColor(r, g, b, delta);
5872 colorStr << "volume";
5873 colorStr << QString::number(r);
5874 colorStr << QString::number(g);
5875 colorStr << QString::number(b);
5876 colorStr << QString::number(delta);
5878 aSmeshActor->GetEdgeColor(r, g, b);
5880 colorStr << QString::number(r);
5881 colorStr << QString::number(g);
5882 colorStr << QString::number(b);
5884 aSmeshActor->GetNodeColor(r, g, b);
5886 colorStr << QString::number(r);
5887 colorStr << QString::number(g);
5888 colorStr << QString::number(b);
5890 aSmeshActor->GetOutlineColor(r, g, b);
5891 colorStr << "outline";
5892 colorStr << QString::number(r);
5893 colorStr << QString::number(g);
5894 colorStr << QString::number(b);
5896 aSmeshActor->Get0DColor(r, g, b);
5897 colorStr << "elem0d";
5898 colorStr << QString::number(r);
5899 colorStr << QString::number(g);
5900 colorStr << QString::number(b);
5902 aSmeshActor->GetBallColor(r, g, b);
5904 colorStr << QString::number(r);
5905 colorStr << QString::number(g);
5906 colorStr << QString::number(b);
5908 aSmeshActor->GetFacesOrientationColor(r, g, b);
5909 colorStr << "orientation";
5910 colorStr << QString::number(r);
5911 colorStr << QString::number(g);
5912 colorStr << QString::number(b);
5914 param = vtkParam + "Colors";
5915 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5918 QStringList sizeStr;
5920 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5921 sizeStr << "outline";
5922 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5923 sizeStr << "elem0d";
5924 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5926 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5927 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
5928 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
5929 sizeStr << "shrink";
5930 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5931 sizeStr << "orientation";
5932 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5933 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5935 param = vtkParam + "Sizes";
5936 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5941 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5942 if( aMarkerType == VTK::MT_USER ) {
5943 markerStr += "custom";
5944 markerStr += gDigitsSep;
5945 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5949 markerStr += gDigitsSep;
5950 markerStr += QString::number( (int)aMarkerType );
5951 markerStr += gDigitsSep;
5952 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5955 param = vtkParam + "PointMarker";
5956 ip->setParameter(entry, param, markerStr.toLatin1().data());
5959 param = vtkParam + "Opacity";
5960 ip->setParameter(entry, param,
5961 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5964 param = vtkParam + "ClippingPlane";
5966 if( !aClippingPlaneInfoList.empty() ) {
5967 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5968 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5970 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5971 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5972 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5973 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5974 if( aSmeshActor == *anIter2 ) {
5975 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5976 QString::number( anId ).toLatin1().constData() );
5983 ip->setParameter( entry, param, "Off" );
5984 } // if (io->hasEntry())
5985 } // SMESH_Actor && hasIO
5987 } // while.. actors traversal
5991 } // if (SVTK view model)
5992 } // for (viewManagers)
5995 // data structures for clipping planes processing
5999 bool isOpenGLClipping;
6000 vtkIdType RelativeOrientation;
6003 int AbsoluteOrientation;
6004 double X, Y, Z, Dx, Dy, Dz;
6006 typedef std::list<TPlaneData> TPlaneDataList;
6007 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6009 typedef std::list<vtkActor*> TActorList;
6012 TActorList ActorList;
6013 SUIT_ViewManager* ViewManager;
6015 typedef std::list<TPlaneInfo> TPlaneInfoList;
6016 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6019 * \brief Restore visual parameters
6021 * This method is called after the study document is opened.
6022 * Restore visual parameters from AttributeParameter attribue(s)
6024 void SMESHGUI::restoreVisualParameters (int savePoint)
6027 Kernel_Utils::Localizer loc;
6029 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6030 if (!appStudy || !appStudy->studyDS())
6032 _PTR(Study) studyDS = appStudy->studyDS();
6034 // componentName is used for encoding of entries when storing them in IParameters
6035 std::string componentName = myComponentSMESH->ComponentDataType();
6036 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
6037 //if (!aSComponent) return;
6040 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6041 componentName.c_str(),
6043 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6045 // restore custom markers and map of clipping planes
6046 TPlaneDataMap aPlaneDataMap;
6048 std::vector<std::string> properties = ip->getProperties();
6049 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6051 std::string property = *propIt;
6052 QString aPropertyName( property.c_str() );
6053 QString aPropertyValue( ip->getProperty( property ).c_str() );
6055 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6056 if( aPropertyNameList.isEmpty() )
6059 QString aPropertyType = aPropertyNameList[0];
6060 if( aPropertyType == "texture" )
6062 if( aPropertyNameList.size() != 2 )
6066 int anId = aPropertyNameList[1].toInt( &ok );
6067 if( !ok || anId < 1 )
6070 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6071 if( aPropertyValueList.size() != 2 )
6074 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6075 QString aMarkerTextureString = aPropertyValueList[1];
6076 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6077 if( aMarkerTextureStringList.size() != 3 )
6081 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6086 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6090 VTK::MarkerTexture aMarkerTexture;
6091 aMarkerTexture.push_back( aWidth );
6092 aMarkerTexture.push_back( aHeight );
6094 QString aMarkerTextureData = aMarkerTextureStringList[2];
6095 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6097 QChar aChar = aMarkerTextureData.at( i );
6098 if( aChar.isDigit() )
6099 aMarkerTexture.push_back( aChar.digitValue() );
6102 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6104 else if( aPropertyType == "ClippingPlane" )
6106 if( aPropertyNameList.size() != 3 )
6110 int aViewId = aPropertyNameList[1].toInt( &ok );
6111 if( !ok || aViewId < 0 )
6115 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6116 if( !ok || aClippingPlaneId < 0 )
6119 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6120 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6123 TPlaneData aPlaneData;
6124 aPlaneData.AbsoluteOrientation = false;
6125 aPlaneData.RelativeOrientation = 0;
6126 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6127 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6128 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6130 aPlaneData.Id = aClippingPlaneId;
6133 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6138 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6142 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6145 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6150 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6155 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6160 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6165 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6170 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6175 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6179 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6181 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6186 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6191 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6196 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6201 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6202 aPlaneDataList.push_back( aPlaneData );
6206 TPlaneInfoMap aPlaneInfoMap;
6208 std::vector<std::string> entries = ip->getEntries();
6210 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6212 // entry is a normal entry - it should be "decoded" (setting base address of component)
6213 QString entry (ip->decodeEntry(*entIt).c_str());
6215 // Check that the entry corresponds to a real object in the Study
6216 // as the object may be deleted or modified after the visual state is saved.
6217 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
6218 if (!so) continue; //Skip the not existent entry
6220 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6221 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6223 std::vector<std::string>::iterator namesIt = paramNames.begin();
6224 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6226 // actors are stored in a map after displaying of them for
6227 // quicker access in the future: map < viewID to actor >
6228 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6230 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6232 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6233 // '_' is used as separator and should not be used in viewer type or parameter names.
6234 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6235 if (lst.size() != 3)
6238 QString viewerTypStr = lst[0];
6239 QString viewIndexStr = lst[1];
6240 QString paramNameStr = lst[2];
6243 int viewIndex = viewIndexStr.toUInt(&ok);
6244 if (!ok) // bad conversion of view index to integer
6248 if (viewerTypStr == SVTK_Viewer::Type())
6250 SMESH_Actor* aSmeshActor = 0;
6251 if (vtkActors.IsBound(viewIndex))
6252 aSmeshActor = vtkActors.Find(viewIndex);
6254 QList<SUIT_ViewManager*> lst;
6255 getApp()->viewManagers(viewerTypStr, lst);
6257 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6258 SUIT_ViewManager* vman = NULL;
6259 if (viewIndex >= 0 && viewIndex < lst.count())
6260 vman = lst.at(viewIndex);
6262 if (paramNameStr == "Visibility")
6264 if (!aSmeshActor && displayer() && vman)
6266 SUIT_ViewModel* vmodel = vman->getViewModel();
6267 // SVTK view model can be casted to SALOME_View
6268 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6270 // store displayed actor in a temporary map for quicker
6271 // access later when restoring other parameters
6272 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6273 vtkRenderer* Renderer = vtkView->getRenderer();
6274 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6275 vtkActorCollection* theActors = aCopy.GetActors();
6276 theActors->InitTraversal();
6277 bool isFound = false;
6278 vtkActor *ac = theActors->GetNextActor();
6279 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6280 if (ac->IsA("SMESH_Actor")) {
6281 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6282 if (aGeomAc->hasIO()) {
6283 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6284 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
6286 vtkActors.Bind(viewIndex, aGeomAc);
6292 } // if (paramNameStr == "Visibility")
6295 // the rest properties "work" with SMESH_Actor
6298 QString val ((*valuesIt).c_str());
6301 if (paramNameStr == "Representation") {
6302 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6305 else if (paramNameStr == "IsShrunk") {
6307 if (!aSmeshActor->IsShrunk())
6308 aSmeshActor->SetShrink();
6311 if (aSmeshActor->IsShrunk())
6312 aSmeshActor->UnShrink();
6315 // Displayed entities
6316 else if (paramNameStr == "Entities") {
6317 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6318 int aEntityMode = SMESH_Actor::eAllEntity;
6319 for ( int i = 0; i < mode.count(); i+=2 ) {
6320 if ( i < mode.count()-1 ) {
6321 QString type = mode[i];
6322 bool val = mode[i+1].toInt();
6323 if ( type == "e" && !val )
6324 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6325 else if ( type == "f" && !val )
6326 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6327 else if ( type == "v" && !val )
6328 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6329 else if ( type == "0d" && !val )
6330 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6331 else if ( type == "b" && !val )
6332 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6335 aSmeshActor->SetEntityMode( aEntityMode );
6338 else if (paramNameStr == "Colors") {
6339 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6346 QColor outlineColor;
6347 QColor orientationColor;
6353 // below lines are required to get default values for delta coefficients
6354 // of backface color for faces and color of reversed volumes
6355 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6356 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6357 for ( int i = 0; i < colors.count(); i++ ) {
6358 QString type = colors[i];
6359 if ( type == "surface" ) {
6360 // face color is set by 3 values r:g:b, where
6361 // - r,g,b - is rgb color components
6362 if ( i+1 >= colors.count() ) break; // format error
6363 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6364 if ( i+2 >= colors.count() ) break; // format error
6365 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6366 if ( i+3 >= colors.count() ) break; // format error
6367 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6368 faceColor.setRgbF( r, g, b );
6371 else if ( type == "backsurface" ) {
6372 // backface color can be defined in several ways
6373 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6374 // - in latest versions, it is set as delta coefficient
6375 bool rgbOk = false, deltaOk;
6376 if ( i+1 >= colors.count() ) break; // format error
6377 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6378 int delta = colors[i+1].toInt( &deltaOk );
6380 if ( i+1 < colors.count() ) // index is shifted to 1
6381 g = colors[i+1].toDouble( &rgbOk );
6382 if ( rgbOk ) i++; // shift index
6383 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6384 b = colors[i+1].toDouble( &rgbOk );
6386 // - as currently there's no way to set directly backsurface color as it was before,
6387 // we ignore old dump where r,g,b triple was set
6388 // - also we check that delta parameter is set properly
6389 if ( !rgbOk && deltaOk )
6392 else if ( type == "volume" ) {
6393 // volume color is set by 4 values r:g:b:delta, where
6394 // - r,g,b - is a normal volume rgb color components
6395 // - delta - is a reversed volume color delta coefficient
6396 if ( i+1 >= colors.count() ) break; // format error
6397 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6398 if ( i+2 >= colors.count() ) break; // format error
6399 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6400 if ( i+3 >= colors.count() ) break; // format error
6401 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6402 if ( i+4 >= colors.count() ) break; // format error
6403 int delta = colors[i+4].toInt( &bOk );
6404 if ( !bOk ) break; // format error
6405 volumeColor.setRgbF( r, g, b );
6409 else if ( type == "edge" ) {
6410 // edge color is set by 3 values r:g:b, where
6411 // - r,g,b - is rgb color components
6412 if ( i+1 >= colors.count() ) break; // format error
6413 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6414 if ( i+2 >= colors.count() ) break; // format error
6415 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6416 if ( i+3 >= colors.count() ) break; // format error
6417 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6418 edgeColor.setRgbF( r, g, b );
6421 else if ( type == "node" ) {
6422 // node color is set by 3 values r:g:b, where
6423 // - r,g,b - is rgb color components
6424 if ( i+1 >= colors.count() ) break; // format error
6425 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6426 if ( i+2 >= colors.count() ) break; // format error
6427 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6428 if ( i+3 >= colors.count() ) break; // format error
6429 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6430 nodeColor.setRgbF( r, g, b );
6433 else if ( type == "elem0d" ) {
6434 // 0d element color is set by 3 values r:g:b, where
6435 // - r,g,b - is rgb color components
6436 if ( i+1 >= colors.count() ) break; // format error
6437 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6438 if ( i+2 >= colors.count() ) break; // format error
6439 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6440 if ( i+3 >= colors.count() ) break; // format error
6441 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6442 elem0dColor.setRgbF( r, g, b );
6445 else if ( type == "ball" ) {
6446 // ball color is set by 3 values r:g:b, where
6447 // - r,g,b - is rgb color components
6448 if ( i+1 >= colors.count() ) break; // format error
6449 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6450 if ( i+2 >= colors.count() ) break; // format error
6451 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6452 if ( i+3 >= colors.count() ) break; // format error
6453 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6454 ballColor.setRgbF( r, g, b );
6457 else if ( type == "outline" ) {
6458 // outline color is set by 3 values r:g:b, where
6459 // - r,g,b - is rgb color components
6460 if ( i+1 >= colors.count() ) break; // format error
6461 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6462 if ( i+2 >= colors.count() ) break; // format error
6463 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6464 if ( i+3 >= colors.count() ) break; // format error
6465 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6466 outlineColor.setRgbF( r, g, b );
6469 else if ( type == "orientation" ) {
6470 // orientation color is set by 3 values r:g:b, where
6471 // - r,g,b - is rgb color components
6472 if ( i+1 >= colors.count() ) break; // format error
6473 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6474 if ( i+2 >= colors.count() ) break; // format error
6475 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6476 if ( i+3 >= colors.count() ) break; // format error
6477 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6478 orientationColor.setRgbF( r, g, b );
6483 if ( nodeColor.isValid() )
6484 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6486 if ( edgeColor.isValid() )
6487 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6489 if ( faceColor.isValid() )
6490 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6492 if ( volumeColor.isValid() )
6493 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6494 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6495 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6497 if ( elem0dColor.isValid() )
6498 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6500 if ( ballColor.isValid() )
6501 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6503 if ( outlineColor.isValid() )
6504 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6505 // orientation color
6506 if ( orientationColor.isValid() )
6507 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6510 else if (paramNameStr == "Sizes") {
6511 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6514 int outlineWidth = -1;
6515 int elem0dSize = -1;
6516 //int ballSize = -1;
6517 double ballDiameter = -1.0;
6518 double ballScale = -1.0;
6519 double shrinkSize = -1;
6520 double orientationSize = -1;
6521 bool orientation3d = false;
6522 for ( int i = 0; i < sizes.count(); i++ ) {
6523 QString type = sizes[i];
6524 if ( type == "line" ) {
6525 // line (wireframe) width is given as single integer value
6526 if ( i+1 >= sizes.count() ) break; // format error
6527 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6531 if ( type == "outline" ) {
6532 // outline width is given as single integer value
6533 if ( i+1 >= sizes.count() ) break; // format error
6534 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6538 else if ( type == "elem0d" ) {
6539 // 0d element size is given as single integer value
6540 if ( i+1 >= sizes.count() ) break; // format error
6541 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6545 else if ( type == "ball" ) {
6546 // balls are specified by two values: size:scale, where
6547 // - size - is a integer value specifying size
6548 // - scale - is a double value specifying scale factor
6549 if ( i+1 >= sizes.count() ) break; // format error
6550 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6551 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6552 if ( i+2 >= sizes.count() ) break; // format error
6553 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6559 else if ( type == "shrink" ) {
6560 // shrink factor is given as single floating point value
6561 if ( i+1 >= sizes.count() ) break; // format error
6562 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6566 else if ( type == "orientation" ) {
6567 // orientation vectors are specified by two values size:3d, where
6568 // - size - is a floating point value specifying scale factor
6569 // - 3d - is a boolean
6570 if ( i+1 >= sizes.count() ) break; // format error
6571 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6572 if ( i+2 >= sizes.count() ) break; // format error
6573 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6574 orientationSize = v1;
6575 orientation3d = (bool)v2;
6579 // line (wireframe) width
6580 if ( lineWidth > 0 )
6581 aSmeshActor->SetLineWidth( lineWidth );
6583 if ( outlineWidth > 0 )
6584 aSmeshActor->SetOutlineWidth( outlineWidth );
6585 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6586 aSmeshActor->SetOutlineWidth( lineWidth );
6588 if ( elem0dSize > 0 )
6589 aSmeshActor->Set0DSize( elem0dSize );
6591 /*if ( ballSize > 0 )
6592 aSmeshActor->SetBallSize( ballSize );*/
6594 if ( ballDiameter > 0 )
6595 aSmeshActor->SetBallSize( ballDiameter );
6597 if ( ballScale > 0.0 )
6598 aSmeshActor->SetBallScale( ballScale );
6600 if ( shrinkSize > 0 )
6601 aSmeshActor->SetShrinkFactor( shrinkSize );
6602 // orientation vectors
6603 if ( orientationSize > 0 ) {
6604 aSmeshActor->SetFacesOrientationScale( orientationSize );
6605 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6609 else if (paramNameStr == "PointMarker") {
6610 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6611 if( data.count() >= 2 ) {
6613 int aParam1 = data[1].toInt( &ok );
6615 if( data[0] == "std" && data.count() == 3 ) {
6616 int aParam2 = data[2].toInt( &ok );
6617 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6619 else if( data[0] == "custom" ) {
6620 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
6621 if( markerIt != myMarkerMap.end() ) {
6622 VTK::MarkerData aMarkerData = markerIt->second;
6623 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6630 else if (paramNameStr == "Opacity") {
6631 aSmeshActor->SetOpacity(val.toFloat());
6634 else if (paramNameStr.startsWith("ClippingPlane")) {
6635 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6636 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6637 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6638 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6639 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6640 // new format - val looks like "Off" or "0" (plane id)
6641 // (note: in new format "Off" value is used only for consistency,
6642 // so it is processed together with values in old format)
6643 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6644 if( anIsOldFormat ) {
6645 if (paramNameStr == "ClippingPlane1" || val == "Off")
6646 aSmeshActor->RemoveAllClippingPlanes();
6648 QList<SUIT_ViewManager*> lst;
6649 getApp()->viewManagers(viewerTypStr, lst);
6650 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6651 if (viewIndex >= 0 && viewIndex < lst.count()) {
6652 SUIT_ViewManager* vman = lst.at(viewIndex);
6653 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6655 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6657 SMESH::TActorList anActorList;
6658 anActorList.push_back( aSmeshActor );
6659 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6660 aPlane->myViewWindow = vtkView;
6661 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6662 aPlane->PlaneMode = aMode;
6663 bool isOpenGLClipping = ( bool )vals[1].toInt();
6664 aPlane->IsOpenGLClipping = isOpenGLClipping;
6665 if ( aMode == SMESH::Absolute ) {
6666 aPlane->myAbsoluteOrientation = vals[2].toInt();
6667 aPlane->X = vals[3].toFloat();
6668 aPlane->Y = vals[4].toFloat();
6669 aPlane->Z = vals[5].toFloat();
6670 aPlane->Dx = vals[6].toFloat();
6671 aPlane->Dy = vals[7].toFloat();
6672 aPlane->Dz = vals[8].toFloat();
6674 else if ( aMode == SMESH::Relative ) {
6675 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6676 aPlane->myDistance = vals[3].toFloat();
6677 aPlane->myAngle[0] = vals[4].toFloat();
6678 aPlane->myAngle[1] = vals[5].toFloat();
6682 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6683 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6684 aClippingPlaneInfo.Plane = aPlane;
6685 aClippingPlaneInfo.ActorList = anActorList;
6686 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6694 int aPlaneId = val.toInt( &ok );
6695 if( ok && aPlaneId >= 0 ) {
6696 bool anIsDefinedPlane = false;
6697 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6698 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6699 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6700 TPlaneInfo& aPlaneInfo = *anIter;
6701 if( aPlaneInfo.PlaneId == aPlaneId ) {
6702 aPlaneInfo.ActorList.push_back( aSmeshActor );
6703 anIsDefinedPlane = true;
6707 if( !anIsDefinedPlane ) {
6708 TPlaneInfo aPlaneInfo;
6709 aPlaneInfo.PlaneId = aPlaneId;
6710 aPlaneInfo.ActorList.push_back( aSmeshActor );
6711 aPlaneInfo.ViewManager = vman;
6713 // to make the list sorted by plane id
6714 anIter = aPlaneInfoList.begin();
6715 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6716 const TPlaneInfo& aPlaneInfoRef = *anIter;
6717 if( aPlaneInfoRef.PlaneId > aPlaneId )
6720 aPlaneInfoList.insert( anIter, aPlaneInfo );
6725 } // if (aSmeshActor)
6726 } // other parameters than Visibility
6728 } // for names/parameters iterator
6729 } // for entries iterator
6731 // take into account planes with empty list of actors referred to them
6732 QList<SUIT_ViewManager*> aVMList;
6733 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6735 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6736 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6737 int aViewId = aPlaneDataIter->first;
6738 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6739 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6741 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6743 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6744 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6745 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6746 const TPlaneData& aPlaneData = *anIter2;
6747 int aPlaneId = aPlaneData.Id;
6749 bool anIsFound = false;
6750 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6751 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6752 const TPlaneInfo& aPlaneInfo = *anIter3;
6753 if( aPlaneInfo.PlaneId == aPlaneId ) {
6760 TPlaneInfo aPlaneInfo; // ActorList field is empty
6761 aPlaneInfo.PlaneId = aPlaneId;
6762 aPlaneInfo.ViewManager = aViewManager;
6764 // to make the list sorted by plane id
6765 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6766 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6767 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6768 if( aPlaneInfoRef.PlaneId > aPlaneId )
6771 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6777 // add clipping planes to actors according to the restored parameters
6778 // and update the clipping plane map
6779 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6780 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6781 int aViewId = anIter1->first;
6782 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6784 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6785 if( anIter2 == aPlaneDataMap.end() )
6787 const TPlaneDataList& aPlaneDataList = anIter2->second;
6789 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6790 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6791 const TPlaneInfo& aPlaneInfo = *anIter3;
6792 int aPlaneId = aPlaneInfo.PlaneId;
6793 const TActorList& anActorList = aPlaneInfo.ActorList;
6794 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6798 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6802 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6804 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6805 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6806 const TPlaneData& aPlaneData = *anIter4;
6807 if( aPlaneData.Id == aPlaneId ) {
6808 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6809 aPlane->myViewWindow = aViewWindow;
6810 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6811 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6812 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6813 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6814 aPlane->X = aPlaneData.X;
6815 aPlane->Y = aPlaneData.Y;
6816 aPlane->Z = aPlaneData.Z;
6817 aPlane->Dx = aPlaneData.Dx;
6818 aPlane->Dy = aPlaneData.Dy;
6819 aPlane->Dz = aPlaneData.Dz;
6821 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6822 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6823 aPlane->myDistance = aPlaneData.Distance;
6824 aPlane->myAngle[0] = aPlaneData.Angle[0];
6825 aPlane->myAngle[1] = aPlaneData.Angle[1];
6828 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6829 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6830 aClippingPlaneInfo.Plane = aPlane;
6831 aClippingPlaneInfo.ActorList = anActorList;
6832 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6843 // update all VTK views
6844 QList<SUIT_ViewManager*> lst;
6845 getApp()->viewManagers(lst);
6846 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6847 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6848 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6849 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6850 // set OpenGL clipping planes
6851 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6852 vtkActorCollection* anAllActors = aCopy.GetActors();
6853 anAllActors->InitTraversal();
6854 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6855 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6856 anActor->SetOpenGLClippingPlane();
6858 vtkView->getRenderer()->ResetCameraClippingRange();
6865 \brief Adds preferences for dfont of VTK viewer
6867 \param pIf group identifier
6868 \param param parameter
6869 \return identifier of preferences
6871 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6873 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6875 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6878 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6879 fam.append( tr( "SMESH_FONT_COURIER" ) );
6880 fam.append( tr( "SMESH_FONT_TIMES" ) );
6882 setPreferenceProperty( tfont, "fonts", fam );
6884 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6885 if ( needSize ) f = f | QtxFontEdit::Size;
6886 setPreferenceProperty( tfont, "features", f );
6892 \brief Actions after hypothesis edition
6893 Updates object browser after hypothesis edition
6895 void SMESHGUI::onHypothesisEdit( int result )
6898 SMESHGUI::Modified();
6899 updateObjBrowser( true );
6903 \brief Actions after choosing menu of control modes
6904 Updates control mode actions according to current selection
6906 void SMESHGUI::onUpdateControlActions()
6908 SALOME_ListIO selected;
6909 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
6910 aSel->selectedObjects( selected );
6912 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
6913 if ( selected.Extent() ) {
6914 if ( selected.First()->hasEntry() ) {
6915 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
6916 aControl = anActor->GetControlMode();
6917 SALOME_ListIteratorOfListIO it(selected);
6918 for ( it.Next(); it.More(); it.Next() ) {
6919 Handle(SALOME_InteractiveObject) anIO = it.Value();
6920 if ( anIO->hasEntry() ) {
6921 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
6922 if ( aControl != anActor->GetControlMode() ) {
6923 aControl = SMESH_Actor::eNone;
6933 int anAction = ActionToControl( aControl, true );
6935 action( anAction )->setChecked( true );
6937 QMenu* send = (QMenu*)sender();
6938 QList<QAction*> actions = send->actions();
6939 for ( int i = 0; i < actions.size(); i++ )
6940 actions[i]->setChecked( false );
6946 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6947 \param pview view being closed
6949 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6950 #ifndef DISABLE_PLOT2DVIEWER
6951 //Crear all Plot2d Viewers if need.
6952 SMESH::ClearPlot2Viewers(pview);
6954 EmitSignalCloseView();
6957 void SMESHGUI::message( const QString& msg )
6960 QStringList data = msg.split("/");
6961 if ( data.count() > 0 ) {
6962 if ( data.first() == "mesh_loading" ) {
6964 QString entry = data.count() > 1 ? data[1] : QString();
6965 if ( entry.isEmpty() )
6968 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6970 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6973 name = SMESH::fromUtf8(obj->GetName());
6974 if ( name.isEmpty() )
6977 if ( data.last() == "stop" )
6978 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6980 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6981 QApplication::processEvents();
6987 \brief Connects or disconnects signals about activating and cloning view on the module slots
6988 \param pview view which is connected/disconnected
6990 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6994 SUIT_ViewManager* viewMgr = pview->getViewManager();
6996 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6997 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6999 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7000 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7005 \brief Return \c true if object can be renamed
7007 bool SMESHGUI::renameAllowed( const QString& entry) const {
7008 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7012 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7016 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7021 if(appStudy->isComponent(entry) || obj->isReference())
7024 // check type to prevent renaming of inappropriate objects
7025 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7026 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7027 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7028 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7029 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7030 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7037 Rename object by entry.
7038 \param entry entry of the object
7039 \param name new name of the object
7040 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7042 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7044 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7048 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7053 _PTR(Study) aStudy = appStudy->studyDS();
7058 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7060 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7065 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7066 _PTR(GenericAttribute) anAttr;
7067 _PTR(AttributeName) aName;
7069 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7071 // check type to prevent renaming of inappropriate objects
7072 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7073 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7074 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7075 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7076 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7077 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7078 if ( !name.isEmpty() ) {
7079 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
7081 // update name of group object and its actor
7082 Handle(SALOME_InteractiveObject) IObject =
7083 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7085 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7086 if( !aGroupObject->_is_nil() ) {
7087 aGroupObject->SetName( qPrintable(name) );
7088 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7089 anActor->setName( qPrintable(name) );
7099 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7101 static QList<QColor> colors;
7103 if ( colors.isEmpty() ) {
7105 for (int s = 0; s < 2 ; s++)
7107 for (int v = 100; v >= 40; v = v - 20)
7109 for (int h = 0; h < 359 ; h = h + 60)
7111 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7116 static int currentColor = randomize( colors.size() );
7118 SALOMEDS::Color color;
7119 color.R = (double)colors[currentColor].red() / 255.0;
7120 color.G = (double)colors[currentColor].green() / 255.0;
7121 color.B = (double)colors[currentColor].blue() / 255.0;
7123 currentColor = (currentColor+1) % colors.count();