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_DisplayEntitiesDlg.h"
44 #include "SMESHGUI_Displayer.h"
45 #include "SMESHGUI_DuplicateNodesDlg.h"
46 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
47 #include "SMESHGUI_ExtrusionDlg.h"
48 #include "SMESHGUI_FaceGroupsSeparatedByEdgesDlg.h"
49 #include "SMESHGUI_FieldSelectorWdg.h"
50 #include "SMESHGUI_FileInfoDlg.h"
51 #include "SMESHGUI_FileValidator.h"
52 #include "SMESHGUI_FilterDlg.h"
53 #include "SMESHGUI_FilterLibraryDlg.h"
54 #include "SMESHGUI_FilterUtils.h"
55 #include "SMESHGUI_FindElemByPointDlg.h"
56 #include "SMESHGUI_GEOMGenUtils.h"
57 #include "SMESHGUI_GroupDlg.h"
58 #include "SMESHGUI_GroupOnShapeDlg.h"
59 #include "SMESHGUI_GroupOpDlg.h"
60 #include "SMESHGUI_GroupUtils.h"
61 #include "SMESHGUI_Hypotheses.h"
62 #include "SMESHGUI_HypothesesUtils.h"
63 #include "SMESHGUI_Make2DFrom3DOp.h"
64 #include "SMESHGUI_MakeNodeAtPointDlg.h"
65 #include "SMESHGUI_Measurements.h"
66 #include "SMESHGUI_MergeDlg.h"
67 #include "SMESHGUI_MeshInfo.h"
68 #include "SMESHGUI_MeshOp.h"
69 #include "SMESHGUI_MeshOrderOp.h"
70 #include "SMESHGUI_MeshPatternDlg.h"
71 #include "SMESHGUI_MeshUtils.h"
72 #include "SMESHGUI_MultiEditDlg.h"
73 #include "SMESHGUI_NodesDlg.h"
74 #include "SMESHGUI_OffsetDlg.h"
75 #include "SMESHGUI_Operations.h"
76 #include "SMESHGUI_PatternUtils.h"
77 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
78 #include "SMESHGUI_PropertiesDlg.h"
79 #include "SMESHGUI_RemoveElementsDlg.h"
80 #include "SMESHGUI_RemoveNodesDlg.h"
81 #include "SMESHGUI_RenumberingDlg.h"
82 #include "SMESHGUI_ReorientFacesDlg.h"
83 #include "SMESHGUI_RevolutionDlg.h"
84 #include "SMESHGUI_RotationDlg.h"
85 #include "SMESHGUI_ScaleDlg.h"
86 #include "SMESHGUI_Selection.h"
87 #include "SMESHGUI_SewingDlg.h"
88 #include "SMESHGUI_SingleEditDlg.h"
89 #include "SMESHGUI_SmoothingDlg.h"
90 #include "SMESHGUI_SpinBox.h"
91 #include "SMESHGUI_SplitBiQuad.h"
92 #include "SMESHGUI_SymmetryDlg.h"
93 #include "SMESHGUI_TranslationDlg.h"
94 #include "SMESHGUI_TransparencyDlg.h"
95 #include "SMESHGUI_Utils.h"
96 #include "SMESHGUI_VTKUtils.h"
98 #include "SMESH_version.h"
100 #include "SMESH_ControlsDef.hxx"
101 #include "SMESH_Actor.h"
102 #include "SMESH_ActorUtils.h"
103 #include "SMESH_Client.hxx"
104 #include "SMESH_ScalarBarActor.h"
105 #include <SMESH_Comment.hxx>
106 #include "SMESH_TypeFilter.hxx"
108 // SALOME GUI includes
109 #include <LightApp_DataOwner.h>
110 #include <LightApp_NameDlg.h>
111 #include <LightApp_Preferences.h>
112 #include <LightApp_SelectionMgr.h>
113 #include <LightApp_UpdateFlags.h>
114 #include <QtxFontEdit.h>
115 #include <QtxPopupMgr.h>
116 #include <SALOME_ListIO.hxx>
117 #include <SUIT_Desktop.h>
118 #include <SUIT_FileDlg.h>
119 #include <SUIT_MessageBox.h>
120 #include <SUIT_OverrideCursor.h>
121 #include <SUIT_ResourceMgr.h>
122 #include <SUIT_Session.h>
123 #include <SVTK_Renderer.h>
124 #include <SVTK_ViewManager.h>
125 #include <SVTK_ViewModel.h>
126 #include <SVTK_ViewWindow.h>
127 #include <SalomeApp_Application.h>
128 #include <SalomeApp_CheckFileDlg.h>
129 #include <SalomeApp_DataObject.h>
130 #include <SalomeApp_Study.h>
131 #include <SalomeApp_Tools.h>
132 #include <VTKViewer_Algorithm.h>
134 #ifndef DISABLE_PLOT2DVIEWER
135 #include <SPlot2d_ViewModel.h>
136 #include <SPlot2d_Histogram.h>
140 #include <SALOMEconfig.h>
141 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
142 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
143 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
144 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
147 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
148 #include <QApplication>
150 #include <QDialogButtonBox>
154 #include <QTextStream>
158 #include <boost/shared_ptr.hpp>
161 #include <vtkCallbackCommand.h>
162 #include <vtkCamera.h>
163 #include <vtkLookupTable.h>
164 #include <vtkPlane.h>
165 #include <vtkRenderer.h>
167 // SALOME KERNEL includes
168 #include <SALOMEDSClient_ClientFactory.hxx>
169 #include <SALOMEDSClient_IParameters.hxx>
170 #include <SALOMEDSClient_SComponent.hxx>
171 #include <SALOMEDSClient_StudyBuilder.hxx>
172 #include <SALOMEDS_Study.hxx>
173 #include <SALOMEDS_SObject.hxx>
174 #include "utilities.h"
177 #include <Standard_ErrorHandler.hxx>
178 #include <NCollection_DataMap.hxx>
179 #include <NCollection_DoubleMap.hxx>
181 #include <Basics_Utils.hxx>
183 // Below macro, when uncommented, switches on simplified (more performant) algorithm
184 // of auto-color picking up
185 #define SIMPLE_AUTOCOLOR
190 //=============================================================
191 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
194 void ExportMeshToFile(int theCommandID);
196 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap);
198 void SetDisplayEntity(int theCommandID);
200 int ActionToControl( int theID, bool theReversed = false );
202 void Control( int theCommandID );
205 //================================================================================
207 * \brief Reads meshes from file
209 //================================================================================
211 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
215 std::string myExtension;
217 if ( theCommandID == SMESHOp::OpImportMED ||
218 theCommandID == SMESHOp::OpPopupImportMED ) {
219 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
220 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
222 else if ( theCommandID == SMESHOp::OpImportUNV ||
223 theCommandID == SMESHOp::OpPopupImportUNV ) {
224 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
226 else if ( theCommandID == SMESHOp::OpImportDAT ||
227 theCommandID == SMESHOp::OpPopupImportDAT ) {
228 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
230 else if ( theCommandID == SMESHOp::OpImportSTL ||
231 theCommandID == SMESHOp::OpPopupImportSTL ) {
232 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
234 else if ( theCommandID == SMESHOp::OpImportCGNS ||
235 theCommandID == SMESHOp::OpPopupImportCGNS ) {
236 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
238 else if ( theCommandID == SMESHOp::OpImportSAUV ||
239 theCommandID == SMESHOp::OpPopupImportSAUV ) {
240 filter.append( QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)" );
241 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
243 else if ( theCommandID == SMESHOp::OpImportGMF ||
244 theCommandID == SMESHOp::OpPopupImportGMF ) {
245 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
246 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
249 QString anInitialPath = "";
250 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
251 anInitialPath = QDir::currentPath();
253 QStringList filenames;
254 bool toCreateGroups = true;
256 // if ( theCommandID == SMESHOp::OpImportGMF ) { // GMF
257 // SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
258 // ( SMESHGUI::desktop(), true, QObject::tr("SMESH_REQUIRED_GROUPS"), true, true );
259 // fd->setWindowTitle( QObject::tr( "SMESH_IMPORT_MESH" ) );
260 // fd->setNameFilters( filter );
261 // fd->SetChecked( true );
263 // filenames << fd->selectedFile();
264 // toCreateGroups = fd->IsChecked();
270 filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
273 QObject::tr( "SMESH_IMPORT_MESH" ) );
275 if ( filenames.count() > 0 )
277 SUIT_OverrideCursor wc;
278 _PTR(Study) aStudy = SMESH::getStudy();
281 QStringList anEntryList;
282 bool isEmpty = false;
283 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it )
285 QString filename = *it;
286 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
288 switch ( theCommandID ) {
289 case SMESHOp::OpImportDAT:
290 case SMESHOp::OpPopupImportDAT:
292 // DAT format (currently unsupported)
293 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
294 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
297 case SMESHOp::OpImportUNV:
298 case SMESHOp::OpPopupImportUNV:
301 aMeshes->length( 1 );
302 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toUtf8().constData() );
303 if ( aMeshes[0]->_is_nil() )
304 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
305 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
308 case SMESHOp::OpImportMED:
309 case SMESHOp::OpPopupImportMED:
312 SMESH::DriverMED_ReadStatus res;
313 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toUtf8().constData(), res );
314 if ( res != SMESH::DRS_OK ) {
315 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
316 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
320 case SMESHOp::OpImportSTL:
321 case SMESHOp::OpPopupImportSTL:
324 aMeshes->length( 1 );
325 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toUtf8().constData() );
326 if ( aMeshes[0]->_is_nil() ) {
327 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
328 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
332 case SMESHOp::OpImportCGNS:
333 case SMESHOp::OpPopupImportCGNS:
336 SMESH::DriverMED_ReadStatus res;
337 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toUtf8().constData(), res );
338 if ( res != SMESH::DRS_OK ) {
339 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
340 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
344 case SMESHOp::OpImportSAUV:
345 case SMESHOp::OpPopupImportSAUV:
348 SMESH::DriverMED_ReadStatus res;
349 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toUtf8().constData(), res );
350 if ( res != SMESH::DRS_OK ) {
351 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
352 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
356 case SMESHOp::OpImportGMF:
357 case SMESHOp::OpPopupImportGMF:
360 SMESH::ComputeError_var res;
361 aMeshes->length( 1 );
362 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toUtf8().constData(),
365 if ( res->code != SMESH::DRS_OK ) {
366 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
367 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
368 if ( strlen( res->comment.in() ) > 0 ) {
369 errors.back() += ": ";
370 errors.back() += res->comment.in();
377 catch ( const SALOME::SALOME_Exception& S_ex ) {
378 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
379 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
382 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ )
384 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
386 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
387 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
388 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
389 if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
390 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
392 anEntryList.append( aMeshSO->GetID().c_str() );
400 // update Object browser
401 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
403 // browse to the published meshes
404 if( LightApp_Application* anApp =
405 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
406 anApp->browseObjects( anEntryList );
408 // show Error message box if there were errors
409 if ( errors.count() > 0 ) {
410 SUIT_MessageBox::critical( SMESHGUI::desktop(),
411 QObject::tr( "SMESH_ERROR" ),
412 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
415 // show warning message box, if some imported mesh is empty
417 SUIT_MessageBox::warning( SMESHGUI::desktop(),
418 QObject::tr( "SMESH_WRN_WARNING" ),
419 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
424 //================================================================================
426 * \brief Export selected meshes or groups into a file
428 //================================================================================
430 void ExportMeshToFile( int theCommandID )
432 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
433 SALOME_ListIO selected;
435 aSel->selectedObjects( selected );
437 const bool isDAT = ( theCommandID == SMESHOp::OpExportDAT ||
438 theCommandID == SMESHOp::OpPopupExportDAT );
439 const bool isMED = ( theCommandID == SMESHOp::OpExportMED ||
440 theCommandID == SMESHOp::OpPopupExportMED );
441 const bool isUNV = ( theCommandID == SMESHOp::OpExportUNV ||
442 theCommandID == SMESHOp::OpPopupExportUNV );
443 const bool isSTL = ( theCommandID == SMESHOp::OpExportSTL ||
444 theCommandID == SMESHOp::OpPopupExportSTL );
445 const bool isCGNS= ( theCommandID == SMESHOp::OpExportCGNS ||
446 theCommandID == SMESHOp::OpPopupExportCGNS );
447 const bool isSAUV= ( theCommandID == SMESHOp::OpExportSAUV ||
448 theCommandID == SMESHOp::OpPopupExportSAUV );
449 const bool isGMF = ( theCommandID == SMESHOp::OpExportGMF ||
450 theCommandID == SMESHOp::OpPopupExportGMF );
452 const bool multiMeshSupported = ( isMED || isCGNS ); // file can hold several meshes
453 if ( selected.Extent() == 0 || ( selected.Extent() > 1 && !multiMeshSupported ))
455 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
456 bool aCheckWarn = true;
458 aCheckWarn = resMgr->booleanValue( "SMESH", "show_warning", false );
459 // get mesh object from selection and check duplication of their names
460 bool hasDuplicatedMeshNames = false;
461 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
462 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
463 SALOME_ListIteratorOfListIO It( selected );
464 for( ; It.More(); It.Next() )
466 Handle(SALOME_InteractiveObject) anIObject = It.Value();
467 SMESH::SMESH_IDSource_var aMeshItem =
468 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
469 if ( aMeshItem->_is_nil() ) {
470 SUIT_MessageBox::warning( SMESHGUI::desktop(),
471 QObject::tr( "SMESH_WRN_WARNING" ),
472 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
475 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aMeshItem );
476 if ( aCheckWarn && !aGroup->_is_nil() )
478 QMessageBox msgBox(SUIT_MessageBox::Warning,
479 QObject::tr("SMESH_WRN_WARNING"),
480 QObject::tr("SMESH_EXPORT_ONLY_GPOUP"),
481 QMessageBox::StandardButton::NoButton,
482 SMESHGUI::desktop());
483 QCheckBox dontShowCheckBox(QObject::tr("SMESH_WRN_SHOW_DLG_CHECKBOX"));
484 msgBox.addButton(QMessageBox::Ok);
485 msgBox.addButton(QMessageBox::Cancel);
486 msgBox.setDefaultButton(QMessageBox::Cancel);
487 QGridLayout* lt = qobject_cast<QGridLayout*>(msgBox.layout());
488 QDialogButtonBox* btnbox = msgBox.findChild<QDialogButtonBox*>();
489 lt->addWidget(&dontShowCheckBox, lt->rowCount(), lt->columnCount()-1, lt->rowCount(), lt->columnCount());
490 lt->addWidget(btnbox, lt->rowCount(), 0, lt->rowCount(), lt->columnCount());
491 if ( msgBox.exec() != QMessageBox::Ok )
494 if ( dontShowCheckBox.checkState() == Qt::Checked && resMgr )
495 resMgr->setValue( "SMESH", "show_warning", false);
498 QString aMeshName = anIObject->getName();
500 // check for name duplications
501 if ( !hasDuplicatedMeshNames )
502 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
503 if( aMeshName == (*aMeshIter).second ) {
504 hasDuplicatedMeshNames = true;
509 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
512 if( hasDuplicatedMeshNames && isMED ) {
513 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
514 QObject::tr("SMESH_WRN_WARNING"),
515 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
516 QObject::tr("SMESH_BUT_YES"),
517 QObject::tr("SMESH_BUT_NO"), 0, 1);
522 aMeshIter = aMeshList.begin();
523 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
524 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
525 QString aMeshName = (*aMeshIter).second;
527 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
529 // check for equal group names within each mesh
530 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
531 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
532 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
533 int aRet = SUIT_MessageBox::warning
534 (SMESHGUI::desktop(),
535 QObject::tr("SMESH_WRN_WARNING"),
536 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
537 QObject::tr("SMESH_BUT_YES"),
538 QObject::tr("SMESH_BUT_NO"), 0, 1);
545 // Warn the user about presence of not supported elements
547 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
551 notSupportedElemTypes.push_back( SMESH::Entity_0D );
552 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
557 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
558 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
559 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
560 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
561 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
562 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
563 notSupportedElemTypes.push_back( SMESH::Entity_0D );
564 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
569 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
570 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
571 notSupportedElemTypes.push_back( SMESH::Entity_0D );
572 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
577 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
582 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
583 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Triangle );
584 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
585 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
586 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
587 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
588 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
589 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
594 notSupportedElemTypes.push_back( SMESH::Entity_0D );
595 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
596 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
597 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
598 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
599 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Penta );
600 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
601 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
602 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
603 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
605 if ( ! notSupportedElemTypes.empty() )
607 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
608 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
609 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
610 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
612 if ( !presentNotSupported.empty() )
615 const char* typeMsg[] = {
616 "SMESH_NODES", "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES",
617 "SMESH_TRIANGLES", "SMESH_QUADRATIC_TRIANGLES", "SMESH_BIQUADRATIC_TRIANGLES",
618 "SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES", "SMESH_BIQUADRATIC_QUADRANGLES",
619 "SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
620 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
621 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
622 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
623 "SMESH_BIQUADRATIC_PENTAHEDRONS",
624 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
626 // is typeMsg complete? (compilation failure mains that enum SMDSAbs_EntityType changed)
627 const int nbTypes = sizeof( typeMsg ) / sizeof( const char* );
628 int _assert[( nbTypes == SMESH::Entity_Last ) ? 2 : -1 ]; _assert[0]=_assert[1]=0;
630 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
631 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
632 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
633 if ( iType != presentNotSupported.size() - 1 )
634 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
636 int aRet = SUIT_MessageBox::warning
637 (SMESHGUI::desktop(),
638 QObject::tr("SMESH_WRN_WARNING"),
639 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
640 QObject::tr("SMESH_BUT_YES"),
641 QObject::tr("SMESH_BUT_NO"), 0, 1);
646 // Get parameters of export operation
649 int aFormat =-1; // for MED version used for write
650 bool isOkToWrite = true; // to check MED file version compatibility before adding a mesh in an existing file
652 // Init the parameters with the default values
653 bool aIsASCII_STL = true;
654 bool toCreateGroups = false;
656 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
657 bool toOverwrite = true;
658 bool toFindOutDim = true;
659 double zTol = resMgr ? resMgr->doubleValue( "SMESH", "med_ztolerance", 0. ) : 0.;
661 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
662 QString anInitialPath = "";
663 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
664 anInitialPath = QDir::currentPath();
666 QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList;
668 // Get a file name to write in and additional options
669 if ( isUNV || isDAT || isGMF ) // Export w/o options
672 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
674 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
676 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
677 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
678 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
679 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
680 anInitialPath + QString("/") + aMeshName,
681 aFilter, aTitle, false);
683 else if ( isCGNS )// Export to CGNS
685 const char* theByTypeResource = "cgns_group_elems_by_type";
686 toCreateGroups = SMESHGUI::resourceMgr()->booleanValue( "SMESH", theByTypeResource, false );
688 QStringList checkBoxes;
689 checkBoxes << QObject::tr("CGNS_EXPORT_ELEMS_BY_TYPE");
691 SalomeApp_CheckFileDlg* fd =
692 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
693 fd->setWindowTitle( aTitle );
694 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
695 if ( !anInitialPath.isEmpty() )
696 fd->setDirectory( anInitialPath );
697 fd->selectFile(aMeshName);
698 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
699 fd->setValidator( fv );
700 fd->SetChecked( toCreateGroups, 0 );
703 aFilename = fd->selectedFile();
704 toOverwrite = fv->isOverwrite(aFilename);
705 toCreateGroups = fd->IsChecked(0);
706 SMESHGUI::resourceMgr()->setValue("SMESH", theByTypeResource, toCreateGroups );
710 else if ( isSTL ) // Export to STL
712 QMap<QString, int> aFilterMap;
713 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
714 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
717 QMap<QString, int>::const_iterator it = aFilterMap.begin();
718 for ( ; it != aFilterMap.end(); ++it )
719 filters.push_back( it.key() );
721 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
722 fd->setWindowTitle( aTitle );
723 fd->setNameFilters( filters );
724 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
725 if ( !anInitialPath.isEmpty() )
726 fd->setDirectory( anInitialPath );
727 fd->selectFile(aMeshName);
731 aFilename = fd->selectedFile();
732 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
737 else if ( isMED || isSAUV ) // Export to MED or SAUV
739 int defaultVersion = 0;
740 QMap<QString, int> aFilterMap;
742 //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
743 //QString vmed (aMesh->GetVersionString(-1, 2));
744 SMESH::long_array_var mvok = aMesh->GetMEDVersionsCompatibleForAppend();
745 if ( mvok->length() > 0)
746 defaultVersion = mvok[0]; // the current version to set the default filter on it
747 for ( CORBA::ULong i = 0; i < mvok->length(); ++i )
749 QString vs = (char*)( SMESH_Comment( mvok[i]/10 ) << "." << mvok[i]%10 );
750 MESSAGE("MED version: " << vs.toStdString());
751 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", mvok[i]);
755 aFilterMap.insert("All files (*)", -1 );
756 aFilterMap.insert("SAUV files (*.sauv)", defaultVersion ); // 0 = default filter (defaultVersion)
757 aFilterMap.insert("SAUV files (*.sauve)", -1 );
760 QMap<QString, int>::const_iterator it = aFilterMap.begin();
761 QString aDefaultFilter = it.key();
762 for ( ; it != aFilterMap.end(); ++it ) {
763 filters.push_back( it.key() );
764 if (it.value() == defaultVersion) // explicit default for MED = current MED version
765 aDefaultFilter = it.key();
767 QStringList checkBoxes;
768 checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
770 SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg();
771 QList< QWidget* > wdgList;
772 if ( fieldSelWdg->GetAllFields( aMeshList, aFieldList ))
773 wdgList.append( fieldSelWdg );
775 QWidget* zTolWdg = new QWidget();
776 QCheckBox* zTolCheck = new QCheckBox( QObject::tr( "SMESH_ZTOLERANCE" ), zTolWdg );
777 SMESHGUI_SpinBox* zTolSpin = new SMESHGUI_SpinBox( zTolWdg );
778 QHBoxLayout* zTolLayout = new QHBoxLayout( zTolWdg );
779 zTolLayout->addWidget( zTolCheck );
780 zTolLayout->addWidget( zTolSpin );
781 zTolLayout->setMargin( 0 );
782 zTolSpin->RangeStepAndValidator( 0, 1e+100, 1., "length_precision" );
783 zTolSpin->setValue( zTol );
784 QObject::connect( zTolCheck, SIGNAL( toggled(bool)), zTolSpin, SLOT( setEnabled(bool)));
785 zTolCheck->setChecked( resMgr->booleanValue( "SMESH", "enable_ztolerance", false ));
786 zTolSpin ->setEnabled( zTolCheck->isChecked() );
787 wdgList.append( zTolWdg );
789 SalomeApp_CheckFileDlg* fd =
790 new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList );
791 fd->setWindowTitle( aTitle );
792 fd->setNameFilters( filters );
793 fd->selectNameFilter( aDefaultFilter );
794 fd->SetChecked( toCreateGroups, 0 );
795 fd->SetChecked( toFindOutDim, 1 );
796 if ( !anInitialPath.isEmpty() )
797 fd->setDirectory( anInitialPath );
798 fd->selectFile(aMeshName);
801 QListView *lview = fd->findChild<QListView*>("listView");
803 lview->setMinimumHeight(200);
805 QTreeView *tview = fd->findChild<QTreeView*>("treeView");
807 tview->setMinimumHeight(200);
810 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
811 fd->setValidator( fv );
816 //MESSAGE("******* Loop on file dialog ***********");
819 aFilename = fd->selectedFile();
821 aFilename = QString::null;
824 aFormat = aFilterMap[fd->selectedNameFilter()];
825 //MESSAGE("selected version: " << aFormat << " file: " << aFilename.toUtf8().constData());
826 toOverwrite = fv->isOverwrite(aFilename);
827 //MESSAGE("toOverwrite:" << toOverwrite);
829 if ( !aFilename.isEmpty() ) {
831 // append is only possible if the existing file format is compatible
832 bool isVersionOk = SMESHGUI::GetSMESHGen()->CheckWriteCompatibility( aFilename.toUtf8().constData() );
833 MESSAGE("Append check, isVersionOk:" << isVersionOk);
834 if ( !isVersionOk ) {
835 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
836 QObject::tr("SMESH_WRN_WARNING"),
837 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
838 QObject::tr("SMESH_BUT_YES"),
839 QObject::tr("SMESH_BUT_NO"), 0, 1);
843 //MESSAGE("incompatible MED file version for add, overwrite accepted");
849 //MESSAGE("incompatible MED file version for add, overwrite refused");
852 QStringList aMeshNamesCollisionList;
853 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toUtf8().constData() );
854 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
855 QString anExistingMeshName( aMeshNames[ i ] );
856 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
857 QString anExportMeshName = (*aMeshIter).second;
858 if( anExportMeshName == anExistingMeshName ) {
859 aMeshNamesCollisionList.append( anExportMeshName );
864 if( !aMeshNamesCollisionList.isEmpty() ) {
866 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
867 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
868 QObject::tr("SMESH_WRN_WARNING"),
869 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
870 QObject::tr("SMESH_BUT_YES"),
871 QObject::tr("SMESH_BUT_NO"),
872 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
873 MESSAGE("answer collision name " << aRet);
884 toCreateGroups = fd->IsChecked(0);
885 toFindOutDim = fd->IsChecked(1);
886 zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1;
887 fieldSelWdg->GetSelectedFields();
888 if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() );
890 if ( !fieldSelWdg->parent() )
892 if ( !zTolWdg->parent() )
903 if ( !aFilename.isEmpty() ) {
904 // Check whether the file already exists and delete it if yes
905 QFile aFile( aFilename );
906 if ( aFile.exists() && toOverwrite )
908 SUIT_OverrideCursor wc;
911 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
912 // bool Renumber = false;
913 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
915 // Renumber= resMgr->booleanValue("renumbering");
917 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
918 // aMeshEditor->RenumberNodes();
919 // aMeshEditor->RenumberElements();
920 // if ( SMESHGUI::automaticUpdate() )
921 // SMESH::UpdateView();
923 if ( isMED && isOkToWrite)
925 MESSAGE("OK to write MED file "<< aFilename.toUtf8().constData());
926 aMeshIter = aMeshList.begin();
927 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
929 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
930 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
931 const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in();
932 const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
933 const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
934 if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ) && zTol < 0 )
935 aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups, aFormat,
936 toOverwrite && aMeshIndex == 0, toFindOutDim );
938 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(),
939 toCreateGroups, aFormat,
940 toOverwrite && aMeshIndex == 0, toFindOutDim,
941 fields, geoAssFields.toLatin1().data(), zTol );
946 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
948 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
949 if( !aMeshItem->_is_nil() )
950 aMeshItem->ExportSAUV( aFilename.toUtf8().data(), toCreateGroups );
955 if ( aMeshOrGroup->_is_equivalent( aMesh ))
956 aMesh->ExportDAT( aFilename.toUtf8().data() );
958 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toUtf8().data() );
962 if ( aMeshOrGroup->_is_equivalent( aMesh ))
963 aMesh->ExportUNV( aFilename.toUtf8().data() );
965 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toUtf8().data() );
969 if ( aMeshOrGroup->_is_equivalent( aMesh ))
970 aMesh->ExportSTL( aFilename.toUtf8().data(), aIsASCII_STL );
972 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toUtf8().data(), aIsASCII_STL );
976 aMeshIter = aMeshList.begin();
977 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
979 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
980 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
981 aMeshItem->ExportCGNS( aMeshOrGroup,
982 aFilename.toUtf8().data(),
983 toOverwrite && aMeshIndex == 0,
989 toCreateGroups = true;
990 aMesh->ExportGMF( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups );
993 catch (const SALOME::SALOME_Exception& S_ex){
995 SUIT_MessageBox::warning(SMESHGUI::desktop(),
996 QObject::tr("SMESH_WRN_WARNING"),
997 QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
1003 inline void InverseEntityMode(unsigned int& theOutputMode,
1004 unsigned int theMode)
1006 bool anIsNotPresent = ~theOutputMode & theMode;
1008 theOutputMode |= theMode;
1010 theOutputMode &= ~theMode;
1013 void SetDisplayEntity(int theCommandID)
1015 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1016 SALOME_ListIO selected;
1018 aSel->selectedObjects( selected );
1020 if ( selected.Extent() >= 1 ) {
1021 SUIT_OverrideCursor wc;
1022 SALOME_ListIteratorOfListIO It( selected );
1023 for( ; It.More(); It.Next()){
1024 Handle(SALOME_InteractiveObject) IObject = It.Value();
1025 if(IObject->hasEntry()){
1026 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1027 unsigned int aMode = anActor->GetEntityMode();
1028 switch(theCommandID){
1029 case SMESHOp::OpDE0DElements: InverseEntityMode(aMode,SMESH_Actor::e0DElements); break;
1030 case SMESHOp::OpDEEdges: InverseEntityMode(aMode,SMESH_Actor::eEdges); break;
1031 case SMESHOp::OpDEFaces: InverseEntityMode(aMode,SMESH_Actor::eFaces); break;
1032 case SMESHOp::OpDEVolumes: InverseEntityMode(aMode,SMESH_Actor::eVolumes); break;
1033 case SMESHOp::OpDEBalls: InverseEntityMode(aMode,SMESH_Actor::eBallElem); break;
1034 case SMESHOp::OpDEAllEntity: aMode = SMESH_Actor::eAllEntity; break;
1037 anActor->SetEntityMode(aMode);
1046 SalomeApp_Application* app =
1047 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1051 LightApp_SelectionMgr* aSel = app->selectionMgr();
1052 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1053 if ( !aSel || !appStudy )
1056 SALOME_ListIO selected;
1057 aSel->selectedObjects( selected );
1058 if ( selected.IsEmpty() )
1061 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1063 _PTR(Study) aStudy = appStudy->studyDS();
1064 _PTR(SObject) aMainSObject = aStudy->FindObjectID( anIObject->getEntry() );
1065 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1066 if ( aMainObject->_is_nil() )
1069 SUIT_OverrideCursor wc;
1071 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
1073 QList<SALOMEDS::Color> aReservedColors;
1075 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
1076 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ )
1078 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
1080 #ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
1081 SALOMEDS::Color aColor = SMESHGUI::getPredefinedUniqueColor();
1082 #else // old algorithm for auto-colors
1083 SALOMEDS::Color aColor = SMESHGUI::getUniqueColor( aReservedColors );
1084 aReservedColors.append( aColor );
1085 #endif // SIMPLE_AUTOCOLOR
1086 aGroupObject->SetColor( aColor );
1088 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
1089 if ( aGroupSObject ) {
1092 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
1093 switch ( aGroupObject->GetType ()) {
1095 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
1097 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
1099 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
1101 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
1103 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
1104 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
1107 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
1108 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
1114 SMESH::RepaintCurrentView();
1117 void OverallMeshQuality()
1119 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1120 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1121 SALOME_ListIO selected;
1123 aSel->selectedObjects( selected );
1125 if ( selected.IsEmpty() ) return;
1126 SALOME_ListIteratorOfListIO It( selected );
1127 for ( ; It.More(); It.Next() ) {
1128 SMESHGUI_CtrlInfoDlg* ctrlDlg = new SMESHGUI_CtrlInfoDlg( SMESHGUI::desktop() );
1129 ctrlDlg->showInfo( It.Value() );
1134 QString functorToString( SMESH::Controls::FunctorPtr f )
1136 QString type = QObject::tr( "UNKNOWN_CONTROL" );
1137 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
1138 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
1139 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
1140 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
1141 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
1142 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
1143 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
1144 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
1145 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
1146 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
1147 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
1148 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
1149 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
1150 type = QObject::tr( "WARP_ELEMENTS" );
1151 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
1152 type = QObject::tr( "TAPER_ELEMENTS" );
1153 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
1154 type = QObject::tr( "SKEW_ELEMENTS" );
1155 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
1156 type = QObject::tr( "AREA_ELEMENTS" );
1157 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
1158 type = QObject::tr( "LENGTH_EDGES" );
1159 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1160 type = QObject::tr( "LENGTH2D_EDGES" );
1161 else if ( dynamic_cast< SMESH::Controls::Deflection2D* >( f.get() ) )
1162 type = QObject::tr( "DEFLECTION2D_FACES" );
1163 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1164 type = QObject::tr( "MULTI_BORDERS" );
1165 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1166 type = QObject::tr( "MULTI2D_BORDERS" );
1167 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1168 type = QObject::tr( "FREE_NODES" );
1169 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1170 type = QObject::tr( "FREE_EDGES" );
1171 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1172 type = QObject::tr( "FREE_BORDERS" );
1173 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1174 type = QObject::tr( "FREE_FACES" );
1175 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1176 type = QObject::tr( "BARE_BORDER_VOLUME" );
1177 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1178 type = QObject::tr( "BARE_BORDER_FACE" );
1179 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1180 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1181 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1182 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1183 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1184 type = QObject::tr( "EQUAL_NODE" );
1185 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1186 type = QObject::tr( "EQUAL_EDGE" );
1187 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1188 type = QObject::tr( "EQUAL_FACE" );
1189 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1190 type = QObject::tr( "EQUAL_VOLUME" );
1191 else if ( dynamic_cast< SMESH::Controls::NodeConnectivityNumber* >( f.get() ) )
1192 type = QObject::tr( "NODE_CONNECTIVITY_NB" );
1196 void SaveDistribution()
1198 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1199 SALOME_ListIO selected;
1201 aSel->selectedObjects( selected );
1203 if ( selected.Extent() == 1 ) {
1204 Handle(SALOME_InteractiveObject) anIO = selected.First();
1205 if ( anIO->hasEntry() ) {
1206 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1208 anActor->GetScalarBarActor() &&
1209 anActor->GetControlMode() != SMESH_Actor::eNone )
1211 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1212 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1213 if ( aScalarBarActor && aFunctor ) {
1214 SMESH::Controls::NumericalFunctor* aNumFun =
1215 dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1217 std::vector<int> elements;
1218 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1219 if ( mesh->_is_nil() ) {
1220 SMESH::SMESH_IDSource_var idSource =
1221 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1222 if ( !idSource->_is_nil() )
1224 SMESH::long_array_var ids = idSource->GetIDs();
1225 elements.resize( ids->length() );
1226 for ( unsigned i = 0; i < elements.size(); ++i )
1227 elements[i] = ids[i];
1230 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1231 vtkLookupTable* lookupTable =
1232 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1233 double * minmax = lookupTable->GetRange();
1234 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
1235 std::vector<int> nbEvents;
1236 std::vector<double> funValues;
1237 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues,
1238 elements, minmax, isLogarithmic );
1239 QString anInitialPath = "";
1240 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1241 anInitialPath = QDir::currentPath();
1242 QString aMeshName = anIO->getName();
1244 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1245 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1246 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1247 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1248 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1251 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1253 if ( !aFilename.isEmpty() ) {
1254 QFile f( aFilename );
1255 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1256 QTextStream out( &f );
1257 out << "# Mesh: " << aMeshName << endl;
1258 out << "# Control: " << functorToString( aFunctor ) << endl;
1260 out.setFieldWidth( 10 );
1261 for ( int i = 0; i < (int)qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1262 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1273 void ShowElement( int theCommandID )
1275 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1276 SALOME_ListIO selected;
1278 aSel->selectedObjects( selected );
1280 if ( selected.Extent() == 1 ) {
1281 Handle(SALOME_InteractiveObject) anIO = selected.First();
1282 if ( anIO->hasEntry() ) {
1283 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1285 anActor->GetScalarBarActor() &&
1286 anActor->GetControlMode() != SMESH_Actor::eNone )
1288 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1289 if ( theCommandID == SMESHOp::OpShowDistribution ) {
1290 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1292 else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
1293 aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
1300 #ifndef DISABLE_PLOT2DVIEWER
1301 void PlotDistribution()
1303 SalomeApp_Application* app =
1304 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1308 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1309 SALOME_ListIO selected;
1311 aSel->selectedObjects( selected );
1313 if ( selected.Extent() == 1 ) {
1314 Handle(SALOME_InteractiveObject) anIO = selected.First();
1315 if ( anIO->hasEntry() ) {
1316 //Find Actor by entry before getting Plot2d viewer,
1317 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1318 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1320 SUIT_ViewManager* aViewManager =
1321 app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1325 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1329 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1333 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone )
1335 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1336 QString functorName = functorToString( anActor->GetFunctor());
1337 QString aHistogramName("%1 : %2");
1338 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1339 aHistogram->setName(aHistogramName);
1340 aHistogram->setHorTitle(functorName);
1341 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1342 aPlot->displayObject(aHistogram, true);
1347 #endif //DISABLE_PLOT2DVIEWER
1349 void DisableAutoColor()
1351 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1352 SALOME_ListIO selected;
1354 aSel->selectedObjects( selected );
1356 if ( selected.Extent() ) {
1357 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1358 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1359 if ( !aMesh->_is_nil() ) {
1360 aMesh->SetAutoColor( false );
1367 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1368 SALOME_ListIO selected;
1370 aSel->selectedObjects( selected );
1371 if ( selected.Extent() )
1373 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1374 _PTR(Study) aStudy = SMESH::getStudy();
1375 _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry());
1377 if ( aStudy->GetUseCaseBuilder()->SortChildren( aSObj, true/*AscendingOrder*/ ) ) {
1378 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1385 void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
1387 SALOME_ListIO selected;
1388 SalomeApp_Application* app =
1389 dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1393 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1394 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1395 if ( !aSel || !appStudy )
1398 if ( theCommandID == SMESHOp::OpClipping ) { // Clipping dialog can be activated without selection
1399 if ( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1400 aModule->EmitSignalDeactivateDialog();
1401 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1402 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1407 aSel->selectedObjects( selected );
1409 if ( selected.Extent() >= 1 )
1411 switch ( theCommandID ) {
1412 case SMESHOp::OpTransparency:
1414 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1415 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1418 case SMESHOp::OpProperties:
1421 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1422 QColor orientationColor, outlineColor, volumeColor;
1423 int deltaF = 0, deltaV = 0;
1426 double ballScale = 1.0;
1428 int outlineWidth = 1;
1429 double shrinkCoef = 0.0;
1430 double orientationScale = 0.0;
1431 bool orientation3d = false;
1432 VTK::MarkerType markerType = VTK::MT_NONE;
1433 VTK::MarkerScale markerScale = VTK::MS_NONE;
1435 bool hasNodes = false;
1436 int presentEntities = 0;
1437 bool firstTime = true;
1439 SALOME_ListIteratorOfListIO It( selected );
1440 for ( ; It.More(); It.Next() ) {
1441 Handle(SALOME_InteractiveObject) IObject = It.Value();
1442 if ( !IObject->hasEntry() ) continue;
1443 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1444 if ( !anActor || !anActor->GetObject() ) continue;
1447 // nodes: color, marker
1448 anActor->GetNodeColor( color[0], color[1], color[2] );
1449 nodeColor.setRgbF( color[0], color[1], color[2] );
1450 markerType = anActor->GetMarkerType();
1451 markerScale = anActor->GetMarkerScale();
1452 markerId = anActor->GetMarkerTexture();
1453 // edges: color, width
1454 anActor->GetEdgeColor( color[0], color[1], color[2] );
1455 edgeColor.setRgbF( color[0], color[1], color[2] );
1456 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1457 // faces: front color, back color (delta)
1458 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1459 faceColor.setRgbF( color[0], color[1], color[2] );
1460 // faces: front color, back color (delta)
1461 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1462 volumeColor.setRgbF( color[0], color[1], color[2] );
1463 // 0d elements: color, size
1464 anActor->Get0DColor( color[0], color[1], color[2] );
1465 elem0dColor.setRgbF( color[0], color[1], color[2] );
1466 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1467 // balls: color, size
1468 anActor->GetBallColor( color[0], color[1], color[2] );
1469 ballColor.setRgbF( color[0], color[1], color[2] );
1470 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1471 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
1473 anActor->GetOutlineColor( color[0], color[1], color[2] );
1474 outlineColor.setRgbF( color[0], color[1], color[2] );
1475 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1476 // orientation vectors: color, scale, 3d flag
1477 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1478 orientationColor.setRgbF( color[0], color[1], color[2] );
1479 orientationScale = anActor->GetFacesOrientationScale();
1480 orientation3d = anActor->GetFacesOrientation3DVectors();
1482 shrinkCoef = anActor->GetShrinkFactor();
1485 firstTime = false; // we only take properties from first object (for performance reasons)
1488 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1489 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1490 presentEntities = presentEntities | SMESH_Actor::eEdges;
1491 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1492 presentEntities = presentEntities | SMESH_Actor::eFaces;
1493 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1494 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1495 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1496 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1497 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1498 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1500 // as we know that all types of elements are present, we can exit the loop
1501 if ( presentEntities == SMESH_Actor::eAllEntity )
1505 SMESHGUI_PropertiesDlg dlg( theMarkerMap, SMESHGUI::desktop() );
1506 // nodes: color, marker
1507 dlg.setNodeColor( nodeColor );
1508 if( markerType != VTK::MT_USER )
1509 dlg.setNodeMarker( markerType, markerScale );
1511 dlg.setNodeCustomMarker( markerId );
1512 // edges: color, line width
1513 dlg.setEdgeColor( edgeColor );
1514 dlg.setEdgeWidth( edgeWidth );
1515 // faces: front color, back color
1516 dlg.setFaceColor( faceColor, deltaF );
1517 // volumes: normal color, reversed color
1518 dlg.setVolumeColor( volumeColor, deltaV );
1519 // outlines: color, line width
1520 dlg.setOutlineColor( outlineColor );
1521 dlg.setOutlineWidth( outlineWidth );
1522 // 0d elements: color, size
1523 dlg.setElem0dColor( elem0dColor );
1524 dlg.setElem0dSize( elem0dSize );
1525 // balls: color, size
1526 dlg.setBallColor( ballColor );
1527 //dlg.setBallSize( ballSize );
1528 dlg.setBallScale( ballScale );
1529 // orientation: color, scale, 3d flag
1530 dlg.setOrientationColor( orientationColor );
1531 dlg.setOrientationSize( int( orientationScale * 100. ) );
1532 dlg.setOrientation3d( orientation3d );
1533 // shrink: scale factor
1534 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1535 // hide unused controls
1536 dlg.showControls( presentEntities, hasNodes );
1539 nodeColor = dlg.nodeColor();
1540 markerType = dlg.nodeMarkerType();
1541 markerScale = dlg.nodeMarkerScale();
1542 markerId = dlg.nodeMarkerId();
1543 edgeColor = dlg.edgeColor();
1544 edgeWidth = dlg.edgeWidth();
1545 faceColor = dlg.faceColor();
1546 deltaF = dlg.faceColorDelta();
1547 volumeColor = dlg.volumeColor();
1548 deltaV = dlg.volumeColorDelta();
1549 outlineColor = dlg.outlineColor();
1550 outlineWidth = dlg.outlineWidth();
1551 elem0dColor = dlg.elem0dColor();
1552 elem0dSize = dlg.elem0dSize();
1553 ballColor = dlg.ballColor();
1554 // ballSize = dlg.ballSize();
1555 ballScale = dlg.ballScale();
1556 orientationColor = dlg.orientationColor();
1557 orientationScale = dlg.orientationSize() / 100.;
1558 orientation3d = dlg.orientation3d();
1559 shrinkCoef = dlg.shrinkCoef() / 100.;
1561 // store point markers that might be changed by the user
1562 theMarkerMap = dlg.customMarkers();
1564 // set properties from dialog box to the presentations
1565 SALOME_ListIteratorOfListIO It( selected );
1566 for ( ; It.More(); It.Next() ) {
1567 Handle(SALOME_InteractiveObject) IObject = It.Value();
1568 if ( !IObject->hasEntry() ) continue;
1569 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1570 if ( !anActor ) continue;
1572 // nodes: color, marker
1573 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1574 if ( markerType != VTK::MT_USER ) {
1575 anActor->SetMarkerStd( markerType, markerScale );
1578 VTK::MarkerMap::const_iterator iter = theMarkerMap.find( markerId );
1579 if ( iter != theMarkerMap.end() )
1580 anActor->SetMarkerTexture( markerId, iter->second.second );
1582 // volumes: normal color, reversed color (delta)
1583 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1584 // faces: front color, back color (delta)
1585 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1586 // edges: color, width
1587 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1588 anActor->SetLineWidth( edgeWidth );
1590 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1591 anActor->SetOutlineWidth( outlineWidth );
1592 // 0D elements: color, size
1593 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1594 anActor->Set0DSize( elem0dSize );
1595 // balls: color, size
1596 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1597 // anActor->SetBallSize( ballSize );
1598 anActor->SetBallScale( ballScale );
1599 // orientation: color, scale, 3d flag
1600 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1601 anActor->SetFacesOrientationScale( orientationScale );
1602 anActor->SetFacesOrientation3DVectors( orientation3d );
1604 anActor->SetShrinkFactor( shrinkCoef );
1606 // for groups, set also proper color
1607 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1608 if ( !aGroupObject->_is_nil() ) {
1609 SMESH::ElementType anElementType = aGroupObject->GetType();
1611 switch( anElementType ) {
1613 aColor = nodeColor; break;
1615 aColor = edgeColor; break;
1617 aColor = faceColor; break;
1619 aColor = volumeColor; break;
1621 aColor = elem0dColor; break;
1623 aColor = ballColor; break;
1627 if ( aColor.isValid() ) {
1628 SALOMEDS::Color aGroupColor;
1629 aGroupColor.R = aColor.redF();
1630 aGroupColor.G = aColor.greenF();
1631 aGroupColor.B = aColor.blueF();
1632 aGroupObject->SetColor( aGroupColor );
1634 } // if ( !aGroupObject->_is_nil() )
1635 } // for ( ; It.More(); It.Next() )
1636 SMESH::RepaintCurrentView();
1637 } // if ( dlg.exec() )
1639 } // case SMESHOp::OpProperties:
1640 } // switch(theCommandID)
1641 SUIT_OverrideCursor wc;
1642 SALOME_ListIteratorOfListIO It( selected );
1643 for( ; It.More(); It.Next()){
1644 Handle(SALOME_InteractiveObject) IObject = It.Value();
1645 if(IObject->hasEntry()){
1646 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1647 switch(theCommandID){
1648 case SMESHOp::OpDMWireframe:
1649 anActor->SetRepresentation(SMESH_Actor::eEdge);
1651 case SMESHOp::OpDMShading:
1652 anActor->SetRepresentation(SMESH_Actor::eSurface);
1654 case SMESHOp::OpDMShrink:
1655 if(anActor->IsShrunk())
1656 anActor->UnShrink();
1658 anActor->SetShrink();
1660 case SMESHOp::OpDMNodes:
1661 anActor->SetRepresentation(SMESH_Actor::ePoint);
1663 case SMESHOp::OpRepresentationLines:
1664 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1665 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1667 case SMESHOp::OpRepresentationArcs:
1668 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1669 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1675 SMESH::RepaintCurrentView();
1679 int ActionToControl( int theID, bool theReversed )
1681 NCollection_DoubleMap<int,int> ActionControl;
1682 ActionControl.Bind( 0, SMESH_Actor::eNone );
1683 ActionControl.Bind( SMESHOp::OpFreeNode, SMESH_Actor::eFreeNodes );
1684 ActionControl.Bind( SMESHOp::OpEqualNode, SMESH_Actor::eCoincidentNodes );
1685 ActionControl.Bind( SMESHOp::OpNodeConnectivityNb, SMESH_Actor::eNodeConnectivityNb );
1686 ActionControl.Bind( SMESHOp::OpFreeEdge, SMESH_Actor::eFreeEdges );
1687 ActionControl.Bind( SMESHOp::OpFreeBorder, SMESH_Actor::eFreeBorders );
1688 ActionControl.Bind( SMESHOp::OpLength, SMESH_Actor::eLength );
1689 ActionControl.Bind( SMESHOp::OpConnection, SMESH_Actor::eMultiConnection );
1690 ActionControl.Bind( SMESHOp::OpEqualEdge, SMESH_Actor::eCoincidentElems1D );
1691 ActionControl.Bind( SMESHOp::OpFreeFace, SMESH_Actor::eFreeFaces );
1692 ActionControl.Bind( SMESHOp::OpBareBorderFace, SMESH_Actor::eBareBorderFace );
1693 ActionControl.Bind( SMESHOp::OpOverConstrainedFace, SMESH_Actor::eOverConstrainedFace );
1694 ActionControl.Bind( SMESHOp::OpLength2D, SMESH_Actor::eLength2D );
1695 ActionControl.Bind( SMESHOp::OpDeflection2D, SMESH_Actor::eDeflection2D );
1696 ActionControl.Bind( SMESHOp::OpConnection2D, SMESH_Actor::eMultiConnection2D );
1697 ActionControl.Bind( SMESHOp::OpArea, SMESH_Actor::eArea );
1698 ActionControl.Bind( SMESHOp::OpTaper, SMESH_Actor::eTaper );
1699 ActionControl.Bind( SMESHOp::OpAspectRatio, SMESH_Actor::eAspectRatio );
1700 ActionControl.Bind( SMESHOp::OpMinimumAngle, SMESH_Actor::eMinimumAngle );
1701 ActionControl.Bind( SMESHOp::OpWarpingAngle, SMESH_Actor::eWarping );
1702 ActionControl.Bind( SMESHOp::OpSkew, SMESH_Actor::eSkew );
1703 ActionControl.Bind( SMESHOp::OpMaxElementLength2D, SMESH_Actor::eMaxElementLength2D );
1704 ActionControl.Bind( SMESHOp::OpEqualFace, SMESH_Actor::eCoincidentElems2D );
1705 ActionControl.Bind( SMESHOp::OpAspectRatio3D, SMESH_Actor::eAspectRatio3D );
1706 ActionControl.Bind( SMESHOp::OpVolume, SMESH_Actor::eVolume3D );
1707 ActionControl.Bind( SMESHOp::OpMaxElementLength3D, SMESH_Actor::eMaxElementLength3D );
1708 ActionControl.Bind( SMESHOp::OpBareBorderVolume, SMESH_Actor::eBareBorderVolume );
1709 ActionControl.Bind( SMESHOp::OpOverConstrainedVolume, SMESH_Actor::eOverConstrainedVolume );
1710 ActionControl.Bind( SMESHOp::OpEqualVolume, SMESH_Actor::eCoincidentElems3D );
1713 return ActionControl.IsBound2( theID ) ? ActionControl.Find2( theID ) : 0;
1714 return ActionControl.IsBound1( theID ) ? ActionControl.Find1( theID ) : 0;
1717 void Control( int theCommandID )
1719 SMESH_Actor::eControl aControl = SMESH_Actor::eControl( ActionToControl( theCommandID ));
1720 _PTR(Study) aStudy = SMESH::getStudy();
1722 SALOME_ListIO selected;
1723 if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
1724 aSel->selectedObjects( selected );
1726 if ( !selected.IsEmpty() ) {
1727 SALOME_ListIteratorOfListIO It(selected);
1728 for ( ; It.More(); It.Next())
1730 Handle(SALOME_InteractiveObject) anIO = It.Value();
1731 if ( !anIO.IsNull() ) {
1732 _PTR(SObject) SO = aStudy->FindObjectID( It.Value()->getEntry() );
1734 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
1735 SMESH::SMESH_IDSource_var anIDSrc = SMESH::SMESH_IDSource::_narrow( aObject );
1736 if ( !anIDSrc->_is_nil() ) {
1737 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry());
1738 if (( !anActor && selected.Extent() == 1 ) &&
1739 ( anActor = SMESH::CreateActor( anIO->getEntry() )))
1741 anActor->SetControlMode( aControl );
1742 SMESH::DisplayActor( SMESH::GetCurrentVtkView(), anActor );
1743 SMESH::UpdateView ( SMESH::eDisplay, anIO->getEntry() );
1747 if ( anActor->GetControlMode() != aControl )
1748 anActor->SetControlMode( aControl );
1749 QString functorName = functorToString( anActor->GetFunctor() );
1750 int anEntitiesCount = anActor->GetNumberControlEntities();
1751 if (anEntitiesCount >= 0)
1752 functorName = functorName + ": " + QString::number(anEntitiesCount);
1753 anActor->GetScalarBarActor()->SetTitle( functorName.toLatin1().constData() );
1754 SMESH::RepaintCurrentView();
1755 #ifndef DISABLE_PLOT2DVIEWER
1756 if ( anActor->GetPlot2Histogram() ) {
1757 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1758 QString aHistogramName("%1 : %2");
1759 aHistogramName = aHistogramName.arg( anIO->getName() ).arg( functorName );
1760 aHistogram->setName( aHistogramName );
1761 aHistogram->setHorTitle( functorName );
1762 SMESH::ProcessIn2DViewers( anActor );
1774 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1775 SMESH::MeshObjectType theType,
1776 const QString theInTypeName,
1777 QString & theOutTypeName)
1779 SMESH_TypeFilter aTypeFilter( theType );
1781 if ( !theIO.IsNull() )
1783 entry = theIO->getEntry();
1784 LightApp_DataOwner owner( entry );
1785 if ( aTypeFilter.isOk( &owner )) {
1786 theOutTypeName = theInTypeName;
1794 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1796 _PTR(Study) aStudy = SMESH::getStudy();
1797 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1799 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1800 CORBA::String_var anID = aSComp->GetID().c_str();
1801 if ( !strcmp(anID.in(),theIO->getEntry()) )
1807 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1808 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1809 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1810 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1811 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1819 // QString CheckHomogeneousSelection()
1821 // LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1822 // SALOME_ListIO selected;
1824 // aSel->selectedObjects( selected );
1826 // QString RefType = CheckTypeObject(selected.First());
1827 // SALOME_ListIteratorOfListIO It(selected);
1828 // for ( ; It.More(); It.Next())
1830 // Handle(SALOME_InteractiveObject) IObject = It.Value();
1831 // QString Type = CheckTypeObject(IObject);
1832 // if ( Type.compare(RefType) != 0 )
1833 // return "Heterogeneous Selection";
1839 uint randomize( uint size )
1841 static bool initialized = false;
1842 if ( !initialized ) {
1843 qsrand( QDateTime::currentDateTime().toTime_t() );
1847 v = uint( (double)( v ) / RAND_MAX * size );
1848 v = qMax( uint(0), qMin ( v, size-1 ) );
1854 void SMESHGUI::OnEditDelete()
1856 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1857 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1858 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1860 _PTR(Study) aStudy = SMESH::getStudy();
1861 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1862 _PTR(GenericAttribute) anAttr;
1863 _PTR(AttributeIOR) anIOR;
1865 const int objectCountLimit = 30; // PAL23599
1866 int objectCount = 0;
1868 QString aParentComponent = QString::null;
1870 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1872 Handle(SALOME_InteractiveObject) anIO = anIt.Value();
1873 if ( anIO.IsNull() ) continue;
1875 QString father = "unknown", name;
1877 _PTR(SObject) aSO = aStudy->FindObjectID( anIO->getEntry() );
1879 father = QString::fromStdString( aSO->GetFatherComponent()->ComponentDataType() );
1880 // check if object is reference
1881 _PTR(SObject) aRefSObj;
1882 if ( aSO->ReferencedObject( aRefSObj ) ) {
1883 name = QString::fromStdString ( aRefSObj->GetName() );
1884 father = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1887 name = anIO->getName();
1890 if ( objectCount < objectCountLimit ) { // avoid occupying the whole screen
1891 aNameList.append("\n - ");
1892 aNameList.append( name );
1895 if( aParentComponent.isNull() )
1896 aParentComponent = father;
1897 else if( !aParentComponent.isEmpty() && aParentComponent!=father )
1898 aParentComponent = "";
1900 if ( objectCount >= objectCountLimit )
1901 aNameList.append("\n - ...");
1903 if ( objectCount == 0 )
1904 return; // No Valid Objects Selected
1906 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1907 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1908 QObject::tr("ERR_ERROR"),
1909 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1912 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1913 if (SUIT_MessageBox::warning
1914 (SMESHGUI::desktop(),
1915 QObject::tr("SMESH_WRN_WARNING"),
1916 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1917 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1918 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1921 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1923 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1924 // then treat them all starting from the deepest objects (at list back)
1925 std::list< _PTR(SObject) > listSO;
1926 SALOME_ListIteratorOfListIO It(selected);
1927 for( ; It.More(); It.Next()) // loop on selected IO's
1929 Handle(SALOME_InteractiveObject) IObject = It.Value();
1930 if(IObject->hasEntry()) {
1931 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1933 // disable removal of "SMESH" component object
1934 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1936 if ( engineIOR() == anIOR->Value().c_str() )
1939 //Check the referenced object
1940 _PTR(SObject) aRefSObject;
1941 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1942 aSO = aRefSObject; // Delete main Object instead of reference
1944 listSO.push_back( aSO );
1945 std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
1946 for ( ; itSO != listSO.end(); ++itSO ) {
1947 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1948 for (it->InitEx(false); it->More(); it->Next())
1949 listSO.push_back( it->Value() );
1953 // Check if none of objects to delete is referred from outside
1954 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1955 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1957 _PTR(SObject) SO = *ritSO;
1958 if ( !SO ) continue;
1959 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1960 for (size_t i = 0; i < aReferences.size(); i++) {
1961 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1962 std::string type = aComponent->ComponentDataType();
1963 if ( type != "SMESH" )
1965 SUIT_MessageBox::warning( anApp->desktop(),
1966 QObject::tr("WRN_WARNING"),
1967 QObject::tr("DEP_OBJECT") );
1968 return; // outside SMESH, there is an object depending on a SMESH object
1973 // Call mesh->Clear() to prevent loading mesh from file caused by hypotheses removal
1974 for( It.Initialize( selected ); It.More(); It.Next()) // loop on selected IO's
1976 Handle(SALOME_InteractiveObject) IObject = It.Value();
1977 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface< SMESH::SMESH_Mesh >( IObject );
1978 if ( !mesh->_is_nil() )
1982 // Treat SO's in the list starting from the back
1983 aStudyBuilder->NewCommand(); // There is a transaction
1984 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1986 _PTR(SObject) SO = *ritSO;
1987 if ( !SO ) continue;
1988 std::string anEntry = SO->GetID();
1990 /** Erase graphical object and remove all its data **/
1991 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
1992 SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
1994 /** Remove an object from data structures **/
1995 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1996 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1997 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1998 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1999 aMesh->RemoveGroup( aGroup );
2001 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
2002 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2003 aMesh->RemoveSubMesh( aSubMesh );
2006 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
2007 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
2008 QString objType = CheckTypeObject(IObject);
2009 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
2010 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2011 aStudyBuilder->RemoveObjectWithChildren( SO );
2013 else {// default action: remove SObject from the study
2014 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
2015 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
2017 aStudyBuilder->RemoveObjectWithChildren( SO );
2021 } /* listSO back loop */
2023 aStudyBuilder->CommitCommand();
2025 /* Clear any previous selection */
2027 aSel->setSelectedObjects( l1 );
2029 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
2033 SMESHGUI_EXPORT CAM_Module* createModule()
2035 return new SMESHGUI();
2038 SMESHGUI_EXPORT char* getModuleVersion() {
2039 return (char*)SMESH_VERSION_STR;
2043 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
2045 //=============================================================================
2049 //=============================================================================
2050 SMESHGUI::SMESHGUI() :
2051 SalomeApp_Module( "SMESH" )
2053 if ( CORBA::is_nil( myComponentSMESH ) )
2055 CORBA::Boolean anIsEmbeddedMode;
2056 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
2057 //MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
2059 // 0019923: EDF 765 SMESH : default values of hypothesis
2060 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
2061 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
2062 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
2063 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
2064 myComponentSMESH->SetDefaultNbSegments( nbSeg );
2066 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif", "default_grp_color" };
2067 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
2068 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
2070 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
2071 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
2075 myActiveDialogBox = 0;
2076 myFilterLibraryDlg = 0;
2080 myEventCallbackCommand = vtkCallbackCommand::New();
2081 myEventCallbackCommand->Delete();
2082 myEventCallbackCommand->SetClientData( this );
2083 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
2086 /* load resources for all available meshers */
2087 SMESH::InitAvailableHypotheses();
2090 //=============================================================================
2094 //=============================================================================
2095 SMESHGUI::~SMESHGUI()
2099 //=============================================================================
2103 //=============================================================================
2104 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
2106 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2108 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2113 //=============================================================================
2117 //=============================================================================
2118 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
2120 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2124 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2125 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2126 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2127 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2128 return autoUpdate && !exceeded;
2131 //=============================================================================
2135 //=============================================================================
2136 bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh,
2137 int* entities, bool* limitExceeded, int* hidden, long* nbElements )
2139 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2143 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
2144 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
2145 bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false );
2147 SMESH::long_array_var info = theMesh->GetMeshInfo();
2148 long nbOdElems = info[SMDSEntity_0D];
2149 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
2150 long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] +
2151 info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] +
2152 info[SMDSEntity_Polygon] + info[SMDSEntity_Quad_Polygon];
2153 long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] +
2154 info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] +
2155 info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] +
2156 info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + info[SMDSEntity_BiQuad_Penta] +
2157 info[SMDSEntity_Polyhedra] +
2158 info[SMDSEntity_Hexagonal_Prism];
2159 long nbBalls = info[SMDSEntity_Ball];
2161 long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes;
2162 *nbElements = requestedSize;
2164 *entities = SMESH_Actor::eAllEntity;
2167 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
2169 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
2171 if ( incrementalLimit ) {
2174 if ( nbOdElems > 0 ) {
2175 if ( total + nbOdElems > updateLimit ) {
2176 *entities = *entities & ~SMESH_Actor::e0DElements;
2177 *hidden = *hidden | SMESH_Actor::e0DElements;
2184 if ( nbEdges > 0 ) {
2185 if ( total + nbEdges > updateLimit ) {
2186 *entities = *entities & ~SMESH_Actor::eEdges;
2187 *hidden = *hidden | SMESH_Actor::eEdges;
2194 if ( nbFaces > 0 ) {
2195 if ( total + nbFaces > updateLimit ) {
2196 *entities = *entities & ~SMESH_Actor::eFaces;
2197 *hidden = *hidden | SMESH_Actor::eFaces;
2204 if ( nbVolumes > 0 ) {
2205 if ( total + nbVolumes > updateLimit ) {
2206 *entities = *entities & ~SMESH_Actor::eVolumes;
2207 *hidden = *hidden | SMESH_Actor::eVolumes;
2214 if ( nbBalls > 0 ) {
2215 if ( total + nbBalls > updateLimit ) {
2216 *entities = *entities & ~SMESH_Actor::eBallElem;
2217 *hidden = *hidden | SMESH_Actor::eBallElem;
2225 return autoUpdate && !exceeded;
2228 //=============================================================================
2232 //=============================================================================
2233 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
2235 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
2238 //=============================================================================
2242 //=============================================================================
2243 SMESHGUI* SMESHGUI::GetSMESHGUI()
2245 SMESHGUI* smeshMod = 0;
2246 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
2249 CAM_Module* module = app->module( "Mesh" );
2250 smeshMod = dynamic_cast<SMESHGUI*>( module );
2258 Standard_EXPORT SMESHGUI* GetComponentGUI()
2260 return SMESHGUI::GetSMESHGUI();
2264 //=============================================================================
2268 //=============================================================================
2269 void SMESHGUI::SetState(int aState)
2274 //=============================================================================
2278 //=============================================================================
2279 void SMESHGUI::ResetState()
2284 //=============================================================================
2288 //=============================================================================
2289 void SMESHGUI::EmitSignalDeactivateDialog()
2291 emit SignalDeactivateActiveDialog();
2294 //=============================================================================
2298 //=============================================================================
2299 void SMESHGUI::EmitSignalStudyFrameChanged()
2301 emit SignalStudyFrameChanged();
2304 //=============================================================================
2308 //=============================================================================
2309 void SMESHGUI::EmitSignalCloseAllDialogs()
2311 emit SignalCloseAllDialogs();
2314 //=============================================================================
2318 //=============================================================================
2319 void SMESHGUI::EmitSignalVisibilityChanged()
2321 emit SignalVisibilityChanged();
2324 //=============================================================================
2328 //=============================================================================
2329 void SMESHGUI::EmitSignalCloseView()
2331 emit SignalCloseView();
2334 //=============================================================================
2338 //=============================================================================
2339 void SMESHGUI::EmitSignalActivatedViewManager()
2341 emit SignalActivatedViewManager();
2344 //=============================================================================
2348 //=============================================================================
2349 QDialog *SMESHGUI::GetActiveDialogBox()
2351 return myActiveDialogBox;
2354 //=============================================================================
2358 //=============================================================================
2359 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2361 myActiveDialogBox = (QDialog *) aDlg;
2365 //=============================================================================
2369 //=============================================================================
2370 SUIT_Desktop* SMESHGUI::desktop()
2372 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2374 return app->desktop();
2379 //=============================================================================
2383 //=============================================================================
2384 SalomeApp_Study* SMESHGUI::activeStudy()
2386 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2388 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2393 //=============================================================================
2397 //=============================================================================
2398 void SMESHGUI::Modified( bool theIsUpdateActions )
2400 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2401 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2402 appStudy->Modified();
2403 if( theIsUpdateActions )
2404 app->updateActions();
2409 //=============================================================================
2413 //=============================================================================
2414 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2416 /* Here the position is on the bottom right corner - 10 */
2417 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2419 SUIT_Desktop *PP = desktop();
2420 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2421 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2426 * \brief Verifies whether study of operation is locked
2427 * \param theMess - specifies whether message box must be shown if study is locked
2428 * \return State of study.
2430 * Verifies whether study of operation is locked. If second parameter is TRUE and study
2431 * is locked when corresponding message box appears
2433 bool SMESHGUI::isStudyLocked( bool theMessage )
2435 if ( SMESH::getStudy()->GetProperties()->IsLocked() )
2438 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2439 QObject::tr( "WRN_WARNING" ),
2440 QObject::tr( "WRN_STUDY_LOCKED" ) );
2446 //=============================================================================
2450 //=============================================================================
2451 bool SMESHGUI::OnGUIEvent( int theCommandID )
2453 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2457 SUIT_ResourceMgr* mgr = resourceMgr();
2461 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2462 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2464 //QAction* act = action( theCommandID );
2466 switch (theCommandID) {
2467 case SMESHOp::OpDelete:
2468 if(isStudyLocked()) break;
2471 case SMESHOp::OpImportDAT:
2472 case SMESHOp::OpImportUNV:
2473 case SMESHOp::OpImportMED:
2474 case SMESHOp::OpImportSTL:
2475 case SMESHOp::OpImportCGNS:
2476 case SMESHOp::OpImportSAUV:
2477 case SMESHOp::OpImportGMF:
2478 case SMESHOp::OpPopupImportDAT:
2479 case SMESHOp::OpPopupImportUNV:
2480 case SMESHOp::OpPopupImportMED:
2481 case SMESHOp::OpPopupImportSTL:
2482 case SMESHOp::OpPopupImportCGNS:
2483 case SMESHOp::OpPopupImportSAUV:
2484 case SMESHOp::OpPopupImportGMF:
2486 if(isStudyLocked()) break;
2487 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2491 case SMESHOp::OpFileInformation:
2493 SALOME_ListIO selected;
2494 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2496 aSel->selectedObjects( selected );
2497 if( selected.Extent() )
2499 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2500 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2501 if ( !aMesh->_is_nil() )
2503 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2509 case SMESHOp::OpExportDAT:
2510 case SMESHOp::OpExportMED:
2511 case SMESHOp::OpExportUNV:
2512 case SMESHOp::OpExportSTL:
2513 case SMESHOp::OpExportCGNS:
2514 case SMESHOp::OpExportSAUV:
2515 case SMESHOp::OpExportGMF:
2516 case SMESHOp::OpPopupExportDAT:
2517 case SMESHOp::OpPopupExportMED:
2518 case SMESHOp::OpPopupExportUNV:
2519 case SMESHOp::OpPopupExportSTL:
2520 case SMESHOp::OpPopupExportCGNS:
2521 case SMESHOp::OpPopupExportSAUV:
2522 case SMESHOp::OpPopupExportGMF:
2524 ::ExportMeshToFile(theCommandID);
2528 case SMESHOp::OpReset: // SCALAR BAR
2530 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2531 SALOME_ListIO selected;
2533 aSel->selectedObjects( selected );
2535 SALOME_ListIteratorOfListIO it(selected);
2536 for( ; it.More(); it.Next()) {
2537 Handle(SALOME_InteractiveObject) anIO = it.Value();
2538 if( anIO->hasEntry() ) {
2539 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2540 anActor->SetControlMode( SMESH_Actor::eNone );
2541 #ifndef DISABLE_PLOT2DVIEWER
2542 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2544 anActor->UpdateFilter();
2548 SMESH::UpdateView();
2551 case SMESHOp::OpScalarBarProperties:
2553 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2556 case SMESHOp::OpShowScalarBar:
2558 // show/hide scalar bar
2559 ::ShowElement(theCommandID);
2562 case SMESHOp::OpSaveDistribution:
2564 // dump control distribution data to the text file
2565 ::SaveDistribution();
2569 case SMESHOp::OpShowDistribution:
2571 // show/hide distribution
2572 ::ShowElement(theCommandID);
2576 #ifndef DISABLE_PLOT2DVIEWER
2577 case SMESHOp::OpPlotDistribution:
2579 // plot distribution
2580 ::PlotDistribution();
2586 case SMESHOp::OpAutoColor:
2590 case SMESHOp::OpDisableAutoColor:
2591 ::DisableAutoColor();
2594 case SMESHOp::OpClipping:
2595 case SMESHOp::OpTransparency:
2596 case SMESHOp::OpProperties: // Display preferences (colors, shrink size, line width, ...)
2599 case SMESHOp::OpDMWireframe:
2600 case SMESHOp::OpDMShading:
2601 case SMESHOp::OpDMNodes:
2602 case SMESHOp::OpDMShrink:
2603 ::SetDisplayMode(theCommandID, myMarkerMap);
2606 //2D quadratic representation
2607 case SMESHOp::OpRepresentationLines:
2608 case SMESHOp::OpRepresentationArcs:
2609 ::SetDisplayMode(theCommandID, myMarkerMap);
2613 case SMESHOp::OpDE0DElements:
2614 case SMESHOp::OpDEEdges:
2615 case SMESHOp::OpDEFaces:
2616 case SMESHOp::OpDEVolumes:
2617 case SMESHOp::OpDEBalls:
2618 case SMESHOp::OpDEAllEntity:
2619 ::SetDisplayEntity(theCommandID);
2622 // Choose entities to be displayed
2623 case SMESHOp::OpDEChoose:
2625 ( new SMESHGUI_DisplayEntitiesDlg( SMESHGUI::desktop() ) )->exec();
2629 case SMESHOp::OpOrientationOnFaces:
2631 SUIT_OverrideCursor wc;
2632 LightApp_SelectionMgr* mgr = selectionMgr();
2633 SALOME_ListIO selected; mgr->selectedObjects( selected );
2635 SALOME_ListIteratorOfListIO it(selected);
2636 for( ; it.More(); it.Next()) {
2637 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2638 if(anIObject->hasEntry()) {
2639 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2640 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2647 case SMESHOp::OpUpdate:
2649 if(isStudyLocked()) break;
2650 SUIT_OverrideCursor wc;
2653 SMESH::UpdateView();
2655 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2656 SMESH::OnVisuException();
2658 catch (...) { // PAL16774 (Crash after display of many groups)
2659 SMESH::OnVisuException();
2663 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2664 aSel->selectedObjects( l );
2665 aSel->setSelectedObjects( l );
2669 case SMESHOp::OpHide:
2670 case SMESHOp::OpShow:
2671 case SMESHOp::OpShowOnly:
2673 SUIT_OverrideCursor wc;
2674 SMESH::EDisplaing anAction;
2675 switch (theCommandID) {
2676 case SMESHOp::OpHide: anAction = SMESH::eErase; break;
2677 case SMESHOp::OpShow: anAction = SMESH::eDisplay; break;
2678 case SMESHOp::OpShowOnly: anAction = SMESH::eDisplayOnly; break;
2681 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2682 SALOME_ListIO sel_objects, to_process;
2684 aSel->selectedObjects( sel_objects );
2686 if ( theCommandID==SMESHOp::OpShowOnly )
2688 //MESSAGE("anAction = SMESH::eDisplayOnly");
2689 startOperation( myEraseAll );
2692 extractContainers( sel_objects, to_process );
2697 SALOME_ListIteratorOfListIO It( to_process );
2698 for ( ; It.More(); It.Next())
2700 Handle(SALOME_InteractiveObject) IOS = It.Value();
2701 if ( IOS->hasEntry() )
2703 if ( !SMESH::UpdateView( anAction, IOS->getEntry() )) {
2704 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2705 break; // PAL16774 (Crash after display of many groups)
2707 if (anAction == SMESH::eDisplayOnly)
2708 anAction = SMESH::eDisplay;
2713 // PAL13338 + PAL15161 -->
2714 if ( ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) && !isStudyLocked()) {
2715 SMESH::UpdateView();
2716 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2718 // PAL13338 + PAL15161 <--
2720 catch (...) { // PAL16774 (Crash after display of many groups)
2721 SMESH::OnVisuException();
2724 if (anAction == SMESH::eErase) {
2726 aSel->setSelectedObjects( l1 );
2729 aSel->setSelectedObjects( to_process );
2731 if ( vtkwnd && vtkwnd->GetRenderer() && !isStudyLocked() &&
2732 ( theCommandID==SMESHOp::OpShow || theCommandID==SMESHOp::OpShowOnly ) )
2733 vtkwnd->GetRenderer()->AdjustActors();
2738 case SMESHOp::OpNode:
2740 if(isStudyLocked()) break;
2743 EmitSignalDeactivateDialog();
2745 ( new SMESHGUI_NodesDlg( this ) )->show();
2748 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"),tr("SMESH_WRN_VIEWER_VTK"));
2753 case SMESHOp::OpCreateMesh:
2754 case SMESHOp::OpCreateSubMesh:
2755 case SMESHOp::OpEditMeshOrSubMesh:
2756 case SMESHOp::OpEditMesh:
2757 case SMESHOp::OpEditSubMesh:
2758 case SMESHOp::OpCompute:
2759 case SMESHOp::OpComputeSubMesh:
2760 case SMESHOp::OpPreCompute:
2761 case SMESHOp::OpEvaluate:
2762 case SMESHOp::OpMeshOrder:
2763 startOperation( theCommandID );
2765 case SMESHOp::OpCopyMesh:
2767 if (isStudyLocked()) break;
2768 EmitSignalDeactivateDialog();
2769 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2772 case SMESHOp::OpBuildCompoundMesh:
2774 if (isStudyLocked()) break;
2775 EmitSignalDeactivateDialog();
2776 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2780 case SMESHOp::OpDiagonalInversion:
2781 case SMESHOp::OpUnionOfTwoTriangle:
2785 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2789 if ( isStudyLocked() )
2792 /*Standard_Boolean aRes;
2793 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2794 if ( aMesh->_is_nil() )
2796 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2797 tr( "SMESH_BAD_SELECTION" ) );
2801 EmitSignalDeactivateDialog();
2802 if ( theCommandID == SMESHOp::OpDiagonalInversion )
2803 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2805 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2808 case SMESHOp::OpOrientation:
2809 case SMESHOp::OpUnionOfTriangles:
2810 case SMESHOp::OpCuttingOfQuadrangles:
2811 case SMESHOp::OpSplitVolumes:
2815 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ) );
2819 if ( isStudyLocked() )
2822 EmitSignalDeactivateDialog();
2823 SMESHGUI_MultiEditDlg* aDlg = NULL;
2824 if ( theCommandID == SMESHOp::OpOrientation )
2825 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2826 else if ( theCommandID == SMESHOp::OpUnionOfTriangles )
2827 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2828 else if ( theCommandID == SMESHOp::OpSplitVolumes )
2829 aDlg = new SMESHGUI_SplitVolumesDlg(this);
2831 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2836 case SMESHOp::OpSmoothing:
2838 if(isStudyLocked()) break;
2840 EmitSignalDeactivateDialog();
2841 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2844 SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2848 case SMESHOp::OpExtrusion:
2850 if (isStudyLocked()) break;
2852 EmitSignalDeactivateDialog();
2853 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2855 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2859 case SMESHOp::OpExtrusionAlongAPath:
2861 if (isStudyLocked()) break;
2863 EmitSignalDeactivateDialog();
2864 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2866 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2870 case SMESHOp::OpRevolution:
2872 if(isStudyLocked()) break;
2874 EmitSignalDeactivateDialog();
2875 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2878 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2882 case SMESHOp::OpPatternMapping:
2884 if ( isStudyLocked() )
2888 EmitSignalDeactivateDialog();
2889 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2892 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2896 case SMESHOp::OpSplitBiQuadratic:
2897 case SMESHOp::OpConvertMeshToQuadratic:
2898 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh from 3D
2899 case SMESHOp::OpReorientFaces:
2900 case SMESHOp::OpCreateGeometryGroup:
2902 startOperation( theCommandID );
2905 case SMESHOp::OpCreateGroup:
2909 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2913 if(isStudyLocked()) break;
2914 EmitSignalDeactivateDialog();
2915 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2917 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2918 SALOME_ListIO selected;
2920 aSel->selectedObjects( selected );
2922 int nbSel = selected.Extent();
2924 // check if mesh is selected
2925 aMesh = SMESH::GetMeshByIO( selected.First() );
2927 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2932 case SMESHOp::OpConstructGroup:
2936 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
2940 if(isStudyLocked()) break;
2941 EmitSignalDeactivateDialog();
2943 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2944 SALOME_ListIO selected;
2946 aSel->selectedObjects( selected );
2948 int nbSel = selected.Extent();
2950 // check if submesh is selected
2951 Handle(SALOME_InteractiveObject) IObject = selected.First();
2952 if (IObject->hasEntry()) {
2953 _PTR(SObject) aSObj = SMESH::getStudy()->FindObjectID(IObject->getEntry());
2955 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2956 if (!aSubMesh->_is_nil()) {
2958 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2959 // get submesh elements list by types
2960 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2961 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2962 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2963 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2964 // create group for each type o elements
2965 QString aName = IObject->getName();
2966 QStringList anEntryList;
2967 if (aNodes->length() > 0) {
2968 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2969 aGroup->Add(aNodes.inout());
2970 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2971 anEntryList.append( aSObject->GetID().c_str() );
2973 if (aEdges->length() > 0) {
2974 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2975 aGroup->Add(aEdges.inout());
2976 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2977 anEntryList.append( aSObject->GetID().c_str() );
2979 if (aFaces->length() > 0) {
2980 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2981 aGroup->Add(aFaces.inout());
2982 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2983 anEntryList.append( aSObject->GetID().c_str() );
2985 if (aVolumes->length() > 0) {
2986 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2987 aGroup->Add(aVolumes.inout());
2988 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2989 anEntryList.append( aSObject->GetID().c_str() );
2992 anApp->browseObjects( anEntryList );
2994 catch(const SALOME::SALOME_Exception & S_ex){
2995 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3002 SUIT_MessageBox::warning(desktop(),
3003 tr("SMESH_WRN_WARNING"),
3004 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
3009 case SMESHOp::OpEditGroup:
3013 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3017 if(isStudyLocked()) break;
3018 EmitSignalDeactivateDialog();
3020 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3021 SALOME_ListIO selected;
3023 aSel->selectedObjects( selected );
3025 SALOME_ListIteratorOfListIO It (selected);
3026 int nbSelectedGroups = 0;
3027 for ( ; It.More(); It.Next() )
3029 SMESH::SMESH_GroupBase_var aGroup =
3030 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
3031 if (!aGroup->_is_nil()) {
3033 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
3037 if (nbSelectedGroups == 0)
3039 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
3045 case SMESHOp::OpAddElemGroupPopup: // Add elements to group
3047 if(isStudyLocked()) break;
3048 if (myState == 800) {
3049 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3050 if (aDlg) aDlg->onAdd();
3055 case SMESHOp::OpRemoveElemGroupPopup: // Remove elements from group
3057 if(isStudyLocked()) break;
3058 if (myState == 800) {
3059 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
3060 if (aDlg) aDlg->onRemove();
3065 case SMESHOp::OpEditGeomGroupAsGroup:
3069 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3073 if(isStudyLocked()) break;
3074 EmitSignalDeactivateDialog();
3076 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3077 SALOME_ListIO selected;
3079 aSel->selectedObjects( selected );
3081 SALOME_ListIteratorOfListIO It (selected);
3082 for ( ; It.More(); It.Next() )
3084 SMESH::SMESH_GroupOnGeom_var aGroup =
3085 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
3086 if (!aGroup->_is_nil()) {
3087 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3092 SMESH::SMESH_GroupOnFilter_var aGroup =
3093 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
3094 if (!aGroup->_is_nil()) {
3095 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
3103 case SMESHOp::OpUnionGroups:
3104 case SMESHOp::OpIntersectGroups:
3105 case SMESHOp::OpCutGroups:
3109 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3113 if ( isStudyLocked() )
3116 EmitSignalDeactivateDialog();
3118 SMESHGUI_GroupOpDlg* aDlg = 0;
3119 if ( theCommandID == SMESHOp::OpUnionGroups )
3120 aDlg = new SMESHGUI_UnionGroupsDlg( this );
3121 else if ( theCommandID == SMESHOp::OpIntersectGroups )
3122 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
3124 aDlg = new SMESHGUI_CutGroupsDlg( this );
3131 case SMESHOp::OpGroupUnderlyingElem: // Create groups of entities from existing groups of superior dimensions
3133 if ( isStudyLocked() )
3136 EmitSignalDeactivateDialog();
3137 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
3143 case SMESHOp::OpFaceGroupsByEdges: // Create face groups separated by sharp edges
3145 if ( isStudyLocked() )
3148 EmitSignalDeactivateDialog();
3149 SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
3155 case SMESHOp::OpDeleteGroup: // Delete groups with their contents
3159 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),tr( "NOT_A_VTK_VIEWER" ) );
3163 if ( isStudyLocked() )
3166 EmitSignalDeactivateDialog();
3168 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
3172 case SMESHOp::OpMeshInformation:
3173 case SMESHOp::OpWhatIs:
3175 int page = theCommandID == SMESHOp::OpMeshInformation ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
3176 EmitSignalDeactivateDialog();
3177 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3178 SALOME_ListIO selected;
3180 aSel->selectedObjects( selected );
3182 if ( selected.Extent() > 1 ) { // a dlg for each IO
3183 SALOME_ListIteratorOfListIO It( selected );
3184 for ( ; It.More(); It.Next() ) {
3185 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3186 dlg->showInfo( It.Value() );
3191 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
3197 case SMESHOp::OpFindElementByPoint:
3199 startOperation( theCommandID );
3203 case SMESHOp::OpEditHypothesis:
3205 if(isStudyLocked()) break;
3207 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3208 SALOME_ListIO selected;
3210 aSel->selectedObjects( selected );
3212 int nbSel = selected.Extent();
3215 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3216 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
3218 if ( !aHypothesis->_is_nil() )
3220 SMESHGUI_GenericHypothesisCreator* aCreator =
3221 SMESH::GetHypothesisCreator( SMESH::toQStr( aHypothesis->GetName() ));
3224 // set geometry of mesh and sub-mesh to aCreator
3225 aSel->selectedObjects( selected, "", /*convertReferences=*/false);
3226 if ( selected.Extent() == 1 )
3228 QString subGeomID, meshGeomID;
3229 Handle(SALOME_InteractiveObject) hypIO = selected.First();
3230 if ( SMESH::GetGeomEntries( hypIO, subGeomID, meshGeomID ))
3232 if ( subGeomID.isEmpty() ) subGeomID = meshGeomID;
3233 aCreator->setShapeEntry( subGeomID );
3234 aCreator->setMainShapeEntry( meshGeomID );
3238 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
3248 case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
3250 if(isStudyLocked()) break;
3251 SUIT_OverrideCursor wc;
3253 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
3254 SALOME_ListIO selected;
3256 aSel->selectedObjects( selected, QString::null, false );
3258 SALOME_ListIteratorOfListIO It(selected);
3259 for (int i = 0; It.More(); It.Next(), i++) {
3260 Handle(SALOME_InteractiveObject) IObject = It.Value();
3261 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
3264 aSel->setSelectedObjects( l1 );
3269 case SMESHOp::OpElem0D:
3270 case SMESHOp::OpBall:
3271 case SMESHOp::OpEdge:
3272 case SMESHOp::OpTriangle:
3273 case SMESHOp::OpQuadrangle:
3274 case SMESHOp::OpPolygon:
3275 case SMESHOp::OpTetrahedron:
3276 case SMESHOp::OpHexahedron:
3277 case SMESHOp::OpPentahedron:
3278 case SMESHOp::OpPyramid:
3279 case SMESHOp::OpHexagonalPrism:
3281 if(isStudyLocked()) break;
3283 EmitSignalDeactivateDialog();
3284 SMDSAbs_EntityType type = SMDSEntity_Edge;
3285 switch (theCommandID) {
3286 case SMESHOp::OpElem0D: type = SMDSEntity_0D; break;
3287 case SMESHOp::OpBall: type = SMDSEntity_Ball; break;
3288 case SMESHOp::OpTriangle: type = SMDSEntity_Triangle; break;
3289 case SMESHOp::OpQuadrangle: type = SMDSEntity_Quadrangle; break;
3290 case SMESHOp::OpTetrahedron: type = SMDSEntity_Tetra; break;
3291 case SMESHOp::OpPolygon: type = SMDSEntity_Polygon; break;
3292 case SMESHOp::OpHexahedron: type = SMDSEntity_Hexa; break;
3293 case SMESHOp::OpPentahedron: type = SMDSEntity_Penta; break;
3294 case SMESHOp::OpPyramid: type = SMDSEntity_Pyramid; break;
3295 case SMESHOp::OpHexagonalPrism: type = SMDSEntity_Hexagonal_Prism; break;
3298 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
3301 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3305 case SMESHOp::OpPolyhedron:
3307 if(isStudyLocked()) break;
3309 EmitSignalDeactivateDialog();
3310 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3313 SUIT_MessageBox::warning(desktop(),tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3317 case SMESHOp::OpQuadraticEdge:
3318 case SMESHOp::OpQuadraticTriangle:
3319 case SMESHOp::OpBiQuadraticTriangle:
3320 case SMESHOp::OpQuadraticQuadrangle:
3321 case SMESHOp::OpBiQuadraticQuadrangle:
3322 case SMESHOp::OpQuadraticPolygon:
3323 case SMESHOp::OpQuadraticTetrahedron:
3324 case SMESHOp::OpQuadraticPyramid:
3325 case SMESHOp::OpQuadraticPentahedron:
3326 case SMESHOp::OpBiQuadraticPentahedron:
3327 case SMESHOp::OpQuadraticHexahedron:
3328 case SMESHOp::OpTriQuadraticHexahedron:
3330 if(isStudyLocked()) break;
3332 EmitSignalDeactivateDialog();
3333 SMDSAbs_EntityType type = SMDSEntity_Last;
3335 switch (theCommandID) {
3336 case SMESHOp::OpQuadraticEdge: type = SMDSEntity_Quad_Edge; break;
3337 case SMESHOp::OpQuadraticTriangle: type = SMDSEntity_Quad_Triangle; break;
3338 case SMESHOp::OpBiQuadraticTriangle: type = SMDSEntity_BiQuad_Triangle; break;
3339 case SMESHOp::OpQuadraticQuadrangle: type = SMDSEntity_Quad_Quadrangle; break;
3340 case SMESHOp::OpBiQuadraticQuadrangle: type = SMDSEntity_BiQuad_Quadrangle; break;
3341 case SMESHOp::OpQuadraticPolygon: type = SMDSEntity_Quad_Polygon; break;
3342 case SMESHOp::OpQuadraticTetrahedron: type = SMDSEntity_Quad_Tetra; break;
3343 case SMESHOp::OpQuadraticPyramid: type = SMDSEntity_Quad_Pyramid; break;
3344 case SMESHOp::OpQuadraticPentahedron: type = SMDSEntity_Quad_Penta; break;
3345 case SMESHOp::OpBiQuadraticPentahedron: type = SMDSEntity_BiQuad_Penta; break;
3346 case SMESHOp::OpQuadraticHexahedron: type = SMDSEntity_Quad_Hexa; break;
3347 case SMESHOp::OpTriQuadraticHexahedron: type = SMDSEntity_TriQuad_Hexa; break;
3350 if ( type != SMDSEntity_Last )
3351 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3354 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3355 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3359 case SMESHOp::OpRemoveNodes:
3361 if(isStudyLocked()) break;
3363 EmitSignalDeactivateDialog();
3364 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3367 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3368 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3372 case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
3374 if(isStudyLocked()) break;
3376 EmitSignalDeactivateDialog();
3377 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3381 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3382 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3386 case SMESHOp::OpClearMesh: {
3388 if(isStudyLocked()) break;
3390 SALOME_ListIO selected;
3391 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3392 aSel->selectedObjects( selected );
3394 SUIT_OverrideCursor wc;
3395 SALOME_ListIteratorOfListIO It (selected);
3396 for ( ; It.More(); It.Next() )
3398 Handle(SALOME_InteractiveObject) IOS = It.Value();
3399 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3400 if ( aMesh->_is_nil()) continue;
3403 if ( aMesh->NbNodes() == 0 ) // imported mesh is not empty
3404 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3405 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3406 // hide groups and submeshes
3407 _PTR(ChildIterator) anIter =
3408 SMESH::getStudy()->NewChildIterator( aMeshSObj );
3409 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3411 _PTR(SObject) so = anIter->Value();
3412 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3415 catch (const SALOME::SALOME_Exception& S_ex){
3417 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3421 SMESH::UpdateView();
3425 case SMESHOp::OpRemoveOrphanNodes:
3427 if(isStudyLocked()) break;
3428 SALOME_ListIO selected;
3429 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3430 aSel->selectedObjects( selected );
3431 if ( selected.Extent() == 1 ) {
3432 Handle(SALOME_InteractiveObject) anIO = selected.First();
3433 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3434 if ( !aMesh->_is_nil() ) {
3435 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3436 tr( "SMESH_WARNING" ),
3437 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3438 SUIT_MessageBox::Yes |
3439 SUIT_MessageBox::No,
3440 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3443 SUIT_OverrideCursor wc;
3444 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3445 int removed = aMeshEditor->RemoveOrphanNodes();
3446 SUIT_MessageBox::information(SMESHGUI::desktop(),
3447 tr("SMESH_INFORMATION"),
3448 tr("NB_NODES_REMOVED").arg(removed));
3449 if ( removed > 0 ) {
3450 SMESH::UpdateView();
3451 SMESHGUI::Modified();
3454 catch (const SALOME::SALOME_Exception& S_ex) {
3455 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3464 case SMESHOp::OpRenumberingNodes:
3466 if(isStudyLocked()) break;
3468 EmitSignalDeactivateDialog();
3469 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3473 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3474 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3478 case SMESHOp::OpRenumberingElements:
3480 if(isStudyLocked()) break;
3482 EmitSignalDeactivateDialog();
3483 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3487 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3488 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3492 case SMESHOp::OpTranslation:
3494 if(isStudyLocked()) break;
3496 EmitSignalDeactivateDialog();
3497 ( new SMESHGUI_TranslationDlg( this ) )->show();
3500 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3501 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3505 case SMESHOp::OpRotation:
3507 if(isStudyLocked()) break;
3509 EmitSignalDeactivateDialog();
3510 ( new SMESHGUI_RotationDlg( this ) )->show();
3513 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3514 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3518 case SMESHOp::OpSymmetry:
3520 if(isStudyLocked()) break;
3522 EmitSignalDeactivateDialog();
3523 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3526 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3527 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3531 case SMESHOp::OpScale:
3533 if(isStudyLocked()) break;
3535 EmitSignalDeactivateDialog();
3536 ( new SMESHGUI_ScaleDlg( this ) )->show();
3539 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3540 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3545 case SMESHOp::OpOffset:
3547 if(isStudyLocked()) break;
3549 EmitSignalDeactivateDialog();
3550 ( new SMESHGUI_OffsetDlg( this ) )->show();
3553 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3554 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3559 case SMESHOp::OpSewing:
3561 if(isStudyLocked()) break;
3563 EmitSignalDeactivateDialog();
3564 ( new SMESHGUI_SewingDlg( this ) )->show();
3567 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3568 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3572 case SMESHOp::OpMergeNodes:
3574 if(isStudyLocked()) break;
3576 EmitSignalDeactivateDialog();
3577 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3580 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3581 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3585 case SMESHOp::OpMergeElements:
3587 if (isStudyLocked()) break;
3589 EmitSignalDeactivateDialog();
3590 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3592 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3593 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3598 case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
3599 startOperation( SMESHOp::OpMoveNode );
3602 case SMESHOp::OpDuplicateNodes:
3604 if(isStudyLocked()) break;
3606 EmitSignalDeactivateDialog();
3607 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3610 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3611 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3616 case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
3617 startOperation( SMESHOp::OpElem0DOnElemNodes );
3620 case SMESHOp::OpSelectFiltersLibrary: // Library of selection filters
3622 static QList<int> aTypes;
3623 if ( aTypes.isEmpty() )
3625 aTypes.append( SMESH::NODE );
3626 aTypes.append( SMESH::EDGE );
3627 aTypes.append( SMESH::FACE );
3628 aTypes.append( SMESH::VOLUME );
3630 if (!myFilterLibraryDlg)
3631 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3632 else if (myFilterLibraryDlg->isHidden())
3633 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3634 myFilterLibraryDlg->raise();
3638 case SMESHOp::OpFreeNode:
3639 case SMESHOp::OpEqualNode:
3640 case SMESHOp::OpNodeConnectivityNb:
3641 case SMESHOp::OpFreeEdge:
3642 case SMESHOp::OpFreeBorder:
3643 case SMESHOp::OpLength:
3644 case SMESHOp::OpConnection:
3645 case SMESHOp::OpEqualEdge:
3646 case SMESHOp::OpFreeFace:
3647 case SMESHOp::OpBareBorderFace:
3648 case SMESHOp::OpOverConstrainedFace:
3649 case SMESHOp::OpLength2D:
3650 case SMESHOp::OpDeflection2D:
3651 case SMESHOp::OpConnection2D:
3652 case SMESHOp::OpArea:
3653 case SMESHOp::OpTaper:
3654 case SMESHOp::OpAspectRatio:
3655 case SMESHOp::OpMinimumAngle:
3656 case SMESHOp::OpWarpingAngle:
3657 case SMESHOp::OpSkew:
3658 case SMESHOp::OpMaxElementLength2D:
3659 case SMESHOp::OpEqualFace:
3660 case SMESHOp::OpAspectRatio3D:
3661 case SMESHOp::OpVolume:
3662 case SMESHOp::OpMaxElementLength3D:
3663 case SMESHOp::OpBareBorderVolume:
3664 case SMESHOp::OpOverConstrainedVolume:
3665 case SMESHOp::OpEqualVolume:
3668 LightApp_SelectionMgr* mgr = selectionMgr();
3669 SALOME_ListIO selected; mgr->selectedObjects( selected );
3671 if( !selected.IsEmpty() ) {
3672 SUIT_OverrideCursor wc;
3673 ::Control( theCommandID );
3676 SUIT_MessageBox::warning(desktop(),
3677 tr( "SMESH_WRN_WARNING" ),
3678 tr( "SMESH_BAD_SELECTION" ) );
3682 SUIT_MessageBox::warning(desktop(),
3683 tr( "SMESH_WRN_WARNING" ),
3684 tr( "NOT_A_VTK_VIEWER" ) );
3687 case SMESHOp::OpOverallMeshQuality:
3688 OverallMeshQuality();
3690 case SMESHOp::OpNumberingNodes:
3692 SUIT_OverrideCursor wc;
3693 LightApp_SelectionMgr* mgr = selectionMgr();
3694 SALOME_ListIO selected; mgr->selectedObjects( selected );
3696 SALOME_ListIteratorOfListIO it(selected);
3697 for( ; it.More(); it.Next()) {
3698 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3699 if(anIObject->hasEntry()) {
3700 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3701 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3707 case SMESHOp::OpNumberingElements:
3709 SUIT_OverrideCursor wc;
3710 LightApp_SelectionMgr* mgr = selectionMgr();
3711 SALOME_ListIO selected; mgr->selectedObjects( selected );
3713 SALOME_ListIteratorOfListIO it(selected);
3714 for( ; it.More(); it.Next()) {
3715 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3716 if(anIObject->hasEntry())
3717 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3718 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3723 case SMESHOp::OpPropertiesLength:
3724 case SMESHOp::OpPropertiesArea:
3725 case SMESHOp::OpPropertiesVolume:
3726 case SMESHOp::OpMinimumDistance:
3727 case SMESHOp::OpBoundingBox:
3728 case SMESHOp::OpAngle:
3730 int page = SMESHGUI_MeasureDlg::MinDistance;
3731 if ( theCommandID == SMESHOp::OpBoundingBox )
3732 page = SMESHGUI_MeasureDlg::BoundingBox;
3733 else if ( theCommandID == SMESHOp::OpPropertiesLength )
3734 page = SMESHGUI_MeasureDlg::Length;
3735 else if ( theCommandID == SMESHOp::OpPropertiesArea )
3736 page = SMESHGUI_MeasureDlg::Area;
3737 else if ( theCommandID == SMESHOp::OpPropertiesVolume )
3738 page = SMESHGUI_MeasureDlg::Volume;
3739 else if ( theCommandID == SMESHOp::OpAngle )
3740 page = SMESHGUI_MeasureDlg::Angle;
3742 EmitSignalDeactivateDialog();
3743 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3747 case SMESHOp::OpSortChild:
3753 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3754 //updateObjBrowser();
3758 //=============================================================================
3762 //=============================================================================
3763 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3768 //=============================================================================
3772 //=============================================================================
3773 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3778 //=============================================================================
3782 //=============================================================================
3783 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3788 //=============================================================================
3789 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3790 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3792 //=============================================================================
3793 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3794 SUIT_ViewWindow* wnd )
3796 if(theIO->hasEntry()){
3797 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3798 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3802 //=======================================================================
3803 // function : createSMESHAction
3805 //=======================================================================
3806 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3807 const int key, const bool toggle, const QString& shortcutAction )
3810 QWidget* parent = application()->desktop();
3811 SUIT_ResourceMgr* resMgr = resourceMgr();
3813 if ( !icon_id.isEmpty() )
3814 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3816 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3817 if ( !pix.isNull() )
3818 icon = QIcon( pix );
3820 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3821 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3822 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3824 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3825 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3828 //=======================================================================
3829 // function : createPopupItem
3831 //=======================================================================
3832 void SMESHGUI::createPopupItem( const int id,
3833 const QString& clients,
3834 const QString& types,
3835 const QString& theRule,
3838 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3839 popupMgr()->insert( action( id ), pId, 0 );
3841 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3842 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3843 QString rule = "(%1) and (%2) and (%3)";
3844 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3845 if( clients.isEmpty() )
3846 rule = rule.arg( QString( "true" ) );
3848 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3849 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3852 bool cont = myRules.contains( id );
3854 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3856 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3857 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3860 //=======================================================================
3861 // function : initialize
3863 //=======================================================================
3864 void SMESHGUI::initialize( CAM_Application* app )
3866 SalomeApp_Module::initialize( app );
3868 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3870 /* Automatic Update flag */
3871 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3873 // ----- create actions --------------
3875 //createSMESHAction( SMESHOp::OpImportDAT, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3876 createSMESHAction( SMESHOp::OpImportUNV, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_I) );
3877 createSMESHAction( SMESHOp::OpImportMED, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3878 createSMESHAction( SMESHOp::OpImportSTL, "IMPORT_STL" );
3880 createSMESHAction( SMESHOp::OpImportCGNS, "IMPORT_CGNS" );
3882 createSMESHAction( SMESHOp::OpImportSAUV, "IMPORT_SAUV" );
3883 createSMESHAction( SMESHOp::OpImportGMF, "IMPORT_GMF" );
3884 createSMESHAction( SMESHOp::OpPopupImportUNV, "IMPORT_UNV");
3885 createSMESHAction( SMESHOp::OpPopupImportMED, "IMPORT_MED");
3886 createSMESHAction( SMESHOp::OpPopupImportSTL, "IMPORT_STL" );
3888 createSMESHAction( SMESHOp::OpPopupImportCGNS, "IMPORT_CGNS" );
3890 createSMESHAction( SMESHOp::OpPopupImportSAUV, "IMPORT_SAUV" );
3891 createSMESHAction( SMESHOp::OpPopupImportGMF, "IMPORT_GMF" );
3893 createSMESHAction( SMESHOp::OpExportDAT, "DAT" );
3894 createSMESHAction( SMESHOp::OpExportMED, "MED" );
3895 createSMESHAction( SMESHOp::OpExportUNV, "UNV" );
3896 createSMESHAction( SMESHOp::OpExportSTL, "STL" );
3898 createSMESHAction( SMESHOp::OpExportCGNS, "CGNS");
3900 createSMESHAction( SMESHOp::OpExportSAUV, "SAUV");
3901 createSMESHAction( SMESHOp::OpExportGMF, "GMF" );
3902 createSMESHAction( SMESHOp::OpPopupExportDAT, "DAT" );
3903 createSMESHAction( SMESHOp::OpPopupExportMED, "MED" );
3904 createSMESHAction( SMESHOp::OpPopupExportUNV, "UNV" );
3905 createSMESHAction( SMESHOp::OpPopupExportSTL, "STL" );
3907 createSMESHAction( SMESHOp::OpPopupExportCGNS, "CGNS");
3909 createSMESHAction( SMESHOp::OpPopupExportSAUV, "SAUV");
3910 createSMESHAction( SMESHOp::OpPopupExportGMF, "GMF" );
3911 createSMESHAction( SMESHOp::OpFileInformation, "FILE_INFO" );
3912 createSMESHAction( SMESHOp::OpDelete, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3913 createSMESHAction( SMESHOp::OpSelectFiltersLibrary, "SEL_FILTER_LIB" );
3914 createSMESHAction( SMESHOp::OpCreateMesh, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3915 createSMESHAction( SMESHOp::OpCreateSubMesh, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3916 createSMESHAction( SMESHOp::OpEditMeshOrSubMesh, "EDIT_MESHSUBMESH", "ICON_DLG_EDIT_MESH" );
3917 createSMESHAction( SMESHOp::OpEditMesh, "EDIT_MESH", "ICON_DLG_EDIT_MESH" );
3918 createSMESHAction( SMESHOp::OpEditSubMesh, "EDIT_SUBMESH", "ICON_DLG_EDIT_MESH" );
3919 createSMESHAction( SMESHOp::OpBuildCompoundMesh, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3920 createSMESHAction( SMESHOp::OpCopyMesh, "COPY_MESH", "ICON_COPY_MESH" );
3921 createSMESHAction( SMESHOp::OpCompute, "COMPUTE", "ICON_COMPUTE" );
3922 createSMESHAction( SMESHOp::OpComputeSubMesh, "COMPUTE_SUBMESH", "ICON_COMPUTE" );
3923 createSMESHAction( SMESHOp::OpPreCompute, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3924 createSMESHAction( SMESHOp::OpEvaluate, "EVALUATE", "ICON_EVALUATE" );
3925 createSMESHAction( SMESHOp::OpMeshOrder, "MESH_ORDER", "ICON_MESH_ORDER");
3926 createSMESHAction( SMESHOp::OpCreateGroup, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3927 createSMESHAction( SMESHOp::OpCreateGeometryGroup, "CREATE_GEO_GROUP", "ICON_CREATE_GEO_GROUP" );
3928 createSMESHAction( SMESHOp::OpConstructGroup, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3929 createSMESHAction( SMESHOp::OpEditGroup, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3930 createSMESHAction( SMESHOp::OpEditGeomGroupAsGroup, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3931 createSMESHAction( SMESHOp::OpUnionGroups, "UN_GROUP", "ICON_UNION" );
3932 createSMESHAction( SMESHOp::OpIntersectGroups, "INT_GROUP", "ICON_INTERSECT" );
3933 createSMESHAction( SMESHOp::OpCutGroups, "CUT_GROUP", "ICON_CUT" );
3934 createSMESHAction( SMESHOp::OpGroupUnderlyingElem, "UNDERLYING_ELEMS", "ICON_UNDERLYING_ELEMS" );
3935 createSMESHAction( SMESHOp::OpFaceGroupsByEdges, "FACE_GROUPS_BY_EDGES", "ICON_FACE_GROUPS_BY_EDGES" );
3936 createSMESHAction( SMESHOp::OpAddElemGroupPopup, "ADD_TO_GROUP" );
3937 createSMESHAction( SMESHOp::OpRemoveElemGroupPopup, "REMOVE_FROM_GROUP" );
3938 createSMESHAction( SMESHOp::OpDeleteGroup, "DEL_GROUP", "ICON_DEL_GROUP" );
3939 createSMESHAction( SMESHOp::OpMeshInformation , "ADV_INFO", "ICON_ADV_INFO" );
3940 //createSMESHAction( SMESHOp::OpStdInfo, "STD_INFO", "ICON_STD_INFO" );
3941 //createSMESHAction( SMESHOp::OpWhatIs, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3942 createSMESHAction( SMESHOp::OpFindElementByPoint, "FIND_ELEM", "ICON_FIND_ELEM" );
3944 createSMESHAction( SMESHOp::OpFreeNode, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3945 createSMESHAction( SMESHOp::OpEqualNode, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3946 createSMESHAction( SMESHOp::OpNodeConnectivityNb, "NODE_CONNECTIVITY_NB", "ICON_NODE_CONN_NB", 0, true );
3947 createSMESHAction( SMESHOp::OpFreeEdge, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3948 createSMESHAction( SMESHOp::OpFreeBorder, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3949 createSMESHAction( SMESHOp::OpLength, "LENGTH", "ICON_LENGTH", 0, true );
3950 createSMESHAction( SMESHOp::OpConnection, "CONNECTION", "ICON_CONNECTION", 0, true );
3951 createSMESHAction( SMESHOp::OpEqualEdge, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3952 createSMESHAction( SMESHOp::OpFreeFace, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3953 createSMESHAction( SMESHOp::OpBareBorderFace, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3954 createSMESHAction( SMESHOp::OpOverConstrainedFace, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3955 createSMESHAction( SMESHOp::OpLength2D, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3956 createSMESHAction( SMESHOp::OpDeflection2D, "DEFLECTION_2D", "ICON_DEFLECTION_2D", 0, true );
3957 createSMESHAction( SMESHOp::OpConnection2D, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3958 createSMESHAction( SMESHOp::OpArea, "AREA", "ICON_AREA", 0, true );
3959 createSMESHAction( SMESHOp::OpTaper, "TAPER", "ICON_TAPER", 0, true );
3960 createSMESHAction( SMESHOp::OpAspectRatio, "ASPECT", "ICON_ASPECT", 0, true );
3961 createSMESHAction( SMESHOp::OpMinimumAngle, "MIN_ANG", "ICON_ANGLE", 0, true );
3962 createSMESHAction( SMESHOp::OpWarpingAngle, "WARP", "ICON_WARP", 0, true );
3963 createSMESHAction( SMESHOp::OpSkew, "SKEW", "ICON_SKEW", 0, true );
3964 createSMESHAction( SMESHOp::OpMaxElementLength2D, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3965 createSMESHAction( SMESHOp::OpEqualFace, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3966 createSMESHAction( SMESHOp::OpAspectRatio3D, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3967 createSMESHAction( SMESHOp::OpVolume, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3968 createSMESHAction( SMESHOp::OpMaxElementLength3D, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3969 createSMESHAction( SMESHOp::OpBareBorderVolume, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3970 createSMESHAction( SMESHOp::OpOverConstrainedVolume, "OVER_CONSTRAINED_VOLUME", "ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3971 createSMESHAction( SMESHOp::OpEqualVolume, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3972 createSMESHAction( SMESHOp::OpOverallMeshQuality, "OVERALL_MESH_QUALITY", "ICON_OVL_MESH_QUALITY" );
3974 createSMESHAction( SMESHOp::OpNode, "NODE", "ICON_DLG_NODE" );
3975 createSMESHAction( SMESHOp::OpElem0D, "ELEM0D", "ICON_DLG_ELEM0D" );
3976 createSMESHAction( SMESHOp::OpElem0DOnElemNodes, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3977 createSMESHAction( SMESHOp::OpBall, "BALL", "ICON_DLG_BALL" );
3978 createSMESHAction( SMESHOp::OpEdge, "EDGE", "ICON_DLG_EDGE" );
3979 createSMESHAction( SMESHOp::OpTriangle, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3980 createSMESHAction( SMESHOp::OpQuadrangle, "QUAD", "ICON_DLG_QUADRANGLE" );
3981 createSMESHAction( SMESHOp::OpPolygon, "POLYGON", "ICON_DLG_POLYGON" );
3982 createSMESHAction( SMESHOp::OpTetrahedron, "TETRA", "ICON_DLG_TETRAS" );
3983 createSMESHAction( SMESHOp::OpHexahedron, "HEXA", "ICON_DLG_HEXAS" );
3984 createSMESHAction( SMESHOp::OpPentahedron, "PENTA", "ICON_DLG_PENTA" );
3985 createSMESHAction( SMESHOp::OpPyramid , "PYRAMID", "ICON_DLG_PYRAMID" );
3986 createSMESHAction( SMESHOp::OpHexagonalPrism, "OCTA", "ICON_DLG_OCTA" );
3987 createSMESHAction( SMESHOp::OpPolyhedron, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3988 createSMESHAction( SMESHOp::OpQuadraticEdge, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3989 createSMESHAction( SMESHOp::OpQuadraticTriangle, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3990 createSMESHAction( SMESHOp::OpBiQuadraticTriangle, "BIQUADRATIC_TRIANGLE", "ICON_DLG_BIQUADRATIC_TRIANGLE" );
3991 createSMESHAction( SMESHOp::OpQuadraticQuadrangle, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3992 createSMESHAction( SMESHOp::OpBiQuadraticQuadrangle, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3993 createSMESHAction( SMESHOp::OpQuadraticPolygon, "QUADRATIC_POLYGON", "ICON_DLG_QUADRATIC_POLYGON" );
3994 createSMESHAction( SMESHOp::OpQuadraticTetrahedron, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3995 createSMESHAction( SMESHOp::OpQuadraticPyramid, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3996 createSMESHAction( SMESHOp::OpQuadraticPentahedron, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3997 createSMESHAction( SMESHOp::OpBiQuadraticPentahedron, "BIQUADRATIC_PENTAHEDRON", "ICON_DLG_BIQUADRATIC_PENTAHEDRON" );
3998 createSMESHAction( SMESHOp::OpQuadraticHexahedron, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3999 createSMESHAction( SMESHOp::OpTriQuadraticHexahedron, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
4001 createSMESHAction( SMESHOp::OpRemoveNodes, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
4002 createSMESHAction( SMESHOp::OpRemoveElements, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
4003 createSMESHAction( SMESHOp::OpRemoveOrphanNodes, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
4004 createSMESHAction( SMESHOp::OpClearMesh, "CLEAR_MESH", "ICON_CLEAR_MESH" );
4006 //createSMESHAction( SMESHOp::OpRenumberingNodes, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
4007 //createSMESHAction( SMESHOp::OpRenumberingElements, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
4009 createSMESHAction( SMESHOp::OpTranslation, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
4010 createSMESHAction( SMESHOp::OpRotation, "ROT", "ICON_DLG_MESH_ROTATION" );
4011 createSMESHAction( SMESHOp::OpSymmetry, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
4012 createSMESHAction( SMESHOp::OpScale, "SCALE", "ICON_DLG_MESH_SCALE" );
4013 createSMESHAction( SMESHOp::OpOffset, "OFFSET", "ICON_DLG_MESH_OFFSET" );
4014 createSMESHAction( SMESHOp::OpSewing, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
4015 createSMESHAction( SMESHOp::OpMergeNodes, "MERGE", "ICON_SMESH_MERGE_NODES" );
4016 createSMESHAction( SMESHOp::OpMergeElements, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
4017 createSMESHAction( SMESHOp::OpMoveNode, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
4018 createSMESHAction( SMESHOp::OpDuplicateNodes, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
4019 createSMESHAction( SMESHOp::OpDiagonalInversion, "INV", "ICON_DLG_MESH_DIAGONAL" );
4020 createSMESHAction( SMESHOp::OpUnionOfTwoTriangle, "UNION2", "ICON_UNION2TRI" );
4021 createSMESHAction( SMESHOp::OpOrientation, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
4022 createSMESHAction( SMESHOp::OpReorientFaces, "REORIENT_2D", "ICON_REORIENT_2D" );
4023 createSMESHAction( SMESHOp::OpUnionOfTriangles, "UNION", "ICON_UNIONTRI" );
4024 createSMESHAction( SMESHOp::OpCuttingOfQuadrangles, "CUT", "ICON_CUTQUAD" );
4025 createSMESHAction( SMESHOp::OpSplitVolumes, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
4026 createSMESHAction( SMESHOp::OpSplitBiQuadratic, "SPLIT_BIQUAD", "ICON_SPLIT_BIQUAD" );
4027 createSMESHAction( SMESHOp::OpSmoothing, "SMOOTH", "ICON_DLG_SMOOTHING" );
4028 createSMESHAction( SMESHOp::OpExtrusion, "EXTRUSION", "ICON_EXTRUSION" );
4029 createSMESHAction( SMESHOp::OpExtrusionAlongAPath, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
4030 createSMESHAction( SMESHOp::OpRevolution, "REVOLUTION", "ICON_REVOLUTION" );
4031 createSMESHAction( SMESHOp::OpPatternMapping, "MAP", "ICON_MAP" );
4032 createSMESHAction( SMESHOp::OpConvertMeshToQuadratic, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
4033 createSMESHAction( SMESHOp::OpCreateBoundaryElements, "2D_FROM_3D", "ICON_2D_FROM_3D" );
4035 createSMESHAction( SMESHOp::OpReset, "RESET" );
4036 createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
4037 createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
4038 createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
4039 createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
4040 #ifndef DISABLE_PLOT2DVIEWER
4041 createSMESHAction( SMESHOp::OpPlotDistribution, "PLOT_DISTRIBUTION" );
4043 createSMESHAction( SMESHOp::OpDMWireframe, "WIRE", "ICON_WIRE", 0, true );
4044 createSMESHAction( SMESHOp::OpDMShading, "SHADE", "ICON_SHADE", 0, true );
4045 createSMESHAction( SMESHOp::OpDMNodes, "NODES", "ICON_POINTS", 0, true );
4046 createSMESHAction( SMESHOp::OpDMShrink, "SHRINK", "ICON_SHRINK", 0, true );
4047 createSMESHAction( SMESHOp::OpUpdate, "UPDATE", "ICON_UPDATE" );
4048 createSMESHAction( SMESHOp::OpDE0DElements, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
4049 createSMESHAction( SMESHOp::OpDEEdges, "EDGES", "ICON_DLG_EDGE", 0, true );
4050 createSMESHAction( SMESHOp::OpDEFaces, "FACES", "ICON_DLG_TRIANGLE", 0, true );
4051 createSMESHAction( SMESHOp::OpDEVolumes, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
4052 createSMESHAction( SMESHOp::OpDEBalls, "BALLS", "ICON_DLG_BALL", 0, true );
4053 createSMESHAction( SMESHOp::OpDEChoose, "CHOOSE", "ICON_DLG_CHOOSE", 0, false );
4054 createSMESHAction( SMESHOp::OpDEAllEntity, "ALL", "ICON_DLG_CHOOSE_ALL", 0, false );
4055 createSMESHAction( SMESHOp::OpOrientationOnFaces, "FACE_ORIENTATION", "", 0, true );
4057 createSMESHAction( SMESHOp::OpRepresentationLines, "LINE_REPRESENTATION", "", 0, true );
4058 createSMESHAction( SMESHOp::OpRepresentationArcs, "ARC_REPRESENTATION", "", 0, true );
4060 createSMESHAction( SMESHOp::OpEditHypothesis, "EDIT_HYPO" );
4061 createSMESHAction( SMESHOp::OpUnassign, "UNASSIGN" );
4062 createSMESHAction( SMESHOp::OpNumberingNodes, "NUM_NODES", "", 0, true );
4063 createSMESHAction( SMESHOp::OpNumberingElements, "NUM_ELEMENTS", "", 0, true );
4064 createSMESHAction( SMESHOp::OpProperties, "COLORS" );
4065 createSMESHAction( SMESHOp::OpTransparency, "TRANSP" );
4066 createSMESHAction( SMESHOp::OpClipping, "CLIP" );
4067 createSMESHAction( SMESHOp::OpAutoColor, "AUTO_COLOR" );
4068 createSMESHAction( SMESHOp::OpDisableAutoColor, "DISABLE_AUTO_COLOR" );
4070 createSMESHAction( SMESHOp::OpMinimumDistance, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
4071 createSMESHAction( SMESHOp::OpBoundingBox, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
4072 createSMESHAction( SMESHOp::OpPropertiesLength, "MEASURE_LENGTH", "ICON_MEASURE_LENGTH" );
4073 createSMESHAction( SMESHOp::OpPropertiesArea, "MEASURE_AREA", "ICON_MEASURE_AREA" );
4074 createSMESHAction( SMESHOp::OpPropertiesVolume, "MEASURE_VOLUME", "ICON_MEASURE_VOLUME" );
4075 createSMESHAction( SMESHOp::OpAngle, "MEASURE_ANGLE", "ICON_MEASURE_ANGLE" );
4077 createSMESHAction( SMESHOp::OpHide, "HIDE", "ICON_HIDE" );
4078 createSMESHAction( SMESHOp::OpShow, "SHOW", "ICON_SHOW" );
4079 createSMESHAction( SMESHOp::OpShowOnly, "DISPLAY_ONLY" );
4081 createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
4083 QList<int> aCtrlActions;
4084 aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
4085 << SMESHOp::OpNodeConnectivityNb // node controls
4086 << SMESHOp::OpFreeEdge << SMESHOp::OpFreeBorder
4087 << SMESHOp::OpLength << SMESHOp::OpConnection << SMESHOp::OpEqualEdge // edge controls
4088 << SMESHOp::OpDeflection2D
4089 << SMESHOp::OpFreeFace << SMESHOp::OpLength2D << SMESHOp::OpConnection2D
4090 << SMESHOp::OpArea << SMESHOp::OpTaper << SMESHOp::OpAspectRatio
4091 << SMESHOp::OpMinimumAngle << SMESHOp::OpWarpingAngle << SMESHOp::OpSkew
4092 << SMESHOp::OpMaxElementLength2D << SMESHOp::OpBareBorderFace
4093 << SMESHOp::OpOverConstrainedFace << SMESHOp::OpEqualFace // face controls
4094 << SMESHOp::OpAspectRatio3D << SMESHOp::OpVolume
4095 << SMESHOp::OpMaxElementLength3D << SMESHOp::OpBareBorderVolume
4096 << SMESHOp::OpOverConstrainedVolume << SMESHOp::OpEqualVolume; // volume controls
4097 QActionGroup* aCtrlGroup = new QActionGroup( application()->desktop() );
4098 aCtrlGroup->setExclusive( true );
4099 for( int i = 0; i < aCtrlActions.size(); i++ )
4100 aCtrlGroup->addAction( action( aCtrlActions[i] ) );
4102 // ----- create menu --------------
4103 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
4104 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
4105 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
4106 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
4107 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
4108 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
4109 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
4110 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
4112 createMenu( separator(), fileId );
4114 QMenu* nodeMenu = new QMenu(); QMenu* edgeMenu = new QMenu();
4115 QMenu* faceMenu = new QMenu(); QMenu* volumeMenu = new QMenu();
4116 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
4117 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
4118 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10, -1, nodeMenu ),
4119 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10, -1, edgeMenu ),
4120 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10, -1, faceMenu ),
4121 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10, -1, volumeMenu ),
4122 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
4123 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
4124 //renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
4125 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 ),
4126 basicPropId = createMenu( tr( "MEN_BASIC_PROPERTIES" ), measureId, -1, 10 );
4128 //createMenu( SMESHOp::OpImportDAT, importId, -1 );
4129 createMenu( SMESHOp::OpImportUNV, importId, -1 );
4130 createMenu( SMESHOp::OpImportMED, importId, -1 );
4131 createMenu( SMESHOp::OpImportSTL, importId, -1 );
4133 createMenu( SMESHOp::OpImportCGNS, importId, -1 );
4135 createMenu( SMESHOp::OpImportSAUV, importId, -1 );
4136 createMenu( SMESHOp::OpImportGMF, importId, -1 );
4137 createMenu( SMESHOp::OpExportDAT, exportId, -1 );
4138 createMenu( SMESHOp::OpExportMED, exportId, -1 );
4139 createMenu( SMESHOp::OpExportUNV, exportId, -1 );
4140 createMenu( SMESHOp::OpExportSTL, exportId, -1 );
4142 createMenu( SMESHOp::OpExportCGNS, exportId, -1 );
4144 createMenu( SMESHOp::OpExportSAUV, exportId, -1 );
4145 createMenu( SMESHOp::OpExportGMF, exportId, -1 );
4146 createMenu( separator(), fileId, 10 );
4148 createMenu( SMESHOp::OpDelete, editId, -1 );
4150 createMenu( SMESHOp::OpSelectFiltersLibrary, toolsId, -1 );
4152 createMenu( SMESHOp::OpCreateMesh, meshId, -1 ); // "Mesh" menu
4153 createMenu( SMESHOp::OpCreateSubMesh, meshId, -1 );
4154 createMenu( SMESHOp::OpEditMeshOrSubMesh, meshId, -1 );
4155 createMenu( SMESHOp::OpBuildCompoundMesh, meshId, -1 );
4156 createMenu( SMESHOp::OpCopyMesh, meshId, -1 );
4157 createMenu( separator(), meshId, -1 );
4158 createMenu( SMESHOp::OpCompute, meshId, -1 );
4159 createMenu( SMESHOp::OpPreCompute, meshId, -1 );
4160 createMenu( SMESHOp::OpEvaluate, meshId, -1 );
4161 createMenu( SMESHOp::OpMeshOrder, meshId, -1 );
4162 createMenu( separator(), meshId, -1 );
4163 createMenu( SMESHOp::OpCreateGroup, meshId, -1 );
4164 createMenu( SMESHOp::OpCreateGeometryGroup, meshId, -1 );
4165 createMenu( SMESHOp::OpConstructGroup, meshId, -1 );
4166 createMenu( SMESHOp::OpEditGroup, meshId, -1 );
4167 createMenu( SMESHOp::OpEditGeomGroupAsGroup, meshId, -1 );
4168 createMenu( separator(), meshId, -1 );
4169 createMenu( SMESHOp::OpUnionGroups, meshId, -1 );
4170 createMenu( SMESHOp::OpIntersectGroups, meshId, -1 );
4171 createMenu( SMESHOp::OpCutGroups, meshId, -1 );
4172 createMenu( separator(), meshId, -1 );
4173 createMenu( SMESHOp::OpGroupUnderlyingElem, meshId, -1 );
4174 createMenu( SMESHOp::OpFaceGroupsByEdges, meshId, -1 );
4175 createMenu( separator(), meshId, -1 );
4176 createMenu( SMESHOp::OpMeshInformation, meshId, -1 );
4177 //createMenu( SMESHOp::OpStdInfo, meshId, -1 );
4178 //createMenu( SMESHOp::OpWhatIs, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4179 createMenu( SMESHOp::OpFindElementByPoint, meshId, -1 );
4180 createMenu( separator(), meshId, -1 );
4182 createMenu( SMESHOp::OpFreeNode, nodeId, -1 );
4183 createMenu( SMESHOp::OpEqualNode, nodeId, -1 );
4184 //createMenu( SMESHOp::OpNodeConnectivityNb, nodeId, -1 );
4185 createMenu( SMESHOp::OpFreeBorder, edgeId, -1 );
4186 createMenu( SMESHOp::OpLength, edgeId, -1 );
4187 createMenu( SMESHOp::OpConnection, edgeId, -1 );
4188 createMenu( SMESHOp::OpEqualEdge, edgeId, -1 );
4189 createMenu( SMESHOp::OpFreeEdge, faceId, -1 );
4190 createMenu( SMESHOp::OpFreeFace, faceId, -1 );
4191 createMenu( SMESHOp::OpBareBorderFace, faceId, -1 );
4192 createMenu( SMESHOp::OpOverConstrainedFace, faceId, -1 );
4193 createMenu( SMESHOp::OpLength2D, faceId, -1 );
4194 createMenu( SMESHOp::OpConnection2D, faceId, -1 );
4195 createMenu( SMESHOp::OpArea, faceId, -1 );
4196 createMenu( SMESHOp::OpTaper, faceId, -1 );
4197 createMenu( SMESHOp::OpAspectRatio, faceId, -1 );
4198 createMenu( SMESHOp::OpMinimumAngle, faceId, -1 );
4199 createMenu( SMESHOp::OpWarpingAngle, faceId, -1 );
4200 createMenu( SMESHOp::OpSkew, faceId, -1 );
4201 createMenu( SMESHOp::OpMaxElementLength2D, faceId, -1 );
4202 createMenu( SMESHOp::OpEqualFace, faceId, -1 );
4203 createMenu( SMESHOp::OpDeflection2D, faceId, -1 );
4204 createMenu( SMESHOp::OpAspectRatio3D, volumeId, -1 );
4205 createMenu( SMESHOp::OpVolume, volumeId, -1 );
4206 createMenu( SMESHOp::OpMaxElementLength3D, volumeId, -1 );
4207 createMenu( SMESHOp::OpBareBorderVolume, volumeId, -1 );
4208 createMenu( SMESHOp::OpOverConstrainedVolume, volumeId, -1 );
4209 createMenu( SMESHOp::OpEqualVolume, volumeId, -1 );
4210 createMenu( separator(), ctrlId, -1 );
4211 createMenu( SMESHOp::OpReset, ctrlId, -1 );
4212 createMenu( separator(), ctrlId, -1 );
4213 createMenu( SMESHOp::OpOverallMeshQuality, ctrlId, -1 );
4215 createMenu( SMESHOp::OpNode, addId, -1 );
4216 createMenu( SMESHOp::OpElem0D, addId, -1 );
4217 createMenu( SMESHOp::OpElem0DOnElemNodes, addId, -1 );
4218 createMenu( SMESHOp::OpBall, addId, -1 );
4219 createMenu( SMESHOp::OpEdge, addId, -1 );
4220 createMenu( SMESHOp::OpTriangle, addId, -1 );
4221 createMenu( SMESHOp::OpQuadrangle, addId, -1 );
4222 createMenu( SMESHOp::OpPolygon, addId, -1 );
4223 createMenu( SMESHOp::OpTetrahedron, addId, -1 );
4224 createMenu( SMESHOp::OpHexahedron, addId, -1 );
4225 createMenu( SMESHOp::OpPentahedron, addId, -1 );
4226 createMenu( SMESHOp::OpPyramid, addId, -1 );
4227 createMenu( SMESHOp::OpHexagonalPrism, addId, -1 );
4228 createMenu( SMESHOp::OpPolyhedron, addId, -1 );
4229 createMenu( separator(), addId, -1 );
4230 createMenu( SMESHOp::OpQuadraticEdge, addId, -1 );
4231 createMenu( SMESHOp::OpQuadraticTriangle, addId, -1 );
4232 createMenu( SMESHOp::OpBiQuadraticTriangle , addId, -1 );
4233 createMenu( SMESHOp::OpQuadraticQuadrangle, addId, -1 );
4234 createMenu( SMESHOp::OpBiQuadraticQuadrangle, addId, -1 );
4235 createMenu( SMESHOp::OpQuadraticPolygon, addId, -1 );
4236 createMenu( SMESHOp::OpQuadraticTetrahedron, addId, -1 );
4237 createMenu( SMESHOp::OpQuadraticPyramid, addId, -1 );
4238 createMenu( SMESHOp::OpQuadraticPentahedron, addId, -1 );
4239 createMenu( SMESHOp::OpBiQuadraticPentahedron, addId, -1 );
4240 createMenu( SMESHOp::OpQuadraticHexahedron, addId, -1 );
4241 createMenu( SMESHOp::OpTriQuadraticHexahedron, addId, -1 );
4243 createMenu( SMESHOp::OpRemoveNodes, removeId, -1 );
4244 createMenu( SMESHOp::OpRemoveElements, removeId, -1 );
4245 createMenu( SMESHOp::OpRemoveOrphanNodes, removeId, -1 );
4246 createMenu( separator(), removeId, -1 );
4247 createMenu( SMESHOp::OpDeleteGroup, removeId, -1 );
4248 createMenu( separator(), removeId, -1 );
4249 createMenu( SMESHOp::OpClearMesh, removeId, -1 );
4251 //createMenu( SMESHOp::OpRenumberingNodes, renumId, -1 );
4252 //createMenu( SMESHOp::OpRenumberingElements, renumId, -1 );
4254 createMenu( SMESHOp::OpMergeNodes, transfId, -1 );
4255 createMenu( SMESHOp::OpMergeElements, transfId, -1 );
4256 createMenu( SMESHOp::OpTranslation, transfId, -1 );
4257 createMenu( SMESHOp::OpRotation, transfId, -1 );
4258 createMenu( SMESHOp::OpSymmetry, transfId, -1 );
4259 createMenu( SMESHOp::OpScale, transfId, -1 );
4260 createMenu( SMESHOp::OpOffset, transfId, -1 );
4261 createMenu( SMESHOp::OpSewing, transfId, -1 );
4262 createMenu( SMESHOp::OpDuplicateNodes, transfId, -1 );
4264 createMenu( SMESHOp::OpConvertMeshToQuadratic, modifyId, -1 );
4265 createMenu( SMESHOp::OpCreateBoundaryElements, modifyId, -1 );
4266 createMenu( SMESHOp::OpExtrusion, modifyId, -1 );
4267 createMenu( SMESHOp::OpExtrusionAlongAPath, modifyId, -1 );
4268 createMenu( SMESHOp::OpRevolution, modifyId, -1 );
4269 createMenu( SMESHOp::OpOrientation, modifyId, -1 );
4270 createMenu( SMESHOp::OpReorientFaces, modifyId, -1 );
4271 createMenu( SMESHOp::OpMoveNode, modifyId, -1 );
4272 createMenu( SMESHOp::OpDiagonalInversion, modifyId, -1 );
4273 createMenu( SMESHOp::OpUnionOfTwoTriangle, modifyId, -1 );
4274 createMenu( SMESHOp::OpUnionOfTriangles, modifyId, -1 );
4275 createMenu( SMESHOp::OpCuttingOfQuadrangles, modifyId, -1 );
4276 createMenu( SMESHOp::OpSplitVolumes, modifyId, -1 );
4277 createMenu( SMESHOp::OpSplitBiQuadratic, modifyId, -1 );
4278 createMenu( SMESHOp::OpSmoothing, modifyId, -1 );
4279 createMenu( SMESHOp::OpPatternMapping, modifyId, -1 );
4281 createMenu( SMESHOp::OpMinimumDistance, measureId, -1 );
4282 createMenu( SMESHOp::OpBoundingBox, measureId, -1 );
4283 createMenu( SMESHOp::OpAngle, measureId, -1 );
4284 createMenu( SMESHOp::OpPropertiesLength, basicPropId, -1 );
4285 createMenu( SMESHOp::OpPropertiesArea, basicPropId, -1 );
4286 createMenu( SMESHOp::OpPropertiesVolume, basicPropId, -1 );
4287 createMenu( SMESHOp::OpUpdate, viewId, -1 );
4289 connect( nodeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4290 connect( edgeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4291 connect( faceMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4292 connect( volumeMenu, SIGNAL( aboutToShow() ), this, SLOT( onUpdateControlActions() ) );
4294 // ----- create toolbars --------------
4295 int meshTb = createTool( tr( "TB_MESH" ), QString( "SMESHMeshToolbar" ) ),
4296 info = createTool( tr( "TB_INFO" ), QString( "SMESHInformationToolbar" ) ),
4297 groupTb = createTool( tr( "TB_GROUP" ), QString( "SMESHGroupToolbar" ) ),
4298 ctrl0dTb = createTool( tr( "TB_CTRL0D" ), QString( "SMESHNodeControlsToolbar" ) ),
4299 ctrl1dTb = createTool( tr( "TB_CTRL1D" ), QString( "SMESHEdgeControlsToolbar" ) ),
4300 ctrl2dTb = createTool( tr( "TB_CTRL2D" ), QString( "SMESHFaceControlsToolbar" ) ),
4301 ctrl3dTb = createTool( tr( "TB_CTRL3D" ), QString( "SMESHVolumeControlsToolbar" ) ),
4302 addElemTb = createTool( tr( "TB_ADD" ), QString( "SMESHAddElementToolbar" ) ),
4303 addNonElemTb = createTool( tr( "TB_ADDNON" ), QString( "SMESHAddElementToolbar" ) ),
4304 remTb = createTool( tr( "TB_REM" ), QString( "SMESHRemoveToolbar" ) ),
4305 //renumbTb = createTool( tr( "TB_RENUMBER" ), QString( "SMESHRenumberingToolbar" ) ),
4306 transformTb = createTool( tr( "TB_TRANSFORM" ), QString( "SMESHTransformationToolbar" ) ),
4307 modifyTb = createTool( tr( "TB_MODIFY" ), QString( "SMESHModificationToolbar" ) ),
4308 measuremTb = createTool( tr( "TB_MEASUREM" ), QString( "SMESHMeasurementsToolbar" ) ),
4309 dispModeTb = createTool( tr( "TB_DISP_MODE" ), QString( "SMESHDisplayModeToolbar" ) );
4311 createTool( SMESHOp::OpCreateMesh, meshTb );
4312 createTool( SMESHOp::OpCreateSubMesh, meshTb );
4313 createTool( SMESHOp::OpEditMeshOrSubMesh, meshTb );
4314 createTool( SMESHOp::OpBuildCompoundMesh, meshTb );
4315 createTool( SMESHOp::OpCopyMesh, meshTb );
4316 createTool( separator(), meshTb );
4317 createTool( SMESHOp::OpCompute, meshTb );
4318 createTool( SMESHOp::OpPreCompute, meshTb );
4319 createTool( SMESHOp::OpEvaluate, meshTb );
4320 createTool( SMESHOp::OpMeshOrder, meshTb );
4322 createTool( SMESHOp::OpCreateGroup, groupTb );
4323 createTool( SMESHOp::OpCreateGeometryGroup, groupTb );
4324 createTool( SMESHOp::OpConstructGroup, groupTb );
4325 createTool( SMESHOp::OpEditGroup, groupTb );
4327 createTool( SMESHOp::OpMeshInformation, info );
4328 //createTool( SMESHOp::OpStdInfo, meshTb );
4329 //createTool( SMESHOp::OpWhatIs, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
4330 createTool( SMESHOp::OpFindElementByPoint, info );
4332 createTool( SMESHOp::OpFreeNode, ctrl0dTb );
4333 createTool( SMESHOp::OpEqualNode, ctrl0dTb );
4334 //createTool( SMESHOp::OpNodeConnectivityNb, ctrl0dTb );
4336 createTool( SMESHOp::OpFreeBorder, ctrl1dTb );
4337 createTool( SMESHOp::OpLength, ctrl1dTb );
4338 createTool( SMESHOp::OpConnection, ctrl1dTb );
4339 createTool( SMESHOp::OpEqualEdge, ctrl1dTb );
4341 createTool( SMESHOp::OpFreeEdge, ctrl2dTb );
4342 createTool( SMESHOp::OpFreeFace, ctrl2dTb );
4343 createTool( SMESHOp::OpBareBorderFace, ctrl2dTb );
4344 createTool( SMESHOp::OpOverConstrainedFace, ctrl2dTb );
4345 createTool( SMESHOp::OpLength2D, ctrl2dTb );
4346 createTool( SMESHOp::OpConnection2D, ctrl2dTb );
4347 createTool( SMESHOp::OpArea, ctrl2dTb );
4348 createTool( SMESHOp::OpTaper, ctrl2dTb );
4349 createTool( SMESHOp::OpAspectRatio, ctrl2dTb );
4350 createTool( SMESHOp::OpMinimumAngle, ctrl2dTb );
4351 createTool( SMESHOp::OpWarpingAngle, ctrl2dTb );
4352 createTool( SMESHOp::OpSkew, ctrl2dTb );
4353 createTool( SMESHOp::OpMaxElementLength2D, ctrl2dTb );
4354 createTool( SMESHOp::OpEqualFace, ctrl2dTb );
4355 createTool( SMESHOp::OpDeflection2D, ctrl2dTb );
4357 createTool( SMESHOp::OpAspectRatio3D, ctrl3dTb );
4358 createTool( SMESHOp::OpVolume, ctrl3dTb );
4359 createTool( SMESHOp::OpMaxElementLength3D, ctrl3dTb );
4360 createTool( SMESHOp::OpBareBorderVolume, ctrl3dTb );
4361 createTool( SMESHOp::OpOverConstrainedVolume, ctrl3dTb );
4362 createTool( SMESHOp::OpEqualVolume, ctrl3dTb );
4364 createTool( SMESHOp::OpNode, addElemTb );
4365 createTool( SMESHOp::OpElem0D, addElemTb );
4366 createTool( SMESHOp::OpElem0DOnElemNodes, addElemTb );
4367 createTool( SMESHOp::OpBall, addElemTb );
4368 createTool( SMESHOp::OpEdge, addElemTb );
4369 createTool( SMESHOp::OpTriangle, addElemTb );
4370 createTool( SMESHOp::OpQuadrangle, addElemTb );
4371 createTool( SMESHOp::OpPolygon, addElemTb );
4372 createTool( SMESHOp::OpTetrahedron, addElemTb );
4373 createTool( SMESHOp::OpHexahedron, addElemTb );
4374 createTool( SMESHOp::OpPentahedron, addElemTb );
4375 createTool( SMESHOp::OpPyramid, addElemTb );
4376 createTool( SMESHOp::OpHexagonalPrism, addElemTb );
4377 createTool( SMESHOp::OpPolyhedron, addElemTb );
4379 createTool( SMESHOp::OpQuadraticEdge, addNonElemTb );
4380 createTool( SMESHOp::OpQuadraticTriangle, addNonElemTb );
4381 createTool( SMESHOp::OpBiQuadraticTriangle, addNonElemTb );
4382 createTool( SMESHOp::OpQuadraticQuadrangle, addNonElemTb );
4383 createTool( SMESHOp::OpBiQuadraticQuadrangle, addNonElemTb );
4384 createTool( SMESHOp::OpQuadraticPolygon, addNonElemTb );
4385 createTool( SMESHOp::OpQuadraticTetrahedron, addNonElemTb );
4386 createTool( SMESHOp::OpQuadraticPyramid, addNonElemTb );
4387 createTool( SMESHOp::OpQuadraticPentahedron, addNonElemTb );
4388 createTool( SMESHOp::OpBiQuadraticPentahedron, addNonElemTb );
4389 createTool( SMESHOp::OpQuadraticHexahedron, addNonElemTb );
4390 createTool( SMESHOp::OpTriQuadraticHexahedron, addNonElemTb );
4392 createTool( SMESHOp::OpRemoveNodes, remTb );
4393 createTool( SMESHOp::OpRemoveElements, remTb );
4394 createTool( SMESHOp::OpRemoveOrphanNodes, remTb );
4395 createTool( SMESHOp::OpClearMesh, remTb );
4397 //createTool( SMESHOp::OpRenumberingNodes, renumbTb );
4398 //createTool( SMESHOp::OpRenumberingElements, renumbTb );
4400 createTool( SMESHOp::OpMergeNodes, transformTb );
4401 createTool( SMESHOp::OpMergeElements, transformTb );
4402 createTool( SMESHOp::OpTranslation, transformTb );
4403 createTool( SMESHOp::OpRotation, transformTb );
4404 createTool( SMESHOp::OpSymmetry, transformTb );
4405 createTool( SMESHOp::OpScale, transformTb );
4406 createTool( SMESHOp::OpOffset, transformTb );
4407 createTool( SMESHOp::OpSewing, transformTb );
4408 createTool( SMESHOp::OpDuplicateNodes, transformTb );
4410 createTool( SMESHOp::OpConvertMeshToQuadratic, modifyTb );
4411 createTool( SMESHOp::OpCreateBoundaryElements, modifyTb );
4412 createTool( SMESHOp::OpExtrusion, modifyTb );
4413 createTool( SMESHOp::OpExtrusionAlongAPath, modifyTb );
4414 createTool( SMESHOp::OpRevolution, modifyTb );
4415 createTool( SMESHOp::OpOrientation, modifyTb );
4416 createTool( SMESHOp::OpReorientFaces, modifyTb );
4417 createTool( SMESHOp::OpMoveNode, modifyTb );
4418 createTool( SMESHOp::OpDiagonalInversion, modifyTb );
4419 createTool( SMESHOp::OpUnionOfTwoTriangle, modifyTb );
4420 createTool( SMESHOp::OpUnionOfTriangles, modifyTb );
4421 createTool( SMESHOp::OpCuttingOfQuadrangles, modifyTb );
4422 createTool( SMESHOp::OpSplitVolumes, modifyTb );
4423 createTool( SMESHOp::OpSplitBiQuadratic, modifyTb );
4424 createTool( SMESHOp::OpSmoothing, modifyTb );
4425 createTool( SMESHOp::OpPatternMapping, modifyTb );
4427 createTool( SMESHOp::OpMinimumDistance, measuremTb );
4429 createTool( SMESHOp::OpUpdate, dispModeTb );
4431 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4432 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4436 OB = "'ObjectBrowser'",
4437 View = "'" + SVTK_Viewer::Type() + "'",
4439 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4440 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4441 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4442 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4443 smesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::COMPONENT ) ),
4444 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4445 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4446 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4447 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4448 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4449 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4450 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4452 mesh_part = mesh + " " + subMesh + " " + group,
4453 mesh_group = mesh + " " + group,
4454 mesh_submesh = mesh + " " + subMesh,
4455 hyp_alg = hypo + " " + algo;
4457 // popup for object browser
4459 isInvisible("not( isVisible )"),
4460 isEmpty("numberOfNodes = 0"),
4461 isNotEmpty("numberOfNodes <> 0"),
4463 // has nodes, edges, etc in VISIBLE! actor
4464 hasNodes("(numberOfNodes > 0 ) && hasActor"),
4465 hasElems("(count( elemTypes ) > 0)"),
4466 hasDifferentElems("(count( elemTypes ) > 1)"),
4467 hasDifferentObjElems("(count( objElemTypes ) > 1)"),
4468 hasBalls("({'BallElem'} in elemTypes)"),
4469 hasElems0d("({'Elem0d'} in elemTypes)"),
4470 hasEdges("({'Edge'} in elemTypes)"),
4471 hasFaces("({'Face'} in elemTypes)"),
4472 hasVolumes("({'Volume'} in elemTypes)"),
4473 hasFacesOrVolumes("(({'Face'} in elemTypes) || ({'Volume'} in elemTypes)) ");
4475 createPopupItem( SMESHOp::OpFileInformation, OB, mesh, "&& selcount=1 && isImported" );
4476 createPopupItem( SMESHOp::OpCreateSubMesh, OB, mesh, "&& hasGeomReference");
4477 createPopupItem( SMESHOp::OpEditMesh, OB, mesh, "&& selcount=1" );
4478 createPopupItem( SMESHOp::OpEditSubMesh, OB, subMesh, "&& selcount=1 && hasGeomReference" );
4479 createPopupItem( SMESHOp::OpEditGroup, OB, group );
4480 createPopupItem( SMESHOp::OpEditGeomGroupAsGroup, OB, group, "&& groupType != 'Group'" );
4482 popupMgr()->insert( separator(), -1, 0 );
4483 createPopupItem( SMESHOp::OpCompute, OB, mesh, "&& selcount=1 && isComputable" );
4484 createPopupItem( SMESHOp::OpComputeSubMesh, OB, subMesh, "&& selcount=1 && isComputable" );
4485 createPopupItem( SMESHOp::OpPreCompute, OB, mesh, "&& selcount=1 && isPreComputable" );
4486 createPopupItem( SMESHOp::OpEvaluate, OB, mesh, "&& selcount=1 && isComputable" );
4487 createPopupItem( SMESHOp::OpMeshOrder, OB, mesh, "&& selcount=1 && isComputable && hasGeomReference" );
4488 createPopupItem( SMESHOp::OpUpdate, OB, mesh_part );
4489 createPopupItem( SMESHOp::OpMeshInformation, OB, mesh_part );
4490 createPopupItem( SMESHOp::OpFindElementByPoint,OB, mesh_group, "&& selcount=1" );
4491 createPopupItem( SMESHOp::OpOverallMeshQuality,OB, mesh_part );
4492 popupMgr()->insert( separator(), -1, 0 );
4493 createPopupItem( SMESHOp::OpCreateGroup, OB, mesh, "&& selcount=1" );
4494 createPopupItem( SMESHOp::OpCreateGeometryGroup, OB, mesh, "&& selcount=1 && hasGeomReference" );
4495 createPopupItem( SMESHOp::OpConstructGroup, OB, subMesh );
4496 popupMgr()->insert( separator(), -1, 0 );
4497 createPopupItem( SMESHOp::OpEditHypothesis, OB, hypo, "&& isEditableHyp");
4498 createPopupItem( SMESHOp::OpUnassign, OB, hyp_alg );
4499 popupMgr()->insert( separator(), -1, 0 );
4500 createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh );
4501 createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2");
4502 popupMgr()->insert( separator(), -1, 0 );
4503 createPopupItem( SMESHOp::OpClearMesh, OB, mesh );
4504 //popupMgr()->insert( separator(), -1, 0 );
4506 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4507 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4508 QString only_one_2D = only_one_non_empty + " && dim>1";
4510 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4511 createPopupItem( SMESHOp::OpPopupExportMED, OB, mesh_group, multiple_non_empty, anId );
4512 createPopupItem( SMESHOp::OpPopupExportUNV, OB, mesh_group, only_one_non_empty, anId );
4513 createPopupItem( SMESHOp::OpPopupExportSTL, OB, mesh_group, only_one_2D, anId );
4515 createPopupItem( SMESHOp::OpPopupExportCGNS, OB, mesh_group, multiple_non_empty, anId );
4517 createPopupItem( SMESHOp::OpPopupExportSAUV, OB, mesh_group, only_one_non_empty, anId );
4518 createPopupItem( SMESHOp::OpPopupExportGMF, OB, mesh_group, only_one_non_empty, anId );
4519 createPopupItem( SMESHOp::OpPopupExportDAT, OB, mesh_group, only_one_non_empty, anId );
4520 createPopupItem( SMESHOp::OpDelete, OB, mesh_part + " " + hyp_alg );
4521 createPopupItem( SMESHOp::OpDeleteGroup, OB, group );
4523 anId = popupMgr()->insert( tr( "MEN_IMPORT" ), -1, -1 ); // IMPORT submenu
4524 createPopupItem( SMESHOp::OpPopupImportMED, OB, smesh, "", anId );
4525 createPopupItem( SMESHOp::OpPopupImportUNV, OB, smesh, "", anId );
4526 createPopupItem( SMESHOp::OpPopupImportSTL, OB, smesh, "", anId );
4528 createPopupItem( SMESHOp::OpPopupImportCGNS, OB, smesh, "", anId );
4530 createPopupItem( SMESHOp::OpPopupImportSAUV, OB, smesh, "", anId );
4531 createPopupItem( SMESHOp::OpPopupImportGMF, OB, smesh, "", anId );
4532 createPopupItem( SMESHOp::OpPopupImportDAT, OB, smesh, "", anId );
4533 popupMgr()->insert( separator(), -1, 0 );
4536 createPopupItem( SMESHOp::OpEditGroup, View, group );
4537 createPopupItem( SMESHOp::OpAddElemGroupPopup, View, elems, "&& guiState = 800" );
4538 createPopupItem( SMESHOp::OpRemoveElemGroupPopup, View, elems, "&& guiState = 800" );
4540 popupMgr()->insert( separator(), -1, 0 );
4541 createPopupItem( SMESHOp::OpUpdate, View, mesh_part );
4542 createPopupItem( SMESHOp::OpMeshInformation, View, mesh_part );
4543 createPopupItem( SMESHOp::OpOverallMeshQuality, View, mesh_part );
4544 createPopupItem( SMESHOp::OpFindElementByPoint, View, mesh );
4545 popupMgr()->insert( separator(), -1, 0 );
4547 createPopupItem( SMESHOp::OpAutoColor, OB + " " + View, mesh, "&& (not isAutoColor)" );
4548 createPopupItem( SMESHOp::OpDisableAutoColor, OB + " " + View, mesh, "&& isAutoColor" );
4549 popupMgr()->insert( separator(), -1, 0 );
4551 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4552 QString aType = QString( "%1type in {%2}" ).arg( lc );
4553 aType = aType.arg( mesh_part );
4554 QString aMeshInVTK = aClient + "&&" + aType;
4556 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4557 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4558 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4560 //-------------------------------------------------
4562 //-------------------------------------------------
4563 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4565 popupMgr()->insert( action( SMESHOp::OpNumberingNodes ), anId, -1 );
4566 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4567 popupMgr()->setRule( action( SMESHOp::OpNumberingNodes ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4569 popupMgr()->insert( action( SMESHOp::OpNumberingElements ), anId, -1 );
4570 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4571 popupMgr()->setRule( action( SMESHOp::OpNumberingElements ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4573 popupMgr()->insert( separator(), -1, -1 );
4575 //-------------------------------------------------
4577 //-------------------------------------------------
4578 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4580 popupMgr()->insert( action( SMESHOp::OpDMWireframe ), anId, -1 );
4581 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4582 popupMgr()->setRule( action( SMESHOp::OpDMWireframe ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4584 popupMgr()->insert( action( SMESHOp::OpDMShading ), anId, -1 );
4585 popupMgr()->setRule( action( SMESHOp::OpDMShading ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4586 popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4588 popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
4589 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4590 popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4592 popupMgr()->insert( separator(), anId, -1 );
4594 popupMgr()->insert( action( SMESHOp::OpDMShrink ), anId, -1 );
4595 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4596 popupMgr()->setRule( action( SMESHOp::OpDMShrink ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4598 //-------------------------------------------------
4600 //-------------------------------------------------
4601 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4603 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4605 popupMgr()->insert( action( SMESHOp::OpDE0DElements ), anId, -1 );
4606 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4607 popupMgr()->setRule( action( SMESHOp::OpDE0DElements ), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4609 popupMgr()->insert( action( SMESHOp::OpDEEdges ), anId, -1 );
4610 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4611 popupMgr()->setRule( action( SMESHOp::OpDEEdges ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4613 popupMgr()->insert( action( SMESHOp::OpDEFaces ), anId, -1 );
4614 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4615 popupMgr()->setRule( action( SMESHOp::OpDEFaces ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4617 popupMgr()->insert( action( SMESHOp::OpDEVolumes ), anId, -1 );
4618 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4619 popupMgr()->setRule( action( SMESHOp::OpDEVolumes ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4621 popupMgr()->insert( action( SMESHOp::OpDEBalls ), anId, -1 );
4622 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4623 popupMgr()->setRule( action( SMESHOp::OpDEBalls ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4625 popupMgr()->insert( separator(), anId, -1 );
4627 popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
4628 popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule );
4630 popupMgr()->insert( separator(), anId, -1 );
4632 popupMgr()->insert( action( SMESHOp::OpDEAllEntity ), anId, -1 );
4633 popupMgr()->setRule( action( SMESHOp::OpDEAllEntity ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4636 //-------------------------------------------------
4637 // Representation of the 2D Quadratic elements
4638 //-------------------------------------------------
4639 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4640 popupMgr()->insert( action( SMESHOp::OpRepresentationLines ), anId, -1 );
4641 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), aMeshInVTK + "&& isVisible && isQuadratic",QtxPopupMgr::VisibleRule );
4642 popupMgr()->setRule( action( SMESHOp::OpRepresentationLines ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4644 popupMgr()->insert( action( SMESHOp::OpRepresentationArcs ), anId, -1 );
4645 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), aMeshInVTK + "&& isVisible && isQuadratic", QtxPopupMgr::VisibleRule );
4646 popupMgr()->setRule( action( SMESHOp::OpRepresentationArcs ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4648 //-------------------------------------------------
4649 // Orientation of faces
4650 //-------------------------------------------------
4651 popupMgr()->insert( action( SMESHOp::OpOrientationOnFaces ), -1, -1 );
4652 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4653 popupMgr()->setRule( action( SMESHOp::OpOrientationOnFaces ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4655 //-------------------------------------------------
4657 //-------------------------------------------------
4658 popupMgr()->insert( action( SMESHOp::OpProperties ), -1, -1 );
4659 popupMgr()->setRule( action( SMESHOp::OpProperties ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4661 //-------------------------------------------------
4663 //-------------------------------------------------
4664 popupMgr()->insert( action( SMESHOp::OpTransparency ), -1, -1 );
4665 popupMgr()->setRule( action( SMESHOp::OpTransparency ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4667 //-------------------------------------------------
4669 //-------------------------------------------------
4671 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4672 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4673 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4674 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4676 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4678 popupMgr()->insert( action( SMESHOp::OpReset ), anId, -1 ); // RESET
4679 popupMgr()->setRule( action( SMESHOp::OpReset ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4681 popupMgr()->insert( separator(), anId, -1 );
4683 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4685 popupMgr()->insert( action( SMESHOp::OpFreeNode ), aSubId, -1 );
4686 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4687 popupMgr()->setRule( action( SMESHOp::OpFreeNode ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4689 popupMgr()->insert ( action( SMESHOp::OpEqualNode ), aSubId, -1 );
4690 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4691 popupMgr()->setRule( action( SMESHOp::OpEqualNode ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4693 // popupMgr()->insert( action( SMESHOp::OpNodeConnectivityNb ), aSubId, -1 );
4694 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4695 // popupMgr()->setRule( action( SMESHOp::OpNodeConnectivityNb ), "controlMode = 'eNodeConnectivityNb'", QtxPopupMgr::ToggleRule );
4697 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4699 popupMgr()->insert( action( SMESHOp::OpFreeBorder ), aSubId, -1 );
4700 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), aMeshInVTK + "&&" + hasEdges + "&&" + hasFacesOrVolumes, QtxPopupMgr::VisibleRule );
4701 popupMgr()->setRule( action( SMESHOp::OpFreeBorder ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4703 popupMgr()->insert( action( SMESHOp::OpLength ), aSubId, -1 );
4704 popupMgr()->setRule( action( SMESHOp::OpLength ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4705 popupMgr()->setRule( action( SMESHOp::OpLength ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4707 popupMgr()->insert( action( SMESHOp::OpConnection ), aSubId, -1 );
4708 popupMgr()->setRule( action( SMESHOp::OpConnection ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4709 popupMgr()->setRule( action( SMESHOp::OpConnection ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4710 popupMgr()->insert ( action( SMESHOp::OpEqualEdge ), aSubId, -1 ); // EQUAL_EDGE
4711 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4712 popupMgr()->setRule( action( SMESHOp::OpEqualEdge ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4714 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4716 popupMgr()->insert( action( SMESHOp::OpFreeEdge ), aSubId, -1 );
4717 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4718 popupMgr()->setRule( action( SMESHOp::OpFreeEdge ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4720 popupMgr()->insert ( action( SMESHOp::OpFreeFace ), aSubId, -1 );
4721 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4722 QtxPopupMgr::VisibleRule );
4723 popupMgr()->setRule( action( SMESHOp::OpFreeFace ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4725 popupMgr()->insert ( action( SMESHOp::OpLength2D ), aSubId, -1 );
4726 popupMgr()->setRule( action( SMESHOp::OpLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4727 popupMgr()->setRule( action( SMESHOp::OpLength2D ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4729 popupMgr()->insert ( action( SMESHOp::OpConnection2D ), aSubId, -1 );
4730 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4731 popupMgr()->setRule( action( SMESHOp::OpConnection2D ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4733 popupMgr()->insert ( action( SMESHOp::OpArea ), aSubId, -1 );
4734 popupMgr()->setRule( action( SMESHOp::OpArea ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4735 popupMgr()->setRule( action( SMESHOp::OpArea ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4737 popupMgr()->insert ( action( SMESHOp::OpTaper ), aSubId, -1 );
4738 popupMgr()->setRule( action( SMESHOp::OpTaper ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4739 popupMgr()->setRule( action( SMESHOp::OpTaper ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4741 popupMgr()->insert ( action( SMESHOp::OpAspectRatio ), aSubId, -1 );
4742 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4743 popupMgr()->setRule( action( SMESHOp::OpAspectRatio ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4745 popupMgr()->insert ( action( SMESHOp::OpMinimumAngle ), aSubId, -1 );
4746 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4747 popupMgr()->setRule( action( SMESHOp::OpMinimumAngle ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4749 popupMgr()->insert ( action( SMESHOp::OpWarpingAngle ), aSubId, -1 );
4750 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4751 popupMgr()->setRule( action( SMESHOp::OpWarpingAngle ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4753 popupMgr()->insert ( action( SMESHOp::OpSkew ), aSubId, -1 );
4754 popupMgr()->setRule( action( SMESHOp::OpSkew ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4755 popupMgr()->setRule( action( SMESHOp::OpSkew ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4757 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength2D ), aSubId, -1 );
4758 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4759 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength2D ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4761 popupMgr()->insert ( action( SMESHOp::OpBareBorderFace ), aSubId, -1 );
4762 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4763 popupMgr()->setRule( action( SMESHOp::OpBareBorderFace ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4765 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedFace ), aSubId, -1 );
4766 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4767 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedFace ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4769 popupMgr()->insert ( action( SMESHOp::OpEqualFace ), aSubId, -1 );
4770 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4771 popupMgr()->setRule( action( SMESHOp::OpEqualFace ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4773 popupMgr()->insert ( action( SMESHOp::OpDeflection2D ), aSubId, -1 );
4774 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), aMeshInVtkHasFaces + " && hasGeomReference", QtxPopupMgr::VisibleRule );
4775 popupMgr()->setRule( action( SMESHOp::OpDeflection2D ), "controlMode = 'eDeflection2D'", QtxPopupMgr::ToggleRule );
4777 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4779 popupMgr()->insert ( action( SMESHOp::OpAspectRatio3D ), aSubId, -1 );
4780 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4781 popupMgr()->setRule( action( SMESHOp::OpAspectRatio3D ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4783 popupMgr()->insert ( action( SMESHOp::OpVolume ), aSubId, -1 );
4784 popupMgr()->setRule( action( SMESHOp::OpVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4785 popupMgr()->setRule( action( SMESHOp::OpVolume ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4787 popupMgr()->insert ( action( SMESHOp::OpMaxElementLength3D ), aSubId, -1 );
4788 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4789 popupMgr()->setRule( action( SMESHOp::OpMaxElementLength3D ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4791 popupMgr()->insert ( action( SMESHOp::OpBareBorderVolume ), aSubId, -1 );
4792 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4793 popupMgr()->setRule( action( SMESHOp::OpBareBorderVolume ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4795 popupMgr()->insert ( action( SMESHOp::OpOverConstrainedVolume ), aSubId, -1 );
4796 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4797 popupMgr()->setRule( action( SMESHOp::OpOverConstrainedVolume ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4799 popupMgr()->insert ( action( SMESHOp::OpEqualVolume ), aSubId, -1 );
4800 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4801 popupMgr()->setRule( action( SMESHOp::OpEqualVolume ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4803 popupMgr()->insert( separator(), anId, -1 );
4805 popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
4806 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4807 popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
4808 popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
4809 popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4811 popupMgr()->insert( separator(), anId, -1 );
4813 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4815 popupMgr()->insert( action( SMESHOp::OpSaveDistribution ), aSubId, -1 );
4816 popupMgr()->setRule( action( SMESHOp::OpSaveDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4818 popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
4819 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4820 popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
4822 #ifndef DISABLE_PLOT2DVIEWER
4823 popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
4824 popupMgr()->setRule( action( SMESHOp::OpPlotDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4827 //-------------------------------------------------
4829 //-------------------------------------------------
4830 popupMgr()->insert( separator(), -1, -1 );
4831 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4832 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4833 popupMgr()->insert( action( SMESHOp::OpShow ), -1, -1 );
4834 popupMgr()->setRule( action( SMESHOp::OpShow ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4836 popupMgr()->insert( action( SMESHOp::OpHide ), -1, -1 );
4837 popupMgr()->setRule( action( SMESHOp::OpHide ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4839 popupMgr()->insert( action( SMESHOp::OpShowOnly ), -1, -1 );
4840 popupMgr()->setRule( action( SMESHOp::OpShowOnly ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4842 popupMgr()->insert( separator(), -1, -1 );
4844 //-------------------------------------------------
4846 //-------------------------------------------------
4847 popupMgr()->insert( action( SMESHOp::OpClipping ), -1, -1 );
4848 popupMgr()->setRule( action( SMESHOp::OpClipping ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4850 popupMgr()->insert( separator(), -1, -1 );
4852 popupMgr()->insert( action( SMESHOp::OpSortChild ), -1, -1 );
4853 popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
4854 popupMgr()->insert( separator(), -1, -1 );
4856 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4857 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4859 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4860 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4863 //================================================================================
4865 * \brief Return true if SMESH or GEOM objects are selected.
4866 * Is called form LightApp_Module::activateModule() which clear selection if
4867 * not isSelectionCompatible()
4869 //================================================================================
4871 bool SMESHGUI::isSelectionCompatible()
4873 bool isCompatible = true;
4874 SALOME_ListIO selected;
4875 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4876 Sel->selectedObjects( selected );
4878 SALOME_ListIteratorOfListIO It( selected );
4879 for ( ; isCompatible && It.More(); It.Next())
4881 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4882 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4884 return isCompatible;
4888 bool SMESHGUI::reusableOperation( const int id )
4890 // compute, evaluate and precompute are not reusable operations
4891 return ( id == SMESHOp::OpCompute || id == SMESHOp::OpPreCompute || id == SMESHOp::OpEvaluate ) ? false : SalomeApp_Module::reusableOperation( id );
4894 bool SMESHGUI::activateModule( SUIT_Study* study )
4896 bool res = SalomeApp_Module::activateModule( study );
4898 setMenuShown( true );
4899 setToolShown( true );
4901 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4902 PyGILState_STATE gstate = PyGILState_Ensure();
4903 PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4904 if ( !pluginsmanager ) {
4908 PyObject* result = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toUtf8().data(),tr("SMESH_PLUGINS_OTHER").toUtf8().data());
4913 PyGILState_Release(gstate);
4914 // end of SMESH plugins loading
4916 // Reset actions accelerator keys
4917 action(SMESHOp::OpDelete)->setEnabled(true); // Delete: Key_Delete
4919 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4920 GetSMESHGen()->UpdateStudy();
4922 // get all view currently opened in the study and connect their signals to
4923 // the corresponding slots of the class.
4924 SUIT_Desktop* aDesk = study->application()->desktop();
4926 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4927 SUIT_ViewWindow* wnd;
4928 foreach ( wnd, wndList )
4932 Py_XDECREF(pluginsmanager);
4936 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4938 setMenuShown( false );
4939 setToolShown( false );
4941 EmitSignalCloseAllDialogs();
4943 // Unset actions accelerator keys
4944 action(SMESHOp::OpDelete)->setEnabled(false); // Delete: Key_Delete
4946 return SalomeApp_Module::deactivateModule( study );
4949 void SMESHGUI::studyClosed( SUIT_Study* s )
4953 SMESH::RemoveVisuData();
4954 SalomeApp_Module::studyClosed( s );
4957 void SMESHGUI::OnGUIEvent()
4959 const QObject* obj = sender();
4960 if ( !obj || !obj->inherits( "QAction" ) )
4962 int id = actionId((QAction*)obj);
4967 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4969 if ( CORBA::is_nil( myComponentSMESH ) )
4971 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4972 return aGUI.myComponentSMESH;
4974 return myComponentSMESH;
4977 QString SMESHGUI::engineIOR() const
4979 CORBA::ORB_var anORB = getApp()->orb();
4980 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4981 return QString( anIOR.in() );
4984 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4986 SalomeApp_Module::contextMenuPopup( client, menu, title );
4988 selectionMgr()->selectedObjects( lst );
4989 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4990 Handle(SALOME_InteractiveObject) io = lst.First();
4991 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4992 _PTR(Study) study = appStudy->studyDS();
4993 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4995 QString aName = SMESH::fromUtf8( obj->GetName());
4996 while ( !aName.isEmpty() && aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4997 aName.remove(( aName.length() - 1 ), 1 );
5003 LightApp_Selection* SMESHGUI::createSelection() const
5005 return new SMESHGUI_Selection();
5008 void SMESHGUI::windows( QMap<int, int>& aMap ) const
5010 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
5011 aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea );
5012 #ifndef DISABLE_PYCONSOLE
5013 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
5017 void SMESHGUI::viewManagers( QStringList& list ) const
5019 list.append( SVTK_Viewer::Type() );
5022 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
5024 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
5025 SMESH::UpdateSelectionProp( this );
5027 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
5028 for(int i = 0; i < aViews.count() ; i++){
5029 SUIT_ViewWindow *sf = aViews[i];
5032 EmitSignalActivatedViewManager();
5036 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
5038 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
5039 myClippingPlaneInfoMap.erase( theViewManager );
5042 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
5044 theActor->AddObserver( SMESH::DeleteActorEvent,
5045 myEventCallbackCommand.GetPointer(),
5049 void SMESHGUI::ProcessEvents( vtkObject* theObject,
5050 unsigned long theEvent,
5051 void* theClientData,
5054 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
5055 if( theObject && (int) theEvent == SMESH::DeleteActorEvent ) {
5056 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
5057 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
5058 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
5059 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
5060 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
5061 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
5062 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
5063 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
5064 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
5065 SMESH::TActorList::iterator anIter3 = anActorList.begin();
5066 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
5067 if( anActor == *anIter3 ) {
5068 anActorList.erase( anIter3 );
5079 void SMESHGUI::createPreferences()
5081 // General tab ------------------------------------------------------------------------
5082 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
5084 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
5085 setPreferenceProperty( autoUpdate, "columns", 2 );
5086 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
5087 setPreferenceProperty( lim, "min", 0 );
5088 setPreferenceProperty( lim, "max", 100000000 );
5089 setPreferenceProperty( lim, "step", 1000 );
5090 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5091 addPreference( tr( "PREF_INCREMENTAL_LIMIT" ), autoUpdate, LightApp_Preferences::Bool, "SMESH", "incremental_limit" );
5093 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE_GROUP" ), genTab );
5094 setPreferenceProperty( dispgroup, "columns", 2 );
5096 addPreference( tr( "PREF_FITALL_ON_DISPLAYONLY" ), dispgroup, LightApp_Preferences::Bool, "SMESH", "fitall_on_displayonly" );
5098 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
5100 modes.append( tr("MEN_WIRE") );
5101 modes.append( tr("MEN_SHADE") );
5102 modes.append( tr("MEN_NODES") );
5103 modes.append( tr("MEN_SHRINK") );
5104 QList<QVariant> indices;
5105 indices.append( 0 );
5106 indices.append( 1 );
5107 indices.append( 2 );
5108 indices.append( 3 );
5109 setPreferenceProperty( dispmode, "strings", modes );
5110 setPreferenceProperty( dispmode, "indexes", indices );
5112 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE_GROUP" ), genTab );
5113 setPreferenceProperty( arcgroup, "columns", 2 );
5114 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
5115 QStringList quadraticModes;
5116 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
5117 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
5119 indices.append( 0 );
5120 indices.append( 1 );
5121 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
5122 setPreferenceProperty( quadraticmode, "indexes", indices );
5124 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
5125 "SMESH", "max_angle" );
5126 setPreferenceProperty( maxAngle, "min", 1 );
5127 setPreferenceProperty( maxAngle, "max", 90 );
5129 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
5130 setPreferenceProperty( qaGroup, "columns", 2 );
5131 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
5132 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
5133 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
5134 setPreferenceProperty( prec, "min", 0 );
5135 setPreferenceProperty( prec, "max", 100 );
5136 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
5137 setPreferenceProperty( doubleNodesTol, "precision", 10 );
5138 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
5139 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
5140 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
5143 int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment");
5144 setPreferenceProperty( cinc, "min", 0 );
5145 setPreferenceProperty( cinc, "max", 5 );
5148 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
5149 setPreferenceProperty( exportgroup, "columns", 2 );
5150 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
5151 addPreference( tr( "PREF_SHOW_WARN" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "show_warning" );
5152 int zTol = addPreference( tr( "PREF_ZTOLERANCE" ), exportgroup, LightApp_Preferences::DblSpin, "SMESH", "med_ztolerance" );
5153 setPreferenceProperty( zTol, "precision", 10 );
5154 setPreferenceProperty( zTol, "min", 0.0000000001 );
5155 setPreferenceProperty( zTol, "max", 1000000.0 );
5156 setPreferenceProperty( zTol, "step", 1. );
5157 //addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
5159 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
5160 setPreferenceProperty( computeGroup, "columns", 2 );
5161 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
5163 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
5164 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
5165 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
5167 indices.append( 0 );
5168 indices.append( 1 );
5169 indices.append( 2 );
5170 setPreferenceProperty( notifyMode, "strings", modes );
5171 setPreferenceProperty( notifyMode, "indexes", indices );
5173 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
5174 setPreferenceProperty( infoGroup, "columns", 2 );
5175 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
5177 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
5178 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
5180 indices.append( 0 );
5181 indices.append( 1 );
5182 setPreferenceProperty( elemInfo, "strings", modes );
5183 setPreferenceProperty( elemInfo, "indexes", indices );
5184 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
5185 setPreferenceProperty( nodesLim, "min", 0 );
5186 setPreferenceProperty( nodesLim, "max", 10000000 );
5187 setPreferenceProperty( nodesLim, "step", 10000 );
5188 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5189 int ctrlLim = addPreference( tr( "PREF_CTRL_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_controls_limit" );
5190 setPreferenceProperty( ctrlLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
5191 setPreferenceProperty( ctrlLim, "min", 0 );
5192 setPreferenceProperty( ctrlLim, "max", 10000000 );
5193 setPreferenceProperty( ctrlLim, "step", 1000 );
5194 addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
5195 addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
5196 addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
5197 addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
5198 addPreference( tr( "PREF_DUMP_CTRL_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_ctrl" );
5200 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
5201 setPreferenceProperty( segGroup, "columns", 2 );
5202 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
5203 "SMESH", "segmentation" );
5204 setPreferenceProperty( segLen, "min", 1 );
5205 setPreferenceProperty( segLen, "max", 10000000 );
5206 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
5207 "SMESH", "nb_segments_per_edge" );
5208 setPreferenceProperty( nbSeg, "min", 1 );
5209 setPreferenceProperty( nbSeg, "max", 10000000 );
5211 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
5212 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
5213 "SMESH", "forget_mesh_on_hyp_modif" );
5216 // Quantities with individual precision settings
5217 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
5218 setPreferenceProperty( precGroup, "columns", 2 );
5220 const int nbQuantities = 6;
5221 int precs[nbQuantities], ii = 0;
5222 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
5223 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
5224 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
5225 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
5226 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
5227 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
5228 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
5229 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
5230 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
5231 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
5232 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
5233 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
5235 // Set property for precision value for spinboxes
5236 for ( ii = 0; ii < nbQuantities; ii++ ){
5237 setPreferenceProperty( precs[ii], "min", -14 );
5238 setPreferenceProperty( precs[ii], "max", 14 );
5239 setPreferenceProperty( precs[ii], "precision", 2 );
5242 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
5243 setPreferenceProperty( previewGroup, "columns", 2 );
5244 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
5245 setPreferenceProperty( chunkSize, "min", 1 );
5246 setPreferenceProperty( chunkSize, "max", 1000 );
5247 setPreferenceProperty( chunkSize, "step", 50 );
5249 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
5250 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
5252 // Mesh tab ------------------------------------------------------------------------
5253 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
5254 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
5255 setPreferenceProperty( nodeGroup, "columns", 3 );
5257 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
5259 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
5261 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5262 QList<QVariant> aMarkerTypeIndicesList;
5263 QList<QVariant> aMarkerTypeIconsList;
5264 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
5265 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
5266 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
5267 aMarkerTypeIndicesList << i;
5268 aMarkerTypeIconsList << pixmap;
5270 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
5271 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
5273 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
5275 QList<QVariant> aMarkerScaleIndicesList;
5276 QStringList aMarkerScaleValuesList;
5277 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
5278 aMarkerScaleIndicesList << i;
5279 //aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
5280 aMarkerScaleValuesList << QString::number( i );
5282 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
5283 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
5285 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
5286 //setPreferenceProperty( elemGroup, "columns", 2 );
5288 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
5289 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
5290 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
5291 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
5292 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
5293 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
5294 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
5295 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
5296 addPreference( tr( "PREF_PREVIEW_COLOR" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "preview_color" );
5299 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
5300 setPreferenceProperty( grpGroup, "columns", 2 );
5302 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
5303 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
5305 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
5306 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
5307 /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
5308 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
5309 double ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
5310 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_diameter");
5311 double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
5312 LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
5313 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
5314 LightApp_Preferences::IntSpin, "SMESH", "element_width");
5315 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
5316 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
5317 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
5318 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
5320 setPreferenceProperty( size0d, "min", 1 );
5321 setPreferenceProperty( size0d, "max", 10 );
5323 // setPreferenceProperty( ballSize, "min", 1 );
5324 // setPreferenceProperty( ballSize, "max", 10 );
5326 setPreferenceProperty( ballDiameter, "min", 1e-7 );
5327 setPreferenceProperty( ballDiameter, "max", 1e9 );
5328 setPreferenceProperty( ballDiameter, "step", 0.1 );
5330 setPreferenceProperty( ballScale, "min", 1e-2 );
5331 setPreferenceProperty( ballScale, "max", 1e7 );
5332 setPreferenceProperty( ballScale, "step", 0.5 );
5334 setPreferenceProperty( elemW, "min", 1 );
5335 setPreferenceProperty( elemW, "max", 5 );
5337 setPreferenceProperty( outW, "min", 1 );
5338 setPreferenceProperty( outW, "max", 5 );
5340 setPreferenceProperty( shrink, "min", 0 );
5341 setPreferenceProperty( shrink, "max", 100 );
5343 int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
5344 setPreferenceProperty( numGroup, "columns", 2 );
5346 addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
5347 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
5349 addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
5350 addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
5352 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
5353 setPreferenceProperty( orientGroup, "columns", 1 );
5355 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
5356 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
5358 setPreferenceProperty( orientScale, "min", 0.05 );
5359 setPreferenceProperty( orientScale, "max", 0.5 );
5360 setPreferenceProperty( orientScale, "step", 0.05 );
5362 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
5364 // Selection tab ------------------------------------------------------------------------
5365 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
5367 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
5368 setPreferenceProperty( selGroup, "columns", 2 );
5370 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
5371 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
5373 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
5374 setPreferenceProperty( preGroup, "columns", 2 );
5376 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
5378 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
5379 setPreferenceProperty( precSelGroup, "columns", 2 );
5381 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
5382 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
5383 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
5385 int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment");
5386 setPreferenceProperty( sinc, "min", 0 );
5387 setPreferenceProperty( sinc, "max", 5 );
5389 // Scalar Bar tab ------------------------------------------------------------------------
5390 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
5391 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
5392 setPreferenceProperty( fontGr, "columns", 2 );
5394 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
5395 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
5397 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
5398 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
5400 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
5401 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
5403 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
5404 setPreferenceProperty( numcol, "min", 2 );
5405 setPreferenceProperty( numcol, "max", 256 );
5407 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
5408 setPreferenceProperty( numlab, "min", 2 );
5409 setPreferenceProperty( numlab, "max", 65 );
5411 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
5412 setPreferenceProperty( orientGr, "columns", 2 );
5413 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
5414 QStringList orients;
5415 orients.append( tr( "SMESH_VERTICAL" ) );
5416 orients.append( tr( "SMESH_HORIZONTAL" ) );
5417 indices.clear(); indices.append( 0 ); indices.append( 1 );
5418 setPreferenceProperty( orient, "strings", orients );
5419 setPreferenceProperty( orient, "indexes", indices );
5421 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
5422 setPreferenceProperty( posVSizeGr, "columns", 2 );
5423 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
5424 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
5425 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
5426 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
5427 setPreferenceProperty( xv, "step", 0.1 );
5428 setPreferenceProperty( xv, "min", 0.0 );
5429 setPreferenceProperty( xv, "max", 1.0 );
5430 setPreferenceProperty( yv, "step", 0.1 );
5431 setPreferenceProperty( yv, "min", 0.0 );
5432 setPreferenceProperty( yv, "max", 1.0 );
5433 setPreferenceProperty( wv, "step", 0.1 );
5434 setPreferenceProperty( wv, "min", 0.0 );
5435 setPreferenceProperty( wv, "max", 1.0 );
5436 setPreferenceProperty( hv, "min", 0.0 );
5437 setPreferenceProperty( hv, "max", 1.0 );
5438 setPreferenceProperty( hv, "step", 0.1 );
5440 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
5441 setPreferenceProperty( posHSizeGr, "columns", 2 );
5442 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
5443 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
5444 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
5445 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
5446 setPreferenceProperty( xv, "min", 0.0 );
5447 setPreferenceProperty( xv, "max", 1.0 );
5448 setPreferenceProperty( xv, "step", 0.1 );
5449 setPreferenceProperty( xh, "min", 0.0 );
5450 setPreferenceProperty( xh, "max", 1.0 );
5451 setPreferenceProperty( xh, "step", 0.1 );
5452 setPreferenceProperty( yh, "min", 0.0 );
5453 setPreferenceProperty( yh, "max", 1.0 );
5454 setPreferenceProperty( yh, "step", 0.1 );
5455 setPreferenceProperty( wh, "min", 0.0 );
5456 setPreferenceProperty( wh, "max", 1.0 );
5457 setPreferenceProperty( wh, "step", 0.1 );
5458 setPreferenceProperty( hh, "min", 0.0 );
5459 setPreferenceProperty( hh, "max", 1.0 );
5460 setPreferenceProperty( hh, "step", 0.1 );
5462 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
5463 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
5464 setPreferenceProperty( distributionGr, "columns", 3 );
5466 types.append( tr( "SMESH_MONOCOLOR" ) );
5467 types.append( tr( "SMESH_MULTICOLOR" ) );
5468 indices.clear(); indices.append( 0 ); indices.append( 1 );
5469 setPreferenceProperty( coloringType, "strings", types );
5470 setPreferenceProperty( coloringType, "indexes", indices );
5471 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
5475 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
5477 if ( sect=="SMESH" ) {
5478 float sbX1 = 0.01, sbY1 = 0.01, sbW = 0.08, sbH = 0.08;
5479 float aTol = 1.00000009999999;
5480 std::string aWarning;
5481 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
5483 if ( name == "selection_object_color" ||
5484 name == "selection_element_color" ||
5485 name == "highlight_color" ||
5486 name == "selection_precision_node" ||
5487 name == "selection_precision_element" ||
5488 name == "selection_precision_object" ||
5489 name == "selection_increment")
5491 SMESH::UpdateSelectionProp( this );
5493 else if (name == "scalar_bar_vertical_x" || name == "scalar_bar_vertical_width")
5495 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
5496 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
5497 if ( sbX1+sbW > aTol ) {
5498 aWarning = "Origin and Size Vertical: X+Width > 1\n";
5501 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
5502 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
5505 else if (name == "scalar_bar_vertical_y" || name == "scalar_bar_vertical_height" )
5507 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
5508 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
5509 if ( sbY1 + sbH > aTol ) {
5510 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
5511 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
5512 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
5515 else if (name == "scalar_bar_horizontal_x" || name == "scalar_bar_horizontal_width")
5517 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5518 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5519 if ( sbX1 + sbW > aTol ) {
5520 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5523 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5524 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5527 else if (name == "scalar_bar_horizontal_y" || name == "scalar_bar_horizontal_height")
5529 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5530 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5531 if ( sbY1 + sbH > aTol ) {
5532 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5535 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5536 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5539 else if ( name == "segmentation" )
5541 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5542 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5544 else if ( name == "nb_segments_per_edge" )
5546 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5547 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5549 else if ( name == "historical_python_dump" || name == "forget_mesh_on_hyp_modif" || name == "default_grp_color" )
5551 QString val = aResourceMgr->stringValue( "SMESH", name );
5552 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5554 else if ( name == "numbering_node_color" || name == "numbering_node_font" )
5556 SMESH::UpdateFontProp( this );
5558 else if ( name == "numbering_elem_color" || name == "numbering_elem_font" )
5560 SMESH::UpdateFontProp( this );
5563 if ( aWarning.size() != 0 ) {
5564 aWarning += "The default values are applied instead.";
5565 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5566 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5567 QObject::tr(aWarning.c_str()));
5572 //================================================================================
5574 * \brief Update something in accordance with update flags
5575 * \param theFlags - update flags
5577 * Update viewer or/and object browser etc. in accordance with update flags ( see
5578 * LightApp_UpdateFlags enumeration ).
5580 //================================================================================
5581 void SMESHGUI::update( const int flags )
5583 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5584 SMESH::UpdateView();
5586 SalomeApp_Module::update( flags );
5589 //================================================================================
5591 * \brief Set default selection mode
5593 * SLOT called when operation committed. Sets default selection mode
5595 //================================================================================
5596 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5598 SVTK_ViewWindow* vtkWnd =
5599 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5601 vtkWnd->SetSelectionMode( ActorSelection );
5604 //================================================================================
5606 * \brief Set default selection mode
5608 * SLOT called when operation aborted. Sets default selection mode
5610 //================================================================================
5611 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5613 SVTK_ViewWindow* vtkWnd =
5614 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5616 vtkWnd->SetSelectionMode( ActorSelection );
5619 //================================================================================
5621 * \brief Creates operation with given identifier
5622 * \param id - identifier of operation to be started
5623 * \return Pointer on created operation or NULL if operation is not created
5625 * Virtual method redefined from the base class creates operation with given id.
5626 * It is called called automatically from startOperation method of base class.
5628 //================================================================================
5629 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5631 LightApp_Operation* op = 0;
5632 // to do : create operation here
5635 case SMESHOp::OpSplitBiQuadratic:
5636 op = new SMESHGUI_SplitBiQuadOp();
5638 case SMESHOp::OpConvertMeshToQuadratic:
5639 op = new SMESHGUI_ConvToQuadOp();
5641 case SMESHOp::OpCreateBoundaryElements: // create 2D mesh as boundary on 3D
5642 op = new SMESHGUI_Make2DFrom3DOp();
5644 case SMESHOp::OpReorientFaces:
5645 op = new SMESHGUI_ReorientFacesOp();
5647 case SMESHOp::OpCreateMesh:
5648 op = new SMESHGUI_MeshOp( true, true );
5650 case SMESHOp::OpCreateSubMesh:
5651 op = new SMESHGUI_MeshOp( true, false );
5653 case SMESHOp::OpEditMeshOrSubMesh:
5654 case SMESHOp::OpEditMesh:
5655 case SMESHOp::OpEditSubMesh:
5656 op = new SMESHGUI_MeshOp( false );
5658 case SMESHOp::OpCompute:
5659 case SMESHOp::OpComputeSubMesh:
5660 op = new SMESHGUI_ComputeOp();
5662 case SMESHOp::OpPreCompute:
5663 op = new SMESHGUI_PrecomputeOp();
5665 case SMESHOp::OpEvaluate:
5666 op = new SMESHGUI_EvaluateOp();
5668 case SMESHOp::OpMeshOrder:
5669 op = new SMESHGUI_MeshOrderOp();
5671 case SMESHOp::OpCreateGeometryGroup:
5672 op = new SMESHGUI_GroupOnShapeOp();
5674 case SMESHOp::OpFindElementByPoint:
5675 op = new SMESHGUI_FindElemByPointOp();
5677 case SMESHOp::OpMoveNode: // Make mesh pass through point
5678 op = new SMESHGUI_MakeNodeAtPointOp();
5680 case SMESHOp::OpElem0DOnElemNodes: // Create 0D elements on all nodes
5681 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5688 op = SalomeApp_Module::createOperation( id );
5692 //================================================================================
5694 * \brief Stops current operations and starts a given one
5695 * \param id - The id of the operation to start
5697 //================================================================================
5699 void SMESHGUI::switchToOperation(int id)
5701 activeStudy()->abortAllOperations();
5702 startOperation( id );
5705 LightApp_Displayer* SMESHGUI::displayer()
5708 myDisplayer = new SMESHGUI_Displayer( getApp() );
5712 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5715 int aTolerance = 64;
5716 int anIterations = 0;
5722 if( anIterations % aPeriod == 0 )
5725 if( aTolerance < 1 )
5729 aHue = (int)( 360.0 * rand() / RAND_MAX );
5732 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5733 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5734 for( ; it != itEnd; ++it )
5736 SALOMEDS::Color anAutoColor = *it;
5737 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5740 aQColor.getHsv( &h, &s, &v );
5741 if( abs( h - aHue ) < aTolerance )
5753 aColor.setHsv( aHue, 255, 255 );
5755 SALOMEDS::Color aSColor;
5756 aSColor.R = aColor.redF();
5757 aSColor.G = aColor.greenF();
5758 aSColor.B = aColor.blueF();
5763 const char* gSeparator = "_"; // character used to separate parameter names
5764 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5765 const char* gPathSep = "|"; // character used to separate paths
5768 * \brief Store visual parameters
5770 * This method is called just before the study document is saved.
5771 * Store visual parameters in AttributeParameter attribute(s)
5773 void SMESHGUI::storeVisualParameters (int savePoint)
5776 Kernel_Utils::Localizer loc;
5778 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5779 if (!appStudy || !appStudy->studyDS())
5781 _PTR(Study) studyDS = appStudy->studyDS();
5783 // componentName is used for encoding of entries when storing them in IParameters
5784 std::string componentName = myComponentSMESH->ComponentDataType();
5785 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5786 //if (!aSComponent) return;
5789 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5790 componentName.c_str(),
5792 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5794 // store custom markers
5795 if( !myMarkerMap.empty() )
5797 VTK::MarkerMap::const_iterator anIter = myMarkerMap.begin();
5798 for( ; anIter != myMarkerMap.end(); anIter++ )
5800 int anId = anIter->first;
5801 VTK::MarkerData aMarkerData = anIter->second;
5802 std::string aMarkerFileName = aMarkerData.first;
5803 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5804 if( aMarkerTexture.size() < 3 )
5805 continue; // should contain at least width, height and the first value
5807 QString aPropertyName( "texture" );
5808 aPropertyName += gSeparator;
5809 aPropertyName += QString::number( anId );
5811 QString aPropertyValue = aMarkerFileName.c_str();
5812 aPropertyValue += gPathSep;
5814 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5815 ushort aWidth = *aTextureIter++;
5816 ushort aHeight = *aTextureIter++;
5817 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5818 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5819 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5820 aPropertyValue += QString::number( *aTextureIter );
5822 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5826 // viewers counters are used for storing view_numbers in IParameters
5829 // main cycle to store parameters of displayed objects
5830 QList<SUIT_ViewManager*> lst;
5831 QList<SUIT_ViewManager*>::Iterator it;
5832 getApp()->viewManagers(lst);
5833 for (it = lst.begin(); it != lst.end(); it++)
5835 SUIT_ViewManager* vman = *it;
5836 QString vType = vman->getType();
5838 // saving VTK actors properties
5839 if (vType == SVTK_Viewer::Type())
5841 // store the clipping planes attached to the view manager
5842 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5843 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5844 if( anIter != myClippingPlaneInfoMap.end() )
5845 aClippingPlaneInfoList = anIter->second;
5847 if( !aClippingPlaneInfoList.empty() ) {
5848 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5849 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5851 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5852 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5854 QString aPropertyName( "ClippingPlane" );
5855 aPropertyName += gSeparator;
5856 aPropertyName += QString::number( vtkViewers );
5857 aPropertyName += gSeparator;
5858 aPropertyName += QString::number( anId );
5860 QString aPropertyValue = QString::number( (int)aPlane->PlaneMode ).toLatin1().constData();
5861 aPropertyValue += gDigitsSep;
5862 aPropertyValue += QString::number( aPlane->IsOpenGLClipping ).toLatin1().constData();
5863 aPropertyValue += gDigitsSep;
5864 if ( aPlane->PlaneMode == SMESH::Absolute ) {
5865 aPropertyValue += QString::number( aPlane->myAbsoluteOrientation ).toLatin1().constData();
5866 aPropertyValue += gDigitsSep;
5867 aPropertyValue += QString::number( aPlane->X ).toLatin1().constData();
5868 aPropertyValue += gDigitsSep;
5869 aPropertyValue += QString::number( aPlane->Y ).toLatin1().constData();
5870 aPropertyValue += gDigitsSep;
5871 aPropertyValue += QString::number( aPlane->Z ).toLatin1().constData();
5872 aPropertyValue += gDigitsSep;
5873 aPropertyValue += QString::number( aPlane->Dx ).toLatin1().constData();
5874 aPropertyValue += gDigitsSep;
5875 aPropertyValue += QString::number( aPlane->Dy ).toLatin1().constData();
5876 aPropertyValue += gDigitsSep;
5877 aPropertyValue += QString::number( aPlane->Dz ).toLatin1().constData();
5879 else if ( aPlane->PlaneMode == SMESH::Relative ) {
5880 aPropertyValue += QString::number( (int)aPlane->myRelativeOrientation ).toLatin1().constData();
5881 aPropertyValue += gDigitsSep;
5882 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5883 aPropertyValue += gDigitsSep;
5884 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5885 aPropertyValue += gDigitsSep;
5886 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5889 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5893 QVector<SUIT_ViewWindow*> views = vman->getViews();
5894 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5896 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5898 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5899 vtkActorCollection* allActors = aCopy.GetActors();
5900 allActors->InitTraversal();
5901 while (vtkActor* actor = allActors->GetNextActor())
5903 if (actor->GetVisibility()) // store only visible actors
5905 SMESH_Actor* aSmeshActor = 0;
5906 if (actor->IsA("SMESH_Actor"))
5907 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5908 if (aSmeshActor && aSmeshActor->hasIO())
5910 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5913 // entry is "encoded" = it does NOT contain component address,
5914 // since it is a subject to change on next component loading
5915 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5917 std::string param, vtkParam = vType.toLatin1().data();
5918 vtkParam += gSeparator;
5919 vtkParam += QString::number(vtkViewers).toLatin1().data();
5920 vtkParam += gSeparator;
5923 param = vtkParam + "Visibility";
5924 ip->setParameter(entry, param, "On");
5927 param = vtkParam + "Representation";
5928 ip->setParameter(entry, param, QString::number
5929 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5932 param = vtkParam + "IsShrunk";
5933 ip->setParameter(entry, param, QString::number
5934 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5936 // Displayed entities
5937 unsigned int aMode = aSmeshActor->GetEntityMode();
5938 bool isE = aMode & SMESH_Actor::eEdges;
5939 bool isF = aMode & SMESH_Actor::eFaces;
5940 bool isV = aMode & SMESH_Actor::eVolumes;
5941 bool is0d = aMode & SMESH_Actor::e0DElements;
5942 bool isB = aMode & SMESH_Actor::eBallElem;
5944 QString modeStr ("e");
5945 modeStr += gDigitsSep; modeStr += QString::number(isE);
5946 modeStr += gDigitsSep; modeStr += "f";
5947 modeStr += gDigitsSep; modeStr += QString::number(isF);
5948 modeStr += gDigitsSep; modeStr += "v";
5949 modeStr += gDigitsSep; modeStr += QString::number(isV);
5950 modeStr += gDigitsSep; modeStr += "0d";
5951 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5952 modeStr += gDigitsSep; modeStr += "b";
5953 modeStr += gDigitsSep; modeStr += QString::number(isB);
5955 param = vtkParam + "Entities";
5956 ip->setParameter(entry, param, modeStr.toLatin1().data());
5962 aSmeshActor->GetSufaceColor(r, g, b, delta);
5963 QStringList colorStr;
5964 colorStr << "surface";
5965 colorStr << QString::number(r);
5966 colorStr << QString::number(g);
5967 colorStr << QString::number(b);
5969 colorStr << "backsurface";
5970 colorStr << QString::number(delta);
5972 aSmeshActor->GetVolumeColor(r, g, b, delta);
5973 colorStr << "volume";
5974 colorStr << QString::number(r);
5975 colorStr << QString::number(g);
5976 colorStr << QString::number(b);
5977 colorStr << QString::number(delta);
5979 aSmeshActor->GetEdgeColor(r, g, b);
5981 colorStr << QString::number(r);
5982 colorStr << QString::number(g);
5983 colorStr << QString::number(b);
5985 aSmeshActor->GetNodeColor(r, g, b);
5987 colorStr << QString::number(r);
5988 colorStr << QString::number(g);
5989 colorStr << QString::number(b);
5991 aSmeshActor->GetOutlineColor(r, g, b);
5992 colorStr << "outline";
5993 colorStr << QString::number(r);
5994 colorStr << QString::number(g);
5995 colorStr << QString::number(b);
5997 aSmeshActor->Get0DColor(r, g, b);
5998 colorStr << "elem0d";
5999 colorStr << QString::number(r);
6000 colorStr << QString::number(g);
6001 colorStr << QString::number(b);
6003 aSmeshActor->GetBallColor(r, g, b);
6005 colorStr << QString::number(r);
6006 colorStr << QString::number(g);
6007 colorStr << QString::number(b);
6009 aSmeshActor->GetFacesOrientationColor(r, g, b);
6010 colorStr << "orientation";
6011 colorStr << QString::number(r);
6012 colorStr << QString::number(g);
6013 colorStr << QString::number(b);
6015 param = vtkParam + "Colors";
6016 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
6019 QStringList sizeStr;
6021 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
6022 sizeStr << "outline";
6023 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
6024 sizeStr << "elem0d";
6025 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
6027 //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
6028 sizeStr << QString::number((double)aSmeshActor->GetBallSize());
6029 sizeStr << QString::number((double)aSmeshActor->GetBallScale());
6030 sizeStr << "shrink";
6031 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
6032 sizeStr << "orientation";
6033 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
6034 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
6036 param = vtkParam + "Sizes";
6037 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
6042 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
6043 if( aMarkerType == VTK::MT_USER ) {
6044 markerStr += "custom";
6045 markerStr += gDigitsSep;
6046 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
6050 markerStr += gDigitsSep;
6051 markerStr += QString::number( (int)aMarkerType );
6052 markerStr += gDigitsSep;
6053 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
6056 param = vtkParam + "PointMarker";
6057 ip->setParameter(entry, param, markerStr.toLatin1().data());
6060 param = vtkParam + "Opacity";
6061 ip->setParameter(entry, param,
6062 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
6065 param = vtkParam + "ClippingPlane";
6067 if( !aClippingPlaneInfoList.empty() ) {
6068 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
6069 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
6071 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
6072 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
6073 SMESH::TActorList::iterator anIter2 = anActorList.begin();
6074 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
6075 if( aSmeshActor == *anIter2 ) {
6076 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
6077 QString::number( anId ).toLatin1().constData() );
6084 ip->setParameter( entry, param, "Off" );
6085 } // if (io->hasEntry())
6086 } // SMESH_Actor && hasIO
6088 } // while.. actors traversal
6092 } // if (SVTK view model)
6093 } // for (viewManagers)
6096 // data structures for clipping planes processing
6100 bool isOpenGLClipping;
6101 vtkIdType RelativeOrientation;
6104 int AbsoluteOrientation;
6105 double X, Y, Z, Dx, Dy, Dz;
6107 typedef std::list<TPlaneData> TPlaneDataList;
6108 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
6110 typedef std::list<vtkActor*> TActorList;
6113 TActorList ActorList;
6114 SUIT_ViewManager* ViewManager;
6116 typedef std::list<TPlaneInfo> TPlaneInfoList;
6117 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
6120 * \brief Restore visual parameters
6122 * This method is called after the study document is opened.
6123 * Restore visual parameters from AttributeParameter attribute(s)
6125 void SMESHGUI::restoreVisualParameters (int savePoint)
6128 Kernel_Utils::Localizer loc;
6130 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
6131 if (!appStudy || !appStudy->studyDS())
6133 _PTR(Study) studyDS = appStudy->studyDS();
6135 // componentName is used for encoding of entries when storing them in IParameters
6136 std::string componentName = myComponentSMESH->ComponentDataType();
6137 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
6138 //if (!aSComponent) return;
6141 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
6142 componentName.c_str(),
6144 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
6146 // restore custom markers and map of clipping planes
6147 TPlaneDataMap aPlaneDataMap;
6149 std::vector<std::string> properties = ip->getProperties();
6150 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
6152 std::string property = *propIt;
6153 QString aPropertyName( property.c_str() );
6154 QString aPropertyValue( ip->getProperty( property ).c_str() );
6156 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
6157 if( aPropertyNameList.isEmpty() )
6160 QString aPropertyType = aPropertyNameList[0];
6161 if( aPropertyType == "texture" )
6163 if( aPropertyNameList.size() != 2 )
6167 int anId = aPropertyNameList[1].toInt( &ok );
6168 if( !ok || anId < 1 )
6171 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
6172 if( aPropertyValueList.size() != 2 )
6175 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
6176 QString aMarkerTextureString = aPropertyValueList[1];
6177 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
6178 if( aMarkerTextureStringList.size() != 3 )
6182 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
6187 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
6191 VTK::MarkerTexture aMarkerTexture;
6192 aMarkerTexture.push_back( aWidth );
6193 aMarkerTexture.push_back( aHeight );
6195 QString aMarkerTextureData = aMarkerTextureStringList[2];
6196 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
6198 QChar aChar = aMarkerTextureData.at( i );
6199 if( aChar.isDigit() )
6200 aMarkerTexture.push_back( aChar.digitValue() );
6203 myMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
6205 else if( aPropertyType == "ClippingPlane" )
6207 if( aPropertyNameList.size() != 3 )
6211 int aViewId = aPropertyNameList[1].toInt( &ok );
6212 if( !ok || aViewId < 0 )
6216 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
6217 if( !ok || aClippingPlaneId < 0 )
6220 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
6221 if( aPropertyValueList.size() != 6 && aPropertyValueList.size() != 9 )
6224 TPlaneData aPlaneData;
6225 aPlaneData.AbsoluteOrientation = false;
6226 aPlaneData.RelativeOrientation = 0;
6227 aPlaneData.Distance = aPlaneData.Angle[0] = aPlaneData.Angle[1] = 0;
6228 aPlaneData.X = aPlaneData.Y = aPlaneData.Z = 0;
6229 aPlaneData.Dx = aPlaneData.Dy = aPlaneData.Dz = 0;
6231 aPlaneData.Id = aClippingPlaneId;
6234 aPlaneData.Mode = aPropertyValueList[0].toInt( &ok );
6239 aPlaneData.isOpenGLClipping = aPropertyValueList[1].toInt( &ok );
6243 if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Absolute )
6246 aPlaneData.AbsoluteOrientation = aPropertyValueList[2].toInt( &ok );
6251 aPlaneData.X = aPropertyValueList[3].toDouble( &ok );
6256 aPlaneData.Y = aPropertyValueList[4].toDouble( &ok );
6261 aPlaneData.Z = aPropertyValueList[5].toDouble( &ok );
6266 aPlaneData.Dx = aPropertyValueList[6].toDouble( &ok );
6271 aPlaneData.Dy = aPropertyValueList[7].toDouble( &ok );
6276 aPlaneData.Dz = aPropertyValueList[8].toDouble( &ok );
6280 else if ( (SMESH::Mode)aPlaneData.Mode == SMESH::Relative ) {
6282 aPlaneData.RelativeOrientation = aPropertyValueList[2].toInt( &ok );
6287 aPlaneData.Distance = aPropertyValueList[3].toDouble( &ok );
6292 aPlaneData.Angle[0] = aPropertyValueList[4].toDouble( &ok );
6297 aPlaneData.Angle[1] = aPropertyValueList[5].toDouble( &ok );
6302 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
6303 aPlaneDataList.push_back( aPlaneData );
6307 TPlaneInfoMap aPlaneInfoMap;
6309 std::vector<std::string> entries = ip->getEntries();
6311 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
6313 // entry is a normal entry - it should be "decoded" (setting base address of component)
6314 QString entry (ip->decodeEntry(*entIt).c_str());
6316 // Check that the entry corresponds to a real object in the Study
6317 // as the object may be deleted or modified after the visual state is saved.
6318 _PTR(SObject) so = studyDS->FindObjectID(entry.toUtf8().data());
6319 if (!so) continue; //Skip the not existent entry
6321 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
6322 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
6324 std::vector<std::string>::iterator namesIt = paramNames.begin();
6325 std::vector<std::string>::iterator valuesIt = paramValues.begin();
6327 // actors are stored in a map after displaying of them for
6328 // quicker access in the future: map < viewID to actor >
6329 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
6331 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
6333 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
6334 // '_' is used as separator and should not be used in viewer type or parameter names.
6335 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
6336 if (lst.size() != 3)
6339 QString viewerTypStr = lst[0];
6340 QString viewIndexStr = lst[1];
6341 QString paramNameStr = lst[2];
6344 int viewIndex = viewIndexStr.toUInt(&ok);
6345 if (!ok) // bad conversion of view index to integer
6349 if (viewerTypStr == SVTK_Viewer::Type())
6351 SMESH_Actor* aSmeshActor = 0;
6352 if (vtkActors.IsBound(viewIndex))
6353 aSmeshActor = vtkActors.Find(viewIndex);
6355 QList<SUIT_ViewManager*> lst;
6356 getApp()->viewManagers(viewerTypStr, lst);
6358 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6359 SUIT_ViewManager* vman = NULL;
6360 if (viewIndex >= 0 && viewIndex < lst.count())
6361 vman = lst.at(viewIndex);
6363 if (paramNameStr == "Visibility")
6365 if (!aSmeshActor && displayer() && vman)
6367 SUIT_ViewModel* vmodel = vman->getViewModel();
6368 // SVTK view model can be casted to SALOME_View
6369 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
6371 // store displayed actor in a temporary map for quicker
6372 // access later when restoring other parameters
6373 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6374 vtkRenderer* Renderer = vtkView->getRenderer();
6375 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
6376 vtkActorCollection* theActors = aCopy.GetActors();
6377 theActors->InitTraversal();
6378 bool isFound = false;
6379 vtkActor *ac = theActors->GetNextActor();
6380 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
6381 if (ac->IsA("SMESH_Actor")) {
6382 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
6383 if (aGeomAc->hasIO()) {
6384 Handle(SALOME_InteractiveObject) io = aGeomAc->getIO();
6385 if (io->hasEntry() && strcmp(io->getEntry(), entry.toUtf8().data()) == 0) {
6387 vtkActors.Bind(viewIndex, aGeomAc);
6393 } // if (paramNameStr == "Visibility")
6396 // the rest properties "work" with SMESH_Actor
6399 QString val ((*valuesIt).c_str());
6402 if (paramNameStr == "Representation") {
6403 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
6406 else if (paramNameStr == "IsShrunk") {
6408 if (!aSmeshActor->IsShrunk())
6409 aSmeshActor->SetShrink();
6412 if (aSmeshActor->IsShrunk())
6413 aSmeshActor->UnShrink();
6416 // Displayed entities
6417 else if (paramNameStr == "Entities") {
6418 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
6419 int aEntityMode = SMESH_Actor::eAllEntity;
6420 for ( int i = 0; i < mode.count(); i+=2 ) {
6421 if ( i < mode.count()-1 ) {
6422 QString type = mode[i];
6423 bool val = mode[i+1].toInt();
6424 if ( type == "e" && !val )
6425 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
6426 else if ( type == "f" && !val )
6427 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
6428 else if ( type == "v" && !val )
6429 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
6430 else if ( type == "0d" && !val )
6431 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
6432 else if ( type == "b" && !val )
6433 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
6436 aSmeshActor->SetEntityMode( aEntityMode );
6439 else if (paramNameStr == "Colors") {
6440 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
6447 QColor outlineColor;
6448 QColor orientationColor;
6454 // below lines are required to get default values for delta coefficients
6455 // of backface color for faces and color of reversed volumes
6456 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
6457 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
6458 for ( int i = 0; i < colors.count(); i++ ) {
6459 QString type = colors[i];
6460 if ( type == "surface" ) {
6461 // face color is set by 3 values r:g:b, where
6462 // - r,g,b - is rgb color components
6463 if ( i+1 >= colors.count() ) break; // format error
6464 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6465 if ( i+2 >= colors.count() ) break; // format error
6466 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6467 if ( i+3 >= colors.count() ) break; // format error
6468 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6469 faceColor.setRgbF( r, g, b );
6472 else if ( type == "backsurface" ) {
6473 // backface color can be defined in several ways
6474 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
6475 // - in latest versions, it is set as delta coefficient
6476 bool rgbOk = false, deltaOk;
6477 if ( i+1 >= colors.count() ) break; // format error
6478 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6479 int delta = colors[i+1].toInt( &deltaOk );
6481 if ( i+1 < colors.count() ) // index is shifted to 1
6482 g = colors[i+1].toDouble( &rgbOk );
6483 if ( rgbOk ) i++; // shift index
6484 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
6485 b = colors[i+1].toDouble( &rgbOk );
6487 // - as currently there's no way to set directly backsurface color as it was before,
6488 // we ignore old dump where r,g,b triple was set
6489 // - also we check that delta parameter is set properly
6490 if ( !rgbOk && deltaOk )
6493 else if ( type == "volume" ) {
6494 // volume color is set by 4 values r:g:b:delta, where
6495 // - r,g,b - is a normal volume rgb color components
6496 // - delta - is a reversed volume color delta coefficient
6497 if ( i+1 >= colors.count() ) break; // format error
6498 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6499 if ( i+2 >= colors.count() ) break; // format error
6500 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6501 if ( i+3 >= colors.count() ) break; // format error
6502 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6503 if ( i+4 >= colors.count() ) break; // format error
6504 int delta = colors[i+4].toInt( &bOk );
6505 if ( !bOk ) break; // format error
6506 volumeColor.setRgbF( r, g, b );
6510 else if ( type == "edge" ) {
6511 // edge color is set by 3 values r:g:b, where
6512 // - r,g,b - is rgb color components
6513 if ( i+1 >= colors.count() ) break; // format error
6514 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6515 if ( i+2 >= colors.count() ) break; // format error
6516 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6517 if ( i+3 >= colors.count() ) break; // format error
6518 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6519 edgeColor.setRgbF( r, g, b );
6522 else if ( type == "node" ) {
6523 // node color is set by 3 values r:g:b, where
6524 // - r,g,b - is rgb color components
6525 if ( i+1 >= colors.count() ) break; // format error
6526 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6527 if ( i+2 >= colors.count() ) break; // format error
6528 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6529 if ( i+3 >= colors.count() ) break; // format error
6530 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6531 nodeColor.setRgbF( r, g, b );
6534 else if ( type == "elem0d" ) {
6535 // 0d element color is set by 3 values r:g:b, where
6536 // - r,g,b - is rgb color components
6537 if ( i+1 >= colors.count() ) break; // format error
6538 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6539 if ( i+2 >= colors.count() ) break; // format error
6540 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6541 if ( i+3 >= colors.count() ) break; // format error
6542 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6543 elem0dColor.setRgbF( r, g, b );
6546 else if ( type == "ball" ) {
6547 // ball color is set by 3 values r:g:b, where
6548 // - r,g,b - is rgb color components
6549 if ( i+1 >= colors.count() ) break; // format error
6550 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6551 if ( i+2 >= colors.count() ) break; // format error
6552 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6553 if ( i+3 >= colors.count() ) break; // format error
6554 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6555 ballColor.setRgbF( r, g, b );
6558 else if ( type == "outline" ) {
6559 // outline color is set by 3 values r:g:b, where
6560 // - r,g,b - is rgb color components
6561 if ( i+1 >= colors.count() ) break; // format error
6562 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6563 if ( i+2 >= colors.count() ) break; // format error
6564 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6565 if ( i+3 >= colors.count() ) break; // format error
6566 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6567 outlineColor.setRgbF( r, g, b );
6570 else if ( type == "orientation" ) {
6571 // orientation color is set by 3 values r:g:b, where
6572 // - r,g,b - is rgb color components
6573 if ( i+1 >= colors.count() ) break; // format error
6574 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6575 if ( i+2 >= colors.count() ) break; // format error
6576 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6577 if ( i+3 >= colors.count() ) break; // format error
6578 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
6579 orientationColor.setRgbF( r, g, b );
6584 if ( nodeColor.isValid() )
6585 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
6587 if ( edgeColor.isValid() )
6588 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
6590 if ( faceColor.isValid() )
6591 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6593 if ( volumeColor.isValid() )
6594 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
6595 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
6596 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
6598 if ( elem0dColor.isValid() )
6599 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
6601 if ( ballColor.isValid() )
6602 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
6604 if ( outlineColor.isValid() )
6605 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
6606 // orientation color
6607 if ( orientationColor.isValid() )
6608 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
6611 else if (paramNameStr == "Sizes") {
6612 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6615 int outlineWidth = -1;
6616 int elem0dSize = -1;
6617 //int ballSize = -1;
6618 double ballDiameter = -1.0;
6619 double ballScale = -1.0;
6620 double shrinkSize = -1;
6621 double orientationSize = -1;
6622 bool orientation3d = false;
6623 for ( int i = 0; i < sizes.count(); i++ ) {
6624 QString type = sizes[i];
6625 if ( type == "line" ) {
6626 // line (wireframe) width is given as single integer value
6627 if ( i+1 >= sizes.count() ) break; // format error
6628 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6632 if ( type == "outline" ) {
6633 // outline width is given as single integer value
6634 if ( i+1 >= sizes.count() ) break; // format error
6635 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6639 else if ( type == "elem0d" ) {
6640 // 0d element size is given as single integer value
6641 if ( i+1 >= sizes.count() ) break; // format error
6642 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6646 else if ( type == "ball" ) {
6647 // balls are specified by two values: size:scale, where
6648 // - size - is a integer value specifying size
6649 // - scale - is a double value specifying scale factor
6650 if ( i+1 >= sizes.count() ) break; // format error
6651 //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6652 double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6653 if ( i+2 >= sizes.count() ) break; // format error
6654 double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
6660 else if ( type == "shrink" ) {
6661 // shrink factor is given as single floating point value
6662 if ( i+1 >= sizes.count() ) break; // format error
6663 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6667 else if ( type == "orientation" ) {
6668 // orientation vectors are specified by two values size:3d, where
6669 // - size - is a floating point value specifying scale factor
6670 // - 3d - is a boolean
6671 if ( i+1 >= sizes.count() ) break; // format error
6672 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6673 if ( i+2 >= sizes.count() ) break; // format error
6674 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6675 orientationSize = v1;
6676 orientation3d = (bool)v2;
6680 // line (wireframe) width
6681 if ( lineWidth > 0 )
6682 aSmeshActor->SetLineWidth( lineWidth );
6684 if ( outlineWidth > 0 )
6685 aSmeshActor->SetOutlineWidth( outlineWidth );
6686 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6687 aSmeshActor->SetOutlineWidth( lineWidth );
6689 if ( elem0dSize > 0 )
6690 aSmeshActor->Set0DSize( elem0dSize );
6692 /*if ( ballSize > 0 )
6693 aSmeshActor->SetBallSize( ballSize );*/
6695 if ( ballDiameter > 0 )
6696 aSmeshActor->SetBallSize( ballDiameter );
6698 if ( ballScale > 0.0 )
6699 aSmeshActor->SetBallScale( ballScale );
6701 if ( shrinkSize > 0 )
6702 aSmeshActor->SetShrinkFactor( shrinkSize );
6703 // orientation vectors
6704 if ( orientationSize > 0 ) {
6705 aSmeshActor->SetFacesOrientationScale( orientationSize );
6706 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6710 else if (paramNameStr == "PointMarker") {
6711 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6712 if( data.count() >= 2 ) {
6714 int aParam1 = data[1].toInt( &ok );
6716 if( data[0] == "std" && data.count() == 3 ) {
6717 int aParam2 = data[2].toInt( &ok );
6718 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6720 else if( data[0] == "custom" ) {
6721 VTK::MarkerMap::const_iterator markerIt = myMarkerMap.find( aParam1 );
6722 if( markerIt != myMarkerMap.end() ) {
6723 VTK::MarkerData aMarkerData = markerIt->second;
6724 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6731 else if (paramNameStr == "Opacity") {
6732 aSmeshActor->SetOpacity(val.toFloat());
6735 else if (paramNameStr.startsWith("ClippingPlane")) {
6736 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6737 // old format - val looks like "Off" or "1:0:0:0.5:0:0"
6738 // (mode(relative), is OpenGL clipping plane, orientation, distance, two angles)
6739 // or "0:1:1:10.5:1.0:1.0:15.0:10.0:10.0"
6740 // (mode(absolute), is OpenGL clipping plane, orientation, base point(x, y, z), direction (dx, dy, dz))
6741 // new format - val looks like "Off" or "0" (plane id)
6742 // (note: in new format "Off" value is used only for consistency,
6743 // so it is processed together with values in old format)
6744 bool anIsOldFormat = ( vals.count() == 6 || vals.count() == 9 || val == "Off" );
6745 if( anIsOldFormat ) {
6746 if (paramNameStr == "ClippingPlane1" || val == "Off")
6747 aSmeshActor->RemoveAllClippingPlanes();
6749 QList<SUIT_ViewManager*> lst;
6750 getApp()->viewManagers(viewerTypStr, lst);
6751 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6752 if (viewIndex >= 0 && viewIndex < lst.count()) {
6753 SUIT_ViewManager* vman = lst.at(viewIndex);
6754 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6756 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6758 SMESH::TActorList anActorList;
6759 anActorList.push_back( aSmeshActor );
6760 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( vtkView );
6761 aPlane->myViewWindow = vtkView;
6762 SMESH::Mode aMode = ( SMESH::Mode )vals[0].toInt();
6763 aPlane->PlaneMode = aMode;
6764 bool isOpenGLClipping = ( bool )vals[1].toInt();
6765 aPlane->IsOpenGLClipping = isOpenGLClipping;
6766 if ( aMode == SMESH::Absolute ) {
6767 aPlane->myAbsoluteOrientation = vals[2].toInt();
6768 aPlane->X = vals[3].toFloat();
6769 aPlane->Y = vals[4].toFloat();
6770 aPlane->Z = vals[5].toFloat();
6771 aPlane->Dx = vals[6].toFloat();
6772 aPlane->Dy = vals[7].toFloat();
6773 aPlane->Dz = vals[8].toFloat();
6775 else if ( aMode == SMESH::Relative ) {
6776 aPlane->myRelativeOrientation = (SMESH::Orientation)vals[2].toInt();
6777 aPlane->myDistance = vals[3].toFloat();
6778 aPlane->myAngle[0] = vals[4].toFloat();
6779 aPlane->myAngle[1] = vals[5].toFloat();
6783 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6784 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6785 aClippingPlaneInfo.Plane = aPlane;
6786 aClippingPlaneInfo.ActorList = anActorList;
6787 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6795 int aPlaneId = val.toInt( &ok );
6796 if( ok && aPlaneId >= 0 ) {
6797 bool anIsDefinedPlane = false;
6798 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6799 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6800 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6801 TPlaneInfo& aPlaneInfo = *anIter;
6802 if( aPlaneInfo.PlaneId == aPlaneId ) {
6803 aPlaneInfo.ActorList.push_back( aSmeshActor );
6804 anIsDefinedPlane = true;
6808 if( !anIsDefinedPlane ) {
6809 TPlaneInfo aPlaneInfo;
6810 aPlaneInfo.PlaneId = aPlaneId;
6811 aPlaneInfo.ActorList.push_back( aSmeshActor );
6812 aPlaneInfo.ViewManager = vman;
6814 // to make the list sorted by plane id
6815 anIter = aPlaneInfoList.begin();
6816 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6817 const TPlaneInfo& aPlaneInfoRef = *anIter;
6818 if( aPlaneInfoRef.PlaneId > aPlaneId )
6821 aPlaneInfoList.insert( anIter, aPlaneInfo );
6826 } // if (aSmeshActor)
6827 } // other parameters than Visibility
6829 } // for names/parameters iterator
6830 } // for entries iterator
6832 // take into account planes with empty list of actors referred to them
6833 QList<SUIT_ViewManager*> aVMList;
6834 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6836 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6837 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6838 int aViewId = aPlaneDataIter->first;
6839 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6840 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6842 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6844 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6845 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6846 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6847 const TPlaneData& aPlaneData = *anIter2;
6848 int aPlaneId = aPlaneData.Id;
6850 bool anIsFound = false;
6851 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6852 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6853 const TPlaneInfo& aPlaneInfo = *anIter3;
6854 if( aPlaneInfo.PlaneId == aPlaneId ) {
6861 TPlaneInfo aPlaneInfo; // ActorList field is empty
6862 aPlaneInfo.PlaneId = aPlaneId;
6863 aPlaneInfo.ViewManager = aViewManager;
6865 // to make the list sorted by plane id
6866 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6867 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6868 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6869 if( aPlaneInfoRef.PlaneId > aPlaneId )
6872 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6878 // add clipping planes to actors according to the restored parameters
6879 // and update the clipping plane map
6880 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6881 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6882 int aViewId = anIter1->first;
6883 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6885 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6886 if( anIter2 == aPlaneDataMap.end() )
6888 const TPlaneDataList& aPlaneDataList = anIter2->second;
6890 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6891 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6892 const TPlaneInfo& aPlaneInfo = *anIter3;
6893 int aPlaneId = aPlaneInfo.PlaneId;
6894 const TActorList& anActorList = aPlaneInfo.ActorList;
6895 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6899 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6903 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6905 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6906 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6907 const TPlaneData& aPlaneData = *anIter4;
6908 if( aPlaneData.Id == aPlaneId ) {
6909 SMESH::OrientedPlane* aPlane = SMESH::OrientedPlane::New( aViewWindow );
6910 aPlane->myViewWindow = aViewWindow;
6911 aPlane->PlaneMode = (SMESH::Mode)aPlaneData.Mode;
6912 aPlane->IsOpenGLClipping = aPlaneData.isOpenGLClipping;
6913 if ( aPlane->PlaneMode == SMESH::Absolute ) {
6914 aPlane->myAbsoluteOrientation = aPlaneData.AbsoluteOrientation;
6915 aPlane->X = aPlaneData.X;
6916 aPlane->Y = aPlaneData.Y;
6917 aPlane->Z = aPlaneData.Z;
6918 aPlane->Dx = aPlaneData.Dx;
6919 aPlane->Dy = aPlaneData.Dy;
6920 aPlane->Dz = aPlaneData.Dz;
6922 else if ( aPlane->PlaneMode == SMESH::Relative ) {
6923 aPlane->myRelativeOrientation = (SMESH::Orientation)aPlaneData.RelativeOrientation;
6924 aPlane->myDistance = aPlaneData.Distance;
6925 aPlane->myAngle[0] = aPlaneData.Angle[0];
6926 aPlane->myAngle[1] = aPlaneData.Angle[1];
6929 if ( SMESHGUI_ClippingDlg::AddPlane( anActorList, aPlane ) ) {
6930 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6931 aClippingPlaneInfo.Plane = aPlane;
6932 aClippingPlaneInfo.ActorList = anActorList;
6933 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6944 // update all VTK views
6945 QList<SUIT_ViewManager*> lst;
6946 getApp()->viewManagers(lst);
6947 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6948 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6949 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6950 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6951 // set OpenGL clipping planes
6952 VTK::ActorCollectionCopy aCopy( vtkView->getRenderer()->GetActors() );
6953 vtkActorCollection* anAllActors = aCopy.GetActors();
6954 anAllActors->InitTraversal();
6955 while( vtkActor* aVTKActor = anAllActors->GetNextActor() )
6956 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
6957 anActor->SetOpenGLClippingPlane();
6959 vtkView->getRenderer()->ResetCameraClippingRange();
6966 \brief Adds preferences for dfont of VTK viewer
6968 \param pIf group identifier
6969 \param param parameter
6970 \return identifier of preferences
6972 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
6974 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6976 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6979 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6980 fam.append( tr( "SMESH_FONT_COURIER" ) );
6981 fam.append( tr( "SMESH_FONT_TIMES" ) );
6983 setPreferenceProperty( tfont, "fonts", fam );
6985 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6986 if ( needSize ) f = f | QtxFontEdit::Size;
6987 setPreferenceProperty( tfont, "features", f );
6993 \brief Actions after hypothesis edition
6994 Updates object browser after hypothesis edition
6996 void SMESHGUI::onHypothesisEdit( int result )
6999 SMESHGUI::Modified();
7000 updateObjBrowser( true );
7004 \brief Actions after choosing menu of control modes
7005 Updates control mode actions according to current selection
7007 void SMESHGUI::onUpdateControlActions()
7009 SALOME_ListIO selected;
7010 if ( LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr() )
7011 aSel->selectedObjects( selected );
7013 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
7014 if ( selected.Extent() ) {
7015 if ( selected.First()->hasEntry() ) {
7016 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( selected.First()->getEntry() )) {
7017 aControl = anActor->GetControlMode();
7018 SALOME_ListIteratorOfListIO it(selected);
7019 for ( it.Next(); it.More(); it.Next() ) {
7020 Handle(SALOME_InteractiveObject) anIO = it.Value();
7021 if ( anIO->hasEntry() ) {
7022 if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
7023 if ( aControl != anActor->GetControlMode() ) {
7024 aControl = SMESH_Actor::eNone;
7034 int anAction = ActionToControl( aControl, true );
7036 action( anAction )->setChecked( true );
7038 QMenu* send = (QMenu*)sender();
7039 QList<QAction*> actions = send->actions();
7040 for ( int i = 0; i < actions.size(); i++ )
7041 actions[i]->setChecked( false );
7047 \brief Signal handler closing(SUIT_ViewWindow*) of a view
7048 \param pview view being closed
7050 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
7051 #ifndef DISABLE_PLOT2DVIEWER
7052 //Crear all Plot2d Viewers if need.
7053 SMESH::ClearPlot2Viewers(pview);
7055 EmitSignalCloseView();
7058 void SMESHGUI::message( const QString& msg )
7061 QStringList data = msg.split("/");
7062 if ( data.count() > 0 ) {
7063 if ( data.first() == "mesh_loading" ) {
7065 QString entry = data.count() > 1 ? data[1] : QString();
7066 if ( entry.isEmpty() )
7069 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
7071 _PTR(SObject) obj = study->FindObjectID( entry.toUtf8().constData() );
7074 name = SMESH::fromUtf8(obj->GetName());
7075 if ( name.isEmpty() )
7078 if ( data.last() == "stop" )
7079 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
7081 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
7082 QApplication::processEvents();
7088 \brief Connects or disconnects signals about activating and cloning view on the module slots
7089 \param pview view which is connected/disconnected
7091 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
7095 SUIT_ViewManager* viewMgr = pview->getViewManager();
7097 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7098 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7100 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
7101 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
7106 \brief Return \c true if object can be renamed
7108 bool SMESHGUI::renameAllowed( const QString& entry) const {
7109 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7113 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7117 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
7122 if(appStudy->isComponent(entry) || obj->isReference())
7125 // check type to prevent renaming of inappropriate objects
7126 int aType = SMESHGUI_Selection::type(qPrintable(entry));
7127 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7128 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7129 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7130 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7131 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
7138 Rename object by entry.
7139 \param entry entry of the object
7140 \param name new name of the object
7141 \brief Return \c true if rename operation finished successfully, \c false otherwise.
7143 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
7145 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
7149 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
7154 _PTR(Study) aStudy = appStudy->studyDS();
7159 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
7161 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
7166 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
7167 _PTR(GenericAttribute) anAttr;
7168 _PTR(AttributeName) aName;
7170 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
7172 // check type to prevent renaming of inappropriate objects
7173 int aType = SMESHGUI_Selection::type( qPrintable(entry));
7174 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
7175 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
7176 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
7177 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
7178 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
7179 if ( !name.isEmpty() ) {
7180 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qUtf8Printable(name) );
7182 // update name of group object and its actor
7183 Handle(SALOME_InteractiveObject) IObject =
7184 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
7186 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
7187 if( !aGroupObject->_is_nil() ) {
7188 aGroupObject->SetName( qUtf8Printable(name) );
7189 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
7190 anActor->setName( qUtf8Printable(name) );
7200 SALOMEDS::Color SMESHGUI::getPredefinedUniqueColor()
7202 static QList<QColor> colors;
7204 if ( colors.isEmpty() ) {
7206 for (int s = 0; s < 2 ; s++)
7208 for (int v = 100; v >= 40; v = v - 20)
7210 for (int h = 0; h < 359 ; h = h + 60)
7212 colors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100));
7217 static int currentColor = randomize( colors.size() );
7219 SALOMEDS::Color color;
7220 color.R = (double)colors[currentColor].red() / 255.0;
7221 color.G = (double)colors[currentColor].green() / 255.0;
7222 color.B = (double)colors[currentColor].blue() / 255.0;
7224 currentColor = (currentColor+1) % colors.count();