1 // Copyright (C) 2007-2011 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.
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
29 #include "SMESHGUI_AddMeshElementDlg.h"
30 #include "SMESHGUI_AddQuadraticElementDlg.h"
31 #include "SMESHGUI_BuildCompoundDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_ComputeDlg.h"
34 #include "SMESHGUI_ConvToQuadOp.h"
35 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
36 #include "SMESHGUI_DeleteGroupDlg.h"
37 #include "SMESHGUI_Displayer.h"
38 #include "SMESHGUI_MergeDlg.h"
39 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
40 #include "SMESHGUI_ExtrusionDlg.h"
41 #include "SMESHGUI_FileInfoDlg.h"
42 #include "SMESHGUI_FileValidator.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_FindElemByPointDlg.h"
46 #include "SMESHGUI_GroupDlg.h"
47 #include "SMESHGUI_GroupOnShapeDlg.h"
48 #include "SMESHGUI_GroupOpDlg.h"
49 #include "SMESHGUI_Hypotheses.h"
50 #include "SMESHGUI_Make2DFrom3DOp.h"
51 #include "SMESHGUI_MakeNodeAtPointDlg.h"
52 //#include "SMESHGUI_MeshInfosDlg.h"
53 #include "SMESHGUI_Measurements.h"
54 #include "SMESHGUI_MeshInfo.h"
55 #include "SMESHGUI_MeshOp.h"
56 #include "SMESHGUI_MeshOrderOp.h"
57 #include "SMESHGUI_MeshPatternDlg.h"
58 #include "SMESHGUI_MultiEditDlg.h"
59 #include "SMESHGUI_NodesDlg.h"
60 #include "SMESHGUI_Preferences_ColorDlg.h"
61 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
62 #include "SMESHGUI_RemoveElementsDlg.h"
63 #include "SMESHGUI_RemoveNodesDlg.h"
64 #include "SMESHGUI_RenumberingDlg.h"
65 #include "SMESHGUI_RevolutionDlg.h"
66 #include "SMESHGUI_RotationDlg.h"
67 #include "SMESHGUI_Selection.h"
68 #include "SMESHGUI_SewingDlg.h"
69 #include "SMESHGUI_SingleEditDlg.h"
70 #include "SMESHGUI_SmoothingDlg.h"
71 //#include "SMESHGUI_StandardMeshInfosDlg.h"
72 #include "SMESHGUI_SymmetryDlg.h"
73 #include "SMESHGUI_TranslationDlg.h"
74 #include "SMESHGUI_ScaleDlg.h"
75 #include "SMESHGUI_TransparencyDlg.h"
76 //#include "SMESHGUI_WhatIsDlg.h"
77 #include "SMESHGUI_DuplicateNodesDlg.h"
78 #include "SMESHGUI_CopyMeshDlg.h"
80 #include "SMESHGUI_Utils.h"
81 #include "SMESHGUI_MeshUtils.h"
82 #include "SMESHGUI_GroupUtils.h"
83 #include "SMESHGUI_FilterUtils.h"
84 #include "SMESHGUI_PatternUtils.h"
85 #include "SMESHGUI_VTKUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
88 #include <SMESH_Client.hxx>
89 #include <SMESH_Actor.h>
90 #include <SMESH_ScalarBarActor.h>
91 #include <SMESH_ActorUtils.h>
92 #include <SMESH_TypeFilter.hxx>
93 #include "SMESH_ControlsDef.hxx"
95 // SALOME GUI includes
96 #include <SalomeApp_Tools.h>
97 #include <SalomeApp_Study.h>
98 #include <SalomeApp_Application.h>
99 #include <SalomeApp_CheckFileDlg.h>
101 #include <LightApp_DataOwner.h>
102 #include <LightApp_Preferences.h>
103 #include <LightApp_SelectionMgr.h>
104 #include <LightApp_UpdateFlags.h>
105 #include <LightApp_NameDlg.h>
107 #include <SVTK_ViewWindow.h>
108 #include <SVTK_ViewModel.h>
109 #include <SVTK_ViewManager.h>
111 #include <VTKViewer_Algorithm.h>
113 #include <SUIT_MessageBox.h>
114 #include <SUIT_ResourceMgr.h>
115 #include <SUIT_FileDlg.h>
116 #include <SUIT_Desktop.h>
117 #include <SUIT_OverrideCursor.h>
118 #include <SUIT_Session.h>
120 #include <QtxPopupMgr.h>
121 #include <QtxFontEdit.h>
123 #include <SALOME_ListIO.hxx>
124 #include <SALOME_ListIteratorOfListIO.hxx>
126 #ifndef DISABLE_PLOT2DVIEWER
127 #include <SPlot2d_ViewModel.h>
128 #include <SPlot2d_Histogram.h>
132 #include <SALOMEconfig.h>
133 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
134 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
135 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
138 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
140 #include <QTextStream>
143 #include <boost/shared_ptr.hpp>
146 #include <vtkCamera.h>
147 #include <vtkRenderer.h>
148 #include <vtkPlane.h>
149 #include <vtkCallbackCommand.h>
150 #include <vtkLookupTable.h>
152 // SALOME KERNEL includes
153 #include <SALOMEDS_Study.hxx>
154 #include <SALOMEDSClient_StudyBuilder.hxx>
155 #include <SALOMEDSClient_SComponent.hxx>
156 #include <SALOMEDSClient_ClientFactory.hxx>
157 #include <SALOMEDSClient_IParameters.hxx>
160 #include <Standard_ErrorHandler.hxx>
161 #include <NCollection_DataMap.hxx>
163 //To disable automatic genericobj management, the following line should be commented.
164 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
165 #define WITHGENERICOBJ
169 //=============================================================
170 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
173 void ExportMeshToFile(int theCommandID);
175 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
177 void SetDisplayEntity(int theCommandID);
179 void Control( int theCommandID );
183 //=============================================================
184 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
188 std::string myExtension;
190 if ( theCommandID == 113 ) {
191 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
192 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
194 else if ( theCommandID == 112 ) {
195 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
197 else if ( theCommandID == 111 ) {
198 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
200 else if ( theCommandID == 115 ) {
201 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
203 else if ( theCommandID == 116 ) {
204 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
207 QString anInitialPath = "";
208 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
209 anInitialPath = QDir::currentPath();
211 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
214 QObject::tr( "SMESH_IMPORT_MESH" ) );
215 if ( filenames.count() > 0 ) {
216 SUIT_OverrideCursor wc;
217 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
220 QStringList anEntryList;
221 bool isEmpty = false;
222 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
223 QString filename = *it;
224 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
226 switch ( theCommandID ) {
229 // DAT format (currently unsupported)
230 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
231 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
237 aMeshes->length( 1 );
238 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
239 if ( aMeshes[0]->_is_nil() )
240 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
241 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
247 SMESH::DriverMED_ReadStatus res;
248 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
249 if ( res != SMESH::DRS_OK ) {
250 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
251 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
258 aMeshes->length( 1 );
259 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
260 if ( aMeshes[0]->_is_nil() ) {
261 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
262 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
269 SMESH::DriverMED_ReadStatus res;
270 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
271 if ( res != SMESH::DRS_OK ) {
272 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
273 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
279 catch ( const SALOME::SALOME_Exception& S_ex ) {
280 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
281 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
284 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
285 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
287 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
288 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
289 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
290 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
291 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
293 anEntryList.append( aMeshSO->GetID().c_str() );
295 #ifdef WITHGENERICOBJ
296 // obj has been published in study. Its refcount has been incremented.
297 // It is safe to decrement its refcount
298 // so that it will be destroyed when the entry in study will be removed
299 aMeshes[i]->UnRegister();
308 // update Object browser
309 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
311 // browse to the published meshes
312 if( LightApp_Application* anApp =
313 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
314 anApp->browseObjects( anEntryList );
316 // show Error message box if there were errors
317 if ( errors.count() > 0 ) {
318 SUIT_MessageBox::critical( SMESHGUI::desktop(),
319 QObject::tr( "SMESH_ERROR" ),
320 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
323 // show warning message box, if some imported mesh is empty
325 SUIT_MessageBox::warning( SMESHGUI::desktop(),
326 QObject::tr( "SMESH_WRN_WARNING" ),
327 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
332 //================================================================================
334 * \brief Export selected meshes or groups into a file
336 //================================================================================
338 void ExportMeshToFile( int theCommandID )
340 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
341 SALOME_ListIO selected;
343 aSel->selectedObjects( selected );
345 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
346 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
347 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
348 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
349 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
351 // actually, the following condition can't be met (added for insurance)
352 if( selected.Extent() == 0 ||
353 ( selected.Extent() > 1 && !isMED && !isSTL ))
356 // get mesh object from selection and check duplication of their names
357 bool hasDuplicatedMeshNames = false;
358 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
359 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
360 SALOME_ListIteratorOfListIO It( selected );
361 for( ; It.More(); It.Next() )
363 Handle(SALOME_InteractiveObject) anIObject = It.Value();
364 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
365 if ( aMeshItem->_is_nil() ) {
366 SUIT_MessageBox::warning( SMESHGUI::desktop(),
367 QObject::tr( "SMESH_WRN_WARNING" ),
368 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
372 QString aMeshName = anIObject->getName();
374 // check for name duplications
375 if ( !hasDuplicatedMeshNames )
376 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
377 if( aMeshName == (*aMeshIter).second ) {
378 hasDuplicatedMeshNames = true;
383 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
386 if( hasDuplicatedMeshNames && isMED ) {
387 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
388 QObject::tr("SMESH_WRN_WARNING"),
389 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
390 QObject::tr("SMESH_BUT_YES"),
391 QObject::tr("SMESH_BUT_NO"), 0, 1);
396 aMeshIter = aMeshList.begin();
397 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
398 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
399 QString aMeshName = (*aMeshIter).second;
401 if ( isMED || isCGNS )
403 // check for equal group names within each mesh
404 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
405 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
406 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
407 int aRet = SUIT_MessageBox::warning
408 (SMESHGUI::desktop(),
409 QObject::tr("SMESH_WRN_WARNING"),
410 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
411 QObject::tr("SMESH_BUT_YES"),
412 QObject::tr("SMESH_BUT_NO"), 0, 1);
420 // warn the user about presence of not supported elements
421 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
422 int nbPyramids = nbElems[ SMESH::Entity_Pyramid ] + nbElems[ SMESH::Entity_Quad_Pyramid ];
423 if ( nbPyramids > 0 ) {
424 int aRet = SUIT_MessageBox::warning
425 (SMESHGUI::desktop(),
426 QObject::tr("SMESH_WRN_WARNING"),
427 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
428 QObject::tr("SMESH_BUT_YES"),
429 QObject::tr("SMESH_BUT_NO"), 0, 1);
435 // Get parameters of export operation
438 SMESH::MED_VERSION aFormat;
439 // Init the parameters with the default values
440 bool aIsASCII_STL = true;
441 bool toCreateGroups = false;
442 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
444 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
445 bool toOverwrite = true;
447 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
448 QString anInitialPath = "";
449 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
450 anInitialPath = QDir::currentPath();
452 if ( isUNV || isDAT )
455 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
457 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
458 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
459 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
460 anInitialPath + QString("/") + aMeshName,
461 aFilter, aTitle, false);
463 else if ( isCGNS )// Export to CGNS
465 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
466 fd->setWindowTitle( aTitle );
467 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
468 if ( !anInitialPath.isEmpty() )
469 fd->setDirectory( anInitialPath );
470 fd->selectFile(aMeshName);
471 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
472 fd->setValidator( fv );
475 aFilename = fd->selectedFile();
476 toOverwrite = fv->isOverwrite();
480 else if ( isSTL ) // Export to STL
482 QMap<QString, int> aFilterMap;
483 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
484 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
487 QMap<QString, int>::const_iterator it = aFilterMap.begin();
488 for ( ; it != aFilterMap.end(); ++it )
489 filters.push_back( it.key() );
491 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
492 fd->setWindowTitle( aTitle );
493 fd->setNameFilters( filters );
494 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
495 if ( !anInitialPath.isEmpty() )
496 fd->setDirectory( anInitialPath );
497 fd->selectFile(aMeshName);
501 aFilename = fd->selectedFile();
502 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
507 else if ( isMED ) // Export to MED
509 QMap<QString, SMESH::MED_VERSION> aFilterMap;
510 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
511 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
512 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
513 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
516 QString aDefaultFilter;
517 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
518 for ( ; it != aFilterMap.end(); ++it ) {
519 filters.push_back( it.key() );
520 if (it.value() == SMESH::MED_V2_2)
521 aDefaultFilter = it.key();
524 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
525 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
526 fd->setWindowTitle( aTitle );
527 fd->setNameFilters( filters );
528 fd->selectNameFilter(aDefaultFilter);
529 fd->SetChecked(toCreateGroups);
530 if ( !anInitialPath.isEmpty() )
531 fd->setDirectory( anInitialPath );
532 fd->selectFile(aMeshName);
534 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
535 fd->setValidator( fv );
540 aFilename = fd->selectedFile();
542 aFilename = QString::null;
545 aFormat = aFilterMap[fd->selectedNameFilter()];
546 toOverwrite = fv->isOverwrite();
548 if ( !aFilename.isEmpty() ) {
549 // med-2.1 does not support poly elements
550 if ( aFormat==SMESH::MED_V2_1 )
551 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
552 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
553 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
554 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
555 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
557 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
558 QObject::tr("SMESH_WRN_WARNING"),
559 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
560 QObject::tr("SMESH_BUT_YES"),
561 QObject::tr("SMESH_BUT_NO"), 0, 1);
569 // can't append to an existing using other format
570 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
571 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
572 if( !isVersionOk || aVersion != aFormat ) {
573 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
574 QObject::tr("SMESH_WRN_WARNING"),
575 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
576 QObject::tr("SMESH_BUT_YES"),
577 QObject::tr("SMESH_BUT_NO"), 0, 1);
584 QStringList aMeshNamesCollisionList;
585 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
586 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
587 QString anExistingMeshName( aMeshNames[ i ] );
588 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
589 QString anExportMeshName = (*aMeshIter).second;
590 if( anExportMeshName == anExistingMeshName ) {
591 aMeshNamesCollisionList.append( anExportMeshName );
596 if( !aMeshNamesCollisionList.isEmpty() ) {
597 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
598 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
599 QObject::tr("SMESH_WRN_WARNING"),
600 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
601 QObject::tr("SMESH_BUT_YES"),
602 QObject::tr("SMESH_BUT_NO"),
603 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
612 toCreateGroups = fd->IsChecked();
622 if ( !aFilename.isEmpty() ) {
623 // Check whether the file already exists and delete it if yes
624 QFile aFile( aFilename );
625 if ( aFile.exists() && toOverwrite )
627 SUIT_OverrideCursor wc;
630 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
631 // bool Renumber = false;
632 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
634 // Renumber= resMgr->booleanValue("SMESH","renumbering");
636 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
637 // aMeshEditor->RenumberNodes();
638 // aMeshEditor->RenumberElements();
639 // if ( SMESHGUI::automaticUpdate() )
640 // SMESH::UpdateView();
644 aMeshIter = aMeshList.begin();
645 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
647 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
648 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
649 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
650 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
651 aFormat, toOverwrite && aMeshIndex == 0 );
653 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
654 aFormat, toOverwrite && aMeshIndex == 0 );
659 if ( aMeshOrGroup->_is_equivalent( aMesh ))
660 aMesh->ExportDAT( aFilename.toLatin1().data() );
662 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
666 if ( aMeshOrGroup->_is_equivalent( aMesh ))
667 aMesh->ExportUNV( aFilename.toLatin1().data() );
669 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
673 if ( aMeshOrGroup->_is_equivalent( aMesh ))
674 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
676 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
680 aMeshIter = aMeshList.begin();
681 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
683 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
684 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
685 aMeshItem->ExportCGNS( aMeshOrGroup,
686 aFilename.toLatin1().data(),
687 toOverwrite && aMeshIndex == 0 );
691 catch (const SALOME::SALOME_Exception& S_ex){
693 SUIT_MessageBox::warning(SMESHGUI::desktop(),
694 QObject::tr("SMESH_WRN_WARNING"),
695 QObject::tr("SMESH_EXPORT_FAILED"));
701 inline void InverseEntityMode(unsigned int& theOutputMode,
702 unsigned int theMode)
704 bool anIsNotPresent = ~theOutputMode & theMode;
706 theOutputMode |= theMode;
708 theOutputMode &= ~theMode;
711 void SetDisplayEntity(int theCommandID){
712 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
713 SALOME_ListIO selected;
715 aSel->selectedObjects( selected );
717 if(selected.Extent() >= 1){
718 SALOME_ListIteratorOfListIO It( selected );
719 for( ; It.More(); It.Next()){
720 Handle(SALOME_InteractiveObject) IObject = It.Value();
721 if(IObject->hasEntry()){
722 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
723 unsigned int aMode = anActor->GetEntityMode();
724 switch(theCommandID){
726 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
729 InverseEntityMode(aMode,SMESH_Actor::eEdges);
732 InverseEntityMode(aMode,SMESH_Actor::eFaces);
735 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
738 aMode = SMESH_Actor::eAllEntity;
742 anActor->SetEntityMode(aMode);
750 SALOME_ListIO selected;
751 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
755 LightApp_SelectionMgr* aSel = app->selectionMgr();
756 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
757 if( !aSel || !appStudy )
760 aSel->selectedObjects( selected );
761 if( selected.IsEmpty() )
764 Handle(SALOME_InteractiveObject) anIObject = selected.First();
766 _PTR(Study) aStudy = appStudy->studyDS();
767 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
768 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
769 if( aMainObject->_is_nil() )
772 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
774 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
775 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
777 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
778 SALOMEDS::Color aColor = aGroupObject->GetColor();
779 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
781 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
782 if( aGroupObject->GetType() == SMESH::NODE )
783 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
784 else if( aGroupObject->GetType() == SMESH::EDGE )
785 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
786 else if( aGroupObject->GetType() == SMESH::ELEM0D )
787 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
789 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
794 SMESH::RepaintCurrentView();
797 QString functorToString( SMESH::Controls::FunctorPtr f )
799 QString type = QObject::tr( "UNKNOWN_CONTROL" );
800 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
801 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
802 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
803 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
804 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
805 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
806 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
807 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
808 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
809 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
810 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
811 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
812 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
813 type = QObject::tr( "WARP_ELEMENTS" );
814 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
815 type = QObject::tr( "TAPER_ELEMENTS" );
816 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
817 type = QObject::tr( "SKEW_ELEMENTS" );
818 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
819 type = QObject::tr( "AREA_ELEMENTS" );
820 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
821 type = QObject::tr( "LENGTH_EDGES" );
822 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
823 type = QObject::tr( "LENGTH2D_EDGES" );
824 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
825 type = QObject::tr( "MULTI_BORDERS" );
826 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
827 type = QObject::tr( "MULTI2D_BORDERS" );
828 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
829 type = QObject::tr( "FREE_NODES" );
830 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
831 type = QObject::tr( "FREE_EDGES" );
832 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
833 type = QObject::tr( "FREE_BORDERS" );
834 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
835 type = QObject::tr( "FREE_FACES" );
836 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
837 type = QObject::tr( "BARE_BORDER_VOLUME" );
838 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
839 type = QObject::tr( "BARE_BORDER_FACE" );
840 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
841 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
842 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
843 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
847 void SaveDistribution()
849 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
850 SALOME_ListIO selected;
852 aSel->selectedObjects( selected );
854 if ( selected.Extent() == 1 ) {
855 Handle(SALOME_InteractiveObject) anIO = selected.First();
856 if ( anIO->hasEntry() ) {
857 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
858 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
859 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
860 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
861 if ( aScalarBarActor && aFunctor ) {
862 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
864 std::vector<int> elements;
865 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
866 if ( mesh->_is_nil() ) {
867 SMESH::SMESH_IDSource_var idSource =
868 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
869 if ( !idSource->_is_nil() )
871 SMESH::long_array_var ids = idSource->GetIDs();
872 elements.resize( ids->length() );
873 for ( unsigned i = 0; i < elements.size(); ++i )
874 elements[i] = ids[i];
877 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
878 vtkLookupTable* lookupTable =
879 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
880 double * minmax = lookupTable->GetRange();
881 std::vector<int> nbEvents;
882 std::vector<double> funValues;
883 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
884 QString anInitialPath = "";
885 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
886 anInitialPath = QDir::currentPath();
887 QString aMeshName = anIO->getName();
889 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
890 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
891 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
892 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
893 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
896 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
898 if ( !aFilename.isEmpty() ) {
899 QFile f( aFilename );
900 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
901 QTextStream out( &f );
902 out << "# Mesh: " << aMeshName << endl;
903 out << "# Control: " << functorToString( aFunctor ) << endl;
905 out.setFieldWidth( 10 );
906 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
907 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
918 void ShowDistribution() {
919 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
920 SALOME_ListIO selected;
922 aSel->selectedObjects( selected );
924 if ( selected.Extent() == 1 ) {
925 Handle(SALOME_InteractiveObject) anIO = selected.First();
926 if ( anIO->hasEntry() ) {
927 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
928 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
929 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
930 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
936 #ifndef DISABLE_PLOT2DVIEWER
937 void PlotDistribution() {
938 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
942 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
943 SALOME_ListIO selected;
945 aSel->selectedObjects( selected );
947 if ( selected.Extent() == 1 ) {
948 Handle(SALOME_InteractiveObject) anIO = selected.First();
949 if ( anIO->hasEntry() ) {
950 //Find Actor by entry before getting Plot2d viewer,
951 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
952 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
954 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
959 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
963 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
967 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
968 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
969 QString functorName = functorToString( anActor->GetFunctor());
970 QString aHistogramName("%1 : %2");
971 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
972 aHistogram->setName(aHistogramName);
973 aHistogram->setHorTitle(functorName);
974 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
975 aPlot->displayObject(aHistogram, true);
980 #endif //DISABLE_PLOT2DVIEWER
982 void DisableAutoColor(){
983 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
984 SALOME_ListIO selected;
986 aSel->selectedObjects( selected );
988 if(selected.Extent()){
989 Handle(SALOME_InteractiveObject) anIObject = selected.First();
990 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
991 if ( !aMesh->_is_nil() ) {
992 aMesh->SetAutoColor( false );
997 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
998 SALOME_ListIO selected;
999 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1003 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1004 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1005 if( !aSel || !appStudy )
1008 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1009 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1010 aModule->EmitSignalDeactivateDialog();
1011 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1012 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1017 _PTR(Study) aStudy = appStudy->studyDS();
1019 aSel->selectedObjects( selected );
1021 if(selected.Extent() >= 1){
1022 switch(theCommandID){
1024 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1025 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1029 QColor c, e, b, n, c0D, o;
1032 vtkFloatingPointType Shrink = 0.0;
1033 vtkFloatingPointType faces_orientation_scale = 0.0;
1034 bool faces_orientation_3dvectors = false;
1036 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1037 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1038 int aMarkerTextureCurrent = 0;
1040 SALOME_ListIteratorOfListIO It( selected );
1041 for( ; It.More(); It.Next()){
1042 Handle(SALOME_InteractiveObject) IObject = It.Value();
1043 if(IObject->hasEntry()){
1044 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1045 vtkFloatingPointType color[3];
1046 anActor->GetSufaceColor(color[0], color[1], color[2]);
1047 int c0 = int (color[0] * 255);
1048 int c1 = int (color[1] * 255);
1049 int c2 = int (color[2] * 255);
1050 c.setRgb(c0, c1, c2);
1052 vtkFloatingPointType edgecolor[3];
1053 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1054 c0 = int (edgecolor[0] * 255);
1055 c1 = int (edgecolor[1] * 255);
1056 c2 = int (edgecolor[2] * 255);
1057 e.setRgb(c0, c1, c2);
1059 vtkFloatingPointType backfacecolor[3];
1060 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
1061 c0 = int (backfacecolor[0] * 255);
1062 c1 = int (backfacecolor[1] * 255);
1063 c2 = int (backfacecolor[2] * 255);
1064 b.setRgb(c0, c1, c2);
1066 vtkFloatingPointType nodecolor[3];
1067 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1068 c0 = int (nodecolor[0] * 255);
1069 c1 = int (nodecolor[1] * 255);
1070 c2 = int (nodecolor[2] * 255);
1071 n.setRgb(c0, c1, c2);
1073 vtkFloatingPointType color0D[3];
1074 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1075 c0 = int (color0D[0] * 255);
1076 c1 = int (color0D[1] * 255);
1077 c2 = int (color0D[2] * 255);
1078 c0D.setRgb(c0, c1, c2);
1080 size0D = (int)anActor->Get0DSize();
1083 Edgewidth = (int)anActor->GetLineWidth();
1086 Shrink = anActor->GetShrinkFactor();
1088 vtkFloatingPointType faces_orientation_color[3];
1089 anActor->GetFacesOrientationColor(faces_orientation_color);
1090 c0 = int (faces_orientation_color[0] * 255);
1091 c1 = int (faces_orientation_color[1] * 255);
1092 c2 = int (faces_orientation_color[2] * 255);
1093 o.setRgb(c0, c1, c2);
1095 faces_orientation_scale = anActor->GetFacesOrientationScale();
1096 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1098 aMarkerTypeCurrent = anActor->GetMarkerType();
1099 aMarkerScaleCurrent = anActor->GetMarkerScale();
1100 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1102 // even if there are multiple objects in the selection,
1103 // we need only the first one to get values for the dialog
1109 SMESHGUI_Preferences_ColorDlg *aDlg =
1110 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1111 aDlg->SetColor(1, c);
1112 aDlg->SetColor(2, e);
1113 aDlg->SetColor(3, n);
1114 aDlg->SetColor(4, b);
1115 aDlg->SetColor(5, c0D);
1116 aDlg->SetColor(6, o);
1117 aDlg->SetIntValue(1, Edgewidth);
1118 aDlg->SetIntValue(2, int(Shrink*100.));
1119 aDlg->SetIntValue(3, size0D);
1120 aDlg->SetDoubleValue(1, faces_orientation_scale);
1121 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1123 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1125 if( aMarkerTypeCurrent != VTK::MT_USER )
1126 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1128 aDlg->setCustomMarker( aMarkerTextureCurrent );
1131 QColor color = aDlg->GetColor(1);
1132 QColor edgecolor = aDlg->GetColor(2);
1133 QColor nodecolor = aDlg->GetColor(3);
1134 QColor backfacecolor = aDlg->GetColor(4);
1135 QColor color0D = aDlg->GetColor(5);
1136 QColor faces_orientation_color = aDlg->GetColor(6);
1139 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1141 SALOME_ListIteratorOfListIO It( selected );
1142 for( ; It.More(); It.Next()){
1143 Handle(SALOME_InteractiveObject) IObject = It.Value();
1144 if(IObject->hasEntry()){
1145 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1146 /* actor color and backface color */
1147 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1148 vtkFloatingPointType (color.green()) / 255.,
1149 vtkFloatingPointType (color.blue()) / 255.);
1150 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1151 vtkFloatingPointType (backfacecolor.green()) / 255.,
1152 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1155 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1156 vtkFloatingPointType (edgecolor.green()) / 255.,
1157 vtkFloatingPointType (edgecolor.blue()) / 255.);
1159 /* Shrink factor and size edges */
1160 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1161 anActor->SetLineWidth(aDlg->GetIntValue(1));
1163 /* Nodes color and size */
1164 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1165 vtkFloatingPointType (nodecolor.green()) / 255.,
1166 vtkFloatingPointType (nodecolor.blue()) / 255.);
1169 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1170 vtkFloatingPointType (color0D.green()) / 255.,
1171 vtkFloatingPointType (color0D.blue()) / 255.);
1172 anActor->Set0DSize(aDlg->GetIntValue(3));
1174 /* Faces orientation */
1175 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1176 vtkFloatingPointType(faces_orientation_color.greenF()),
1177 vtkFloatingPointType(faces_orientation_color.blueF())};
1178 anActor->SetFacesOrientationColor(c);
1179 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1180 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1182 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1183 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1184 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1185 if( aMarkerTypeNew != VTK::MT_USER )
1186 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1188 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1189 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1190 if( anIter != aMarkerMap.end() )
1191 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1194 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1195 if( !aGroupObject->_is_nil() )
1197 SMESH::ElementType anElementType = aGroupObject->GetType();
1199 switch( anElementType )
1201 case SMESH::NODE: aColor = nodecolor; break;
1202 case SMESH::EDGE: aColor = edgecolor; break;
1203 default: aColor = color; break;
1206 SALOMEDS::Color aGroupColor;
1207 aGroupColor.R = (float)aColor.red() / 255.0;
1208 aGroupColor.G = (float)aColor.green() / 255.0;
1209 aGroupColor.B = (float)aColor.blue() / 255.0;
1210 aGroupObject->SetColor( aGroupColor );
1215 SMESH::RepaintCurrentView();
1221 SALOME_ListIteratorOfListIO It( selected );
1222 for( ; It.More(); It.Next()){
1223 Handle(SALOME_InteractiveObject) IObject = It.Value();
1224 if(IObject->hasEntry()){
1225 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1226 switch(theCommandID){
1228 anActor->SetRepresentation(SMESH_Actor::eEdge);
1231 anActor->SetRepresentation(SMESH_Actor::eSurface);
1234 if(anActor->IsShrunk())
1235 anActor->UnShrink();
1237 anActor->SetShrink();
1240 anActor->SetRepresentation(SMESH_Actor::ePoint);
1243 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1244 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1247 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1248 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1254 SMESH::RepaintCurrentView();
1258 void Control( int theCommandID )
1260 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1261 SALOME_ListIO selected;
1263 aSel->selectedObjects( selected );
1265 if( !selected.IsEmpty() ){
1266 Handle(SALOME_InteractiveObject) anIO = selected.First();
1268 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1269 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1270 switch ( theCommandID ){
1272 aControl = SMESH_Actor::eLength;
1275 aControl = SMESH_Actor::eLength2D;
1278 aControl = SMESH_Actor::eFreeEdges;
1281 aControl = SMESH_Actor::eFreeBorders;
1284 aControl = SMESH_Actor::eMultiConnection;
1287 aControl = SMESH_Actor::eFreeNodes;
1290 aControl = SMESH_Actor::eMultiConnection2D;
1293 aControl = SMESH_Actor::eArea;
1296 aControl = SMESH_Actor::eTaper;
1299 aControl = SMESH_Actor::eAspectRatio;
1302 aControl = SMESH_Actor::eAspectRatio3D;
1305 aControl = SMESH_Actor::eMinimumAngle;
1308 aControl = SMESH_Actor::eWarping;
1311 aControl = SMESH_Actor::eSkew;
1314 aControl = SMESH_Actor::eVolume3D;
1317 aControl = SMESH_Actor::eFreeFaces;
1320 aControl = SMESH_Actor::eMaxElementLength2D;
1323 aControl = SMESH_Actor::eMaxElementLength3D;
1326 aControl = SMESH_Actor::eBareBorderVolume;
1329 aControl = SMESH_Actor::eBareBorderFace;
1332 aControl = SMESH_Actor::eOverConstrainedVolume;
1335 aControl = SMESH_Actor::eOverConstrainedFace;
1338 anActor->SetControlMode(aControl);
1339 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1340 SMESH::RepaintCurrentView();
1341 #ifndef DISABLE_PLOT2DVIEWER
1342 if(anActor->GetPlot2Histogram()) {
1343 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1344 QString functorName = functorToString( anActor->GetFunctor());
1345 QString aHistogramName("%1 : %2");
1346 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1347 aHistogram->setName(aHistogramName);
1348 aHistogram->setHorTitle(functorName);
1349 SMESH::ProcessIn2DViewers(anActor);
1358 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1359 MeshObjectType theType,
1360 const QString theInTypeName,
1361 QString & theOutTypeName)
1363 SMESH_TypeFilter aTypeFilter( theType );
1365 if( !theIO.IsNull() )
1367 entry = theIO->getEntry();
1368 LightApp_DataOwner owner( entry );
1369 if ( aTypeFilter.isOk( &owner )) {
1370 theOutTypeName = theInTypeName;
1378 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1380 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1381 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1383 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1384 CORBA::String_var anID = aSComp->GetID().c_str();
1385 if (!strcmp(anID.in(),theIO->getEntry()))
1391 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1392 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1393 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1394 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1395 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1403 QString CheckHomogeneousSelection()
1405 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1406 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1407 SALOME_ListIO selected;
1409 aSel->selectedObjects( selected );
1411 QString RefType = CheckTypeObject(selected.First());
1412 SALOME_ListIteratorOfListIO It(selected);
1413 for ( ; It.More(); It.Next())
1415 Handle(SALOME_InteractiveObject) IObject = It.Value();
1416 QString Type = CheckTypeObject(IObject);
1417 if (Type.compare(RefType) != 0)
1418 return "Heterogeneous Selection";
1425 void SMESHGUI::OnEditDelete()
1427 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1428 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1429 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1431 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1432 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1433 _PTR(GenericAttribute) anAttr;
1434 _PTR(AttributeIOR) anIOR;
1436 int objectCount = 0;
1438 QString aParentComponent = QString::null;
1439 Handle(SALOME_InteractiveObject) anIO;
1440 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1442 anIO = anIt.Value();
1443 QString cur = anIO->getComponentDataType();
1444 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1446 // check if object is reference
1447 _PTR(SObject) aRefSObj;
1448 aNameList.append("\n - ");
1449 if ( aSO->ReferencedObject( aRefSObj ) ) {
1450 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1451 aNameList.append( aRefName );
1452 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1455 aNameList.append(anIO->getName());
1459 if( aParentComponent.isNull() )
1460 aParentComponent = cur;
1461 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1462 aParentComponent = "";
1465 if ( objectCount == 0 )
1466 return; // No Valid Objects Selected
1468 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1469 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1470 QObject::tr("ERR_ERROR"),
1471 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1474 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1475 if (SUIT_MessageBox::warning
1476 (SMESHGUI::desktop(),
1477 QObject::tr("SMESH_WRN_WARNING"),
1478 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1479 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1480 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1483 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1485 SALOME_ListIteratorOfListIO It(selected);
1487 aStudyBuilder->NewCommand(); // There is a transaction
1488 for( ; It.More(); It.Next()){ // loop on selected IO's
1489 Handle(SALOME_InteractiveObject) IObject = It.Value();
1490 if(IObject->hasEntry()) {
1491 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1493 // disable removal of "SMESH" component object
1494 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1496 if ( engineIOR() == anIOR->Value().c_str() )
1499 //Check the referenced object
1500 _PTR(SObject) aRefSObject;
1501 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1502 aSO = aRefSObject; // Delete main Object instead of reference
1504 // put the whole hierarchy of sub-objects of the selected SO into a list and
1505 // then treat them all starting from the deepest objects (at list back)
1507 std::list< _PTR(SObject) > listSO;
1508 listSO.push_back( aSO );
1509 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1510 for ( ; itSO != listSO.end(); ++itSO ) {
1511 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1512 for (it->InitEx(false); it->More(); it->Next())
1513 listSO.push_back( it->Value() );
1516 // treat SO's in the list starting from the back
1518 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1519 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1520 _PTR(SObject) SO = *ritSO;
1521 if ( !SO ) continue;
1522 std::string anEntry = SO->GetID();
1524 /** Erase graphical object **/
1525 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1526 ViewManagerList aViewMenegers = anApp->viewManagers();
1527 ViewManagerList::const_iterator it = aViewMenegers.begin();
1528 for( ; it != aViewMenegers.end(); it++) {
1529 SUIT_ViewManager* vm = *it;
1530 int nbSf = vm ? vm->getViewsCount() : 0;
1532 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1533 for(int i = 0; i < nbSf; i++){
1534 SUIT_ViewWindow *sf = aViews[i];
1535 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1536 SMESH::RemoveActor(sf,anActor);
1542 /** Remove an object from data structures **/
1543 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1544 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1545 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1546 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1547 aMesh->RemoveGroup( aGroup );
1549 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1550 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1551 aMesh->RemoveSubMesh( aSubMesh );
1553 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1555 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1558 IObject = new SALOME_InteractiveObject
1559 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1560 QString objType = CheckTypeObject(IObject);
1561 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1562 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1563 aStudyBuilder->RemoveObjectWithChildren( SO );
1565 else {// default action: remove SObject from the study
1566 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1567 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1569 aStudyBuilder->RemoveObjectWithChildren( SO );
1573 } /* listSO back loop */
1574 } /* IObject->hasEntry() */
1577 aStudyBuilder->CommitCommand();
1579 /* Clear any previous selection */
1581 aSel->setSelectedObjects( l1 );
1583 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1588 SMESHGUI_EXPORT CAM_Module* createModule()
1590 return new SMESHGUI();
1594 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1596 //=============================================================================
1600 //=============================================================================
1601 SMESHGUI::SMESHGUI() :
1602 SalomeApp_Module( "SMESH" ),
1603 LightApp_Module( "SMESH" )
1605 if ( CORBA::is_nil( myComponentSMESH ) )
1607 CORBA::Boolean anIsEmbeddedMode;
1608 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1609 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1611 // 0019923: EDF 765 SMESH : default values of hypothesis
1612 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1613 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1614 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1615 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1616 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1619 myActiveDialogBox = 0;
1620 myFilterLibraryDlg = 0;
1624 myEventCallbackCommand = vtkCallbackCommand::New();
1625 myEventCallbackCommand->Delete();
1626 myEventCallbackCommand->SetClientData( this );
1627 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1630 SMESH::GetFilterManager();
1631 SMESH::GetPattern();
1632 SMESH::GetMeasurements();
1634 /* load resources for all available meshers */
1635 SMESH::InitAvailableHypotheses();
1638 //=============================================================================
1642 //=============================================================================
1643 SMESHGUI::~SMESHGUI()
1645 #ifdef WITHGENERICOBJ
1646 SMESH::GetFilterManager()->UnRegister();
1647 SMESH::GetMeasurements()->UnRegister();
1649 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1650 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1653 //=============================================================================
1657 //=============================================================================
1658 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1660 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1662 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1667 //=============================================================================
1671 //=============================================================================
1672 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1674 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1678 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1679 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1680 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1681 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1682 return autoUpdate && !exceeded;
1685 //=============================================================================
1689 //=============================================================================
1690 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1692 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1695 //=============================================================================
1699 //=============================================================================
1700 SMESHGUI* SMESHGUI::GetSMESHGUI()
1702 SMESHGUI* smeshMod = 0;
1703 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1706 CAM_Module* module = app->module( "Mesh" );
1707 smeshMod = dynamic_cast<SMESHGUI*>( module );
1710 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1712 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1715 _PTR(Study) aStudy = study->studyDS();
1717 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1726 Standard_EXPORT SMESHGUI* GetComponentGUI()
1728 return SMESHGUI::GetSMESHGUI();
1732 //=============================================================================
1736 //=============================================================================
1737 void SMESHGUI::SetState(int aState)
1742 //=============================================================================
1746 //=============================================================================
1747 void SMESHGUI::ResetState()
1752 //=============================================================================
1756 //=============================================================================
1757 void SMESHGUI::EmitSignalDeactivateDialog()
1759 emit SignalDeactivateActiveDialog();
1762 //=============================================================================
1766 //=============================================================================
1767 void SMESHGUI::EmitSignalStudyFrameChanged()
1769 emit SignalStudyFrameChanged();
1772 //=============================================================================
1776 //=============================================================================
1777 void SMESHGUI::EmitSignalCloseAllDialogs()
1779 emit SignalCloseAllDialogs();
1782 //=============================================================================
1786 //=============================================================================
1787 void SMESHGUI::EmitSignalVisibilityChanged()
1789 emit SignalVisibilityChanged();
1792 //=============================================================================
1796 //=============================================================================
1797 QDialog *SMESHGUI::GetActiveDialogBox()
1799 return myActiveDialogBox;
1802 //=============================================================================
1806 //=============================================================================
1807 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1809 myActiveDialogBox = (QDialog *) aDlg;
1813 //=============================================================================
1817 //=============================================================================
1818 SUIT_Desktop* SMESHGUI::desktop()
1820 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1822 return app->desktop();
1827 //=============================================================================
1831 //=============================================================================
1832 SalomeApp_Study* SMESHGUI::activeStudy()
1834 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1836 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1841 //=============================================================================
1845 //=============================================================================
1846 void SMESHGUI::Modified( bool theIsUpdateActions )
1848 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1849 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1850 appStudy->Modified();
1851 if( theIsUpdateActions )
1852 app->updateActions();
1857 //=============================================================================
1861 //=============================================================================
1862 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1864 /* Here the position is on the bottom right corner - 10 */
1865 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1867 SUIT_Desktop *PP = desktop();
1868 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1869 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1873 //=============================================================================
1877 //=============================================================================
1878 static int isStudyLocked(_PTR(Study) theStudy){
1879 return theStudy->GetProperties()->IsLocked();
1882 static bool checkLock(_PTR(Study) theStudy) {
1883 if (isStudyLocked(theStudy)) {
1884 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1885 QObject::tr("WRN_WARNING"),
1886 QObject::tr("WRN_STUDY_LOCKED") );
1892 //=======================================================================
1893 //function : CheckActiveStudyLocked
1895 //=======================================================================
1897 bool SMESHGUI::isActiveStudyLocked()
1899 _PTR(Study) aStudy = activeStudy()->studyDS();
1900 return checkLock( aStudy );
1903 //=============================================================================
1907 //=============================================================================
1908 bool SMESHGUI::OnGUIEvent( int theCommandID )
1910 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1914 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1915 SUIT_ResourceMgr* mgr = resourceMgr();
1919 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1920 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1923 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1924 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1926 //QAction* act = action( theCommandID );
1928 switch (theCommandID) {
1930 if(checkLock(aStudy)) break;
1940 if(checkLock(aStudy)) break;
1941 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1945 case 150: //MED FILE INFORMATION
1947 SALOME_ListIO selected;
1948 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1950 aSel->selectedObjects( selected );
1951 if( selected.Extent() )
1953 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1954 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1955 if ( !aMesh->_is_nil() )
1957 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1964 case 122: // EXPORT MED
1975 ::ExportMeshToFile(theCommandID);
1979 case 200: // SCALAR BAR
1981 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1982 SALOME_ListIO selected;
1984 aSel->selectedObjects( selected );
1986 if( selected.Extent() ) {
1987 Handle(SALOME_InteractiveObject) anIO = selected.First();
1988 if( anIO->hasEntry() ) {
1989 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1990 anActor->SetControlMode( SMESH_Actor::eNone );
1991 #ifndef DISABLE_PLOT2DVIEWER
1992 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2001 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2006 // dump control distribution data to the text file
2007 ::SaveDistribution();
2013 // show/ distribution
2014 ::ShowDistribution();
2018 #ifndef DISABLE_PLOT2DVIEWER
2021 // plot distribution
2022 ::PlotDistribution();
2033 ::DisableAutoColor();
2036 case 1134: // Clipping
2037 case 1133: // Tranparency
2038 case 1132: // Colors / Size
2045 ::SetDisplayMode(theCommandID, myMarkerMap);
2048 //2D quadratic representation
2051 ::SetDisplayMode(theCommandID, myMarkerMap);
2055 case 216: // 0D elements
2058 case 219: // Volumes
2059 case 220: // All Entity
2060 ::SetDisplayEntity(theCommandID);
2063 case 221: // Orientation of faces
2065 LightApp_SelectionMgr* mgr = selectionMgr();
2066 SALOME_ListIO selected; mgr->selectedObjects( selected );
2068 SALOME_ListIteratorOfListIO it(selected);
2069 for( ; it.More(); it.Next()) {
2070 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2071 if(anIObject->hasEntry()) {
2072 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2073 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2082 if(checkLock(aStudy)) break;
2084 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2087 SMESH::UpdateView();
2089 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2090 SMESH::OnVisuException();
2092 catch (...) { // PAL16774 (Crash after display of many groups)
2093 SMESH::OnVisuException();
2097 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2098 aSel->selectedObjects( l );
2099 aSel->setSelectedObjects( l );
2104 case 301: // DISPLAY
2105 case 302: // DISPLAY ONLY
2107 SMESH::EDisplaing anAction;
2108 switch (theCommandID) {
2109 case 300: anAction = SMESH::eErase; break;
2110 case 301: anAction = SMESH::eDisplay; break;
2111 case 302: anAction = SMESH::eDisplayOnly; break;
2114 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2115 SALOME_ListIO sel_objects, to_process;
2117 aSel->selectedObjects( sel_objects );
2119 if( theCommandID==302 )
2121 MESSAGE("anAction = SMESH::eDisplayOnly");
2122 startOperation( myEraseAll );
2125 extractContainers( sel_objects, to_process );
2128 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2132 SALOME_ListIteratorOfListIO It( to_process );
2133 for ( ; It.More(); It.Next()) {
2135 Handle(SALOME_InteractiveObject) IOS = It.Value();
2136 if (IOS->hasEntry()) {
2138 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2139 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2140 break; // PAL16774 (Crash after display of many groups)
2142 if (anAction == SMESH::eDisplayOnly)
2144 MESSAGE("anAction = SMESH::eDisplayOnly");
2145 anAction = SMESH::eDisplay;
2151 // PAL13338 + PAL15161 -->
2152 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2153 MESSAGE("anAction = SMESH::eDisplayOnly");
2154 SMESH::UpdateView();
2155 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2157 // PAL13338 + PAL15161 <--
2159 catch (...) { // PAL16774 (Crash after display of many groups)
2160 SMESH::OnVisuException();
2163 if (anAction == SMESH::eErase) {
2164 MESSAGE("anAction == SMESH::eErase");
2166 aSel->setSelectedObjects( l1 );
2169 aSel->setSelectedObjects( to_process );
2176 if(checkLock(aStudy)) break;
2179 EmitSignalDeactivateDialog();
2181 ( new SMESHGUI_NodesDlg( this ) )->show();
2184 SUIT_MessageBox::warning(desktop(),
2185 tr("SMESH_WRN_WARNING"),
2186 tr("SMESH_WRN_VIEWER_VTK"));
2191 case 2151: // FILTER
2195 EmitSignalDeactivateDialog();
2196 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2201 case 701: // COMPUTE MESH
2202 case 711: // PRECOMPUTE MESH
2203 case 712: // EVALUATE MESH
2204 case 713: // MESH ORDER
2206 if (checkLock(aStudy)) break;
2207 startOperation( theCommandID );
2211 case 702: // Create mesh
2212 case 703: // Create sub-mesh
2213 case 704: // Edit mesh/sub-mesh
2214 startOperation( theCommandID );
2216 case 705: // copy mesh
2218 if (checkLock(aStudy)) break;
2219 EmitSignalDeactivateDialog();
2220 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2223 case 710: // Build compound mesh
2225 if (checkLock(aStudy)) break;
2226 EmitSignalDeactivateDialog();
2227 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2231 case 407: // DIAGONAL INVERSION
2232 case 408: // Delete diagonal
2236 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2237 tr( "NOT_A_VTK_VIEWER" ) );
2241 if ( checkLock( aStudy ) )
2244 /*Standard_Boolean aRes;
2245 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2246 if ( aMesh->_is_nil() )
2248 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2249 tr( "SMESH_BAD_SELECTION" ) );
2253 EmitSignalDeactivateDialog();
2254 if ( theCommandID == 407 )
2255 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2257 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2260 case 409: // Change orientation
2261 case 410: // Union of triangles
2262 case 411: // Cutting of quadrangles
2263 case 419: // Splitting volumes into tetrahedra
2267 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2268 tr( "NOT_A_VTK_VIEWER" ) );
2272 if ( checkLock( aStudy ) )
2275 EmitSignalDeactivateDialog();
2276 SMESHGUI_MultiEditDlg* aDlg = NULL;
2277 if ( theCommandID == 409 )
2278 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2279 else if ( theCommandID == 410 )
2280 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2281 else if ( theCommandID == 419 )
2282 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2284 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2289 case 412: // Smoothing
2291 if(checkLock(aStudy)) break;
2293 EmitSignalDeactivateDialog();
2294 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2297 SUIT_MessageBox::warning(desktop(),
2298 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2302 case 413: // Extrusion
2304 if (checkLock(aStudy)) break;
2306 EmitSignalDeactivateDialog();
2307 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2309 SUIT_MessageBox::warning(desktop(),
2310 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2314 case 414: // Revolution
2316 if(checkLock(aStudy)) break;
2318 EmitSignalDeactivateDialog();
2319 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2322 SUIT_MessageBox::warning(desktop(),
2323 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2327 case 415: // Pattern mapping
2329 if ( checkLock( aStudy ) )
2333 EmitSignalDeactivateDialog();
2334 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2337 SUIT_MessageBox::warning(desktop(),
2338 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2342 case 416: // Extrusion along a path
2344 if (checkLock(aStudy)) break;
2346 EmitSignalDeactivateDialog();
2347 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2349 SUIT_MessageBox::warning(desktop(),
2350 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2354 case 417: // Convert mesh to quadratic
2356 startOperation( 417 );
2357 /* if (checkLock(aStudy)) break;
2359 EmitSignalDeactivateDialog();
2360 new SMESHGUI_ConvToQuadDlg();
2362 SUIT_MessageBox::warning(desktop(),
2363 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2367 case 418: // create 2D mesh from 3D
2369 startOperation( 418 );
2372 case 806: // CREATE GEO GROUP
2374 startOperation( 806 );
2377 case 801: // CREATE GROUP
2381 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2382 tr( "NOT_A_VTK_VIEWER" ) );
2386 if(checkLock(aStudy)) break;
2387 EmitSignalDeactivateDialog();
2388 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2390 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2391 SALOME_ListIO selected;
2393 aSel->selectedObjects( selected );
2395 int nbSel = selected.Extent();
2397 // check if mesh is selected
2398 aMesh = SMESH::GetMeshByIO( selected.First() );
2400 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2405 case 802: // CONSTRUCT GROUP
2409 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2410 tr( "NOT_A_VTK_VIEWER" ) );
2414 if(checkLock(aStudy)) break;
2415 EmitSignalDeactivateDialog();
2417 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2418 SALOME_ListIO selected;
2420 aSel->selectedObjects( selected );
2422 int nbSel = selected.Extent();
2424 // check if submesh is selected
2425 Handle(SALOME_InteractiveObject) IObject = selected.First();
2426 if (IObject->hasEntry()) {
2427 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2429 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2430 if (!aSubMesh->_is_nil()) {
2432 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2433 // get submesh elements list by types
2434 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2435 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2436 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2437 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2438 // create group for each type o elements
2439 QString aName = IObject->getName();
2440 QStringList anEntryList;
2441 if (aNodes->length() > 0) {
2442 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2443 aGroup->Add(aNodes.inout());
2444 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2445 anEntryList.append( aSObject->GetID().c_str() );
2447 if (aEdges->length() > 0) {
2448 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2449 aGroup->Add(aEdges.inout());
2450 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2451 anEntryList.append( aSObject->GetID().c_str() );
2453 if (aFaces->length() > 0) {
2454 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2455 aGroup->Add(aFaces.inout());
2456 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2457 anEntryList.append( aSObject->GetID().c_str() );
2459 if (aVolumes->length() > 0) {
2460 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2461 aGroup->Add(aVolumes.inout());
2462 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2463 anEntryList.append( aSObject->GetID().c_str() );
2466 anApp->browseObjects( anEntryList );
2468 catch(const SALOME::SALOME_Exception & S_ex){
2469 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2476 SUIT_MessageBox::warning(desktop(),
2477 tr("SMESH_WRN_WARNING"),
2478 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2483 case 803: // EDIT GROUP
2487 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2488 tr( "NOT_A_VTK_VIEWER" ) );
2492 if(checkLock(aStudy)) break;
2493 EmitSignalDeactivateDialog();
2495 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2496 SALOME_ListIO selected;
2498 aSel->selectedObjects( selected );
2500 SALOME_ListIteratorOfListIO It (selected);
2501 int nbSelectedGroups = 0;
2502 for ( ; It.More(); It.Next() )
2504 SMESH::SMESH_GroupBase_var aGroup =
2505 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2506 if (!aGroup->_is_nil()) {
2508 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2512 if (nbSelectedGroups == 0)
2514 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2520 case 804: // Add elements to group
2522 if(checkLock(aStudy)) break;
2523 if (myState == 800) {
2524 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2525 if (aDlg) aDlg->onAdd();
2530 case 805: // Remove elements from group
2532 if(checkLock(aStudy)) break;
2533 if (myState == 800) {
2534 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2535 if (aDlg) aDlg->onRemove();
2540 case 815: // Edit GEOM GROUP as standalone
2544 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2545 tr( "NOT_A_VTK_VIEWER" ) );
2549 if(checkLock(aStudy)) break;
2550 EmitSignalDeactivateDialog();
2552 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2553 SALOME_ListIO selected;
2555 aSel->selectedObjects( selected );
2557 SALOME_ListIteratorOfListIO It (selected);
2558 for ( ; It.More(); It.Next() )
2560 SMESH::SMESH_GroupOnGeom_var aGroup =
2561 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2562 if (!aGroup->_is_nil()) {
2563 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2568 SMESH::SMESH_GroupOnFilter_var aGroup =
2569 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2570 if (!aGroup->_is_nil()) {
2571 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2579 case 810: // Union Groups
2580 case 811: // Intersect groups
2581 case 812: // Cut groups
2585 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2586 tr( "NOT_A_VTK_VIEWER" ) );
2590 if ( checkLock( aStudy ) )
2593 EmitSignalDeactivateDialog();
2595 SMESHGUI_GroupOpDlg* aDlg = 0;
2596 if ( theCommandID == 810 )
2597 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2598 else if ( theCommandID == 811 )
2599 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2601 aDlg = new SMESHGUI_CutGroupsDlg( this );
2608 case 814: // Create groups of entities from existing groups of superior dimensions
2610 if ( checkLock( aStudy ) )
2613 EmitSignalDeactivateDialog();
2614 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2620 case 813: // Delete groups with their contents
2624 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2625 tr( "NOT_A_VTK_VIEWER" ) );
2629 if ( checkLock( aStudy ) )
2632 EmitSignalDeactivateDialog();
2634 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2638 case 900: // MESH INFOS
2639 case 903: // WHAT IS
2641 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2642 EmitSignalDeactivateDialog();
2643 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2644 SALOME_ListIO selected;
2646 aSel->selectedObjects( selected );
2648 if ( selected.Extent() > 1 ) { // a dlg for each IO
2649 SALOME_ListIteratorOfListIO It( selected );
2650 for ( ; It.More(); It.Next() ) {
2651 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2652 dlg->showInfo( It.Value() );
2657 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2663 case 902: // STANDARD MESH INFOS
2665 EmitSignalDeactivateDialog();
2666 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2667 SALOME_ListIO selected;
2669 aSel->selectedObjects( selected );
2671 if ( selected.Extent() > 1 ) { // a dlg for each IO
2673 SALOME_ListIteratorOfListIO It (selected);
2674 for ( ; It.More(); It.Next() ) {
2676 IOs.Append( It.Value() );
2677 aSel->setSelectedObjects( IOs );
2678 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2680 // restore selection
2681 aSel->setSelectedObjects( selected );
2684 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2687 case 903: // WHAT IS
2689 EmitSignalDeactivateDialog();
2690 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2695 case 904: // FIND ELEM
2697 startOperation( theCommandID );
2701 case 1100: // EDIT HYPOTHESIS
2703 if(checkLock(aStudy)) break;
2705 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2706 SALOME_ListIO selected;
2708 aSel->selectedObjects( selected );
2710 int nbSel = selected.Extent();
2713 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2714 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2716 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2717 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2718 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2719 if ( !aHypothesis->_is_nil() )
2722 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2723 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2725 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2735 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2737 if(checkLock(aStudy)) break;
2738 SUIT_OverrideCursor wc;
2740 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2741 SALOME_ListIO selected;
2743 aSel->selectedObjects( selected, QString::null, false );
2745 SALOME_ListIteratorOfListIO It(selected);
2746 for (int i = 0; It.More(); It.Next(), i++) {
2747 Handle(SALOME_InteractiveObject) IObject = It.Value();
2748 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2751 aSel->setSelectedObjects( l1 );
2756 case 4009: // ELEM0D
2757 case 4010: // GEOM::EDGE
2758 case 4021: // TRIANGLE
2760 case 4023: // POLYGON
2764 if(checkLock(aStudy)) break;
2766 EmitSignalDeactivateDialog();
2767 SMDSAbs_ElementType type = SMDSAbs_Edge;
2769 switch (theCommandID) {
2770 case 4009: // ELEM0D
2771 type = SMDSAbs_0DElement; nbNodes = 1; break;
2772 case 4021: // TRIANGLE
2773 type = SMDSAbs_Face; nbNodes = 3; break;
2775 type = SMDSAbs_Face; nbNodes = 4; break;
2777 type = SMDSAbs_Volume; nbNodes = 4; break;
2778 case 4023: // POLYGON
2779 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2781 type = SMDSAbs_Volume; nbNodes = 8; break;
2782 case 4033: // POLYHEDRE
2783 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2786 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2789 SUIT_MessageBox::warning(desktop(),
2790 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2794 case 4033: // POLYHEDRON
2796 if(checkLock(aStudy)) break;
2798 EmitSignalDeactivateDialog();
2799 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2802 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2803 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2807 case 4034: // QUADRATIC EDGE
2808 case 4035: // QUADRATIC TRIANGLE
2809 case 4036: // QUADRATIC QUADRANGLE
2810 case 4037: // QUADRATIC TETRAHEDRON
2811 case 4038: // QUADRATIC PYRAMID
2812 case 4039: // QUADRATIC PENTAHEDRON
2813 case 4040: // QUADRATIC HEXAHEDRON
2815 if(checkLock(aStudy)) break;
2817 EmitSignalDeactivateDialog();
2820 switch (theCommandID) {
2822 type = QUAD_EDGE; break;
2824 type = QUAD_TRIANGLE; break;
2826 type = QUAD_QUADRANGLE; break;
2828 type = QUAD_TETRAHEDRON; break;
2830 type = QUAD_PYRAMID; break;
2832 type = QUAD_PENTAHEDRON; break;
2834 type = QUAD_HEXAHEDRON;
2838 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2841 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2842 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2846 case 4041: // REMOVES NODES
2848 if(checkLock(aStudy)) break;
2850 EmitSignalDeactivateDialog();
2851 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2854 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2855 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2859 case 4042: // REMOVES ELEMENTS
2861 if(checkLock(aStudy)) break;
2863 EmitSignalDeactivateDialog();
2864 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2868 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2869 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2873 case 4043: { // CLEAR_MESH
2875 if(checkLock(aStudy)) break;
2877 SALOME_ListIO selected;
2878 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2879 aSel->selectedObjects( selected );
2881 SUIT_OverrideCursor wc;
2882 SALOME_ListIteratorOfListIO It (selected);
2883 for ( ; It.More(); It.Next() )
2885 Handle(SALOME_InteractiveObject) IOS = It.Value();
2886 SMESH::SMESH_Mesh_var aMesh =
2887 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2888 if ( aMesh->_is_nil()) continue;
2890 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2892 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2893 SMESH::ModifiedMesh( aMeshSObj, false, true);
2894 // hide groups and submeshes
2895 _PTR(ChildIterator) anIter =
2896 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2897 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2899 _PTR(SObject) so = anIter->Value();
2900 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2903 catch (const SALOME::SALOME_Exception& S_ex){
2905 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2909 SMESH::UpdateView();
2913 case 4044: // REMOVE ORPHAN NODES
2915 if(checkLock(aStudy)) break;
2916 SALOME_ListIO selected;
2917 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2918 aSel->selectedObjects( selected );
2919 if ( selected.Extent() == 1 ) {
2920 Handle(SALOME_InteractiveObject) anIO = selected.First();
2921 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2922 if ( !aMesh->_is_nil() ) {
2923 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2924 tr( "SMESH_WARNING" ),
2925 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2926 SUIT_MessageBox::Yes |
2927 SUIT_MessageBox::No,
2928 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2931 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2932 int removed = aMeshEditor->RemoveOrphanNodes();
2933 SUIT_MessageBox::information(SMESHGUI::desktop(),
2934 tr("SMESH_INFORMATION"),
2935 tr("NB_NODES_REMOVED").arg(removed));
2936 if ( removed > 0 ) {
2937 SMESH::UpdateView();
2938 SMESHGUI::Modified();
2941 catch (const SALOME::SALOME_Exception& S_ex) {
2942 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2951 case 4051: // RENUMBERING NODES
2953 if(checkLock(aStudy)) break;
2955 EmitSignalDeactivateDialog();
2956 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2960 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2961 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2965 case 4052: // RENUMBERING ELEMENTS
2967 if(checkLock(aStudy)) break;
2969 EmitSignalDeactivateDialog();
2970 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2974 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2975 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2979 case 4061: // TRANSLATION
2981 if(checkLock(aStudy)) break;
2983 EmitSignalDeactivateDialog();
2984 ( new SMESHGUI_TranslationDlg( this ) )->show();
2987 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2988 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2992 case 4062: // ROTATION
2994 if(checkLock(aStudy)) break;
2996 EmitSignalDeactivateDialog();
2997 ( new SMESHGUI_RotationDlg( this ) )->show();
3000 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3001 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3005 case 4063: // SYMMETRY
3007 if(checkLock(aStudy)) break;
3009 EmitSignalDeactivateDialog();
3010 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3013 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3014 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3018 case 4064: // SEWING
3020 if(checkLock(aStudy)) break;
3022 EmitSignalDeactivateDialog();
3023 ( new SMESHGUI_SewingDlg( this ) )->show();
3026 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3027 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3031 case 4065: // MERGE NODES
3033 if(checkLock(aStudy)) break;
3035 EmitSignalDeactivateDialog();
3036 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3039 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3040 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3044 case 4066: // MERGE EQUAL ELEMENTS
3046 if (checkLock(aStudy)) break;
3048 EmitSignalDeactivateDialog();
3049 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3051 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3052 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3057 case 4067: // MAKE MESH PASS THROUGH POINT
3058 startOperation( 4067 );
3063 if(checkLock(aStudy)) break;
3065 EmitSignalDeactivateDialog();
3066 ( new SMESHGUI_ScaleDlg( this ) )->show();
3069 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3070 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3075 case 4069: // DUPLICATE NODES
3077 if(checkLock(aStudy)) break;
3079 EmitSignalDeactivateDialog();
3080 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3083 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3084 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3089 case 5105: // Library of selection filters
3091 static QList<int> aTypes;
3092 if ( aTypes.isEmpty() )
3094 aTypes.append( SMESH::NODE );
3095 aTypes.append( SMESH::EDGE );
3096 aTypes.append( SMESH::FACE );
3097 aTypes.append( SMESH::VOLUME );
3099 if (!myFilterLibraryDlg)
3100 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3101 else if (myFilterLibraryDlg->isHidden())
3102 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3103 myFilterLibraryDlg->raise();
3107 case 6017: // CONTROLS
3131 LightApp_SelectionMgr* mgr = selectionMgr();
3132 SALOME_ListIO selected; mgr->selectedObjects( selected );
3134 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3135 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3137 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3138 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3139 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3140 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3141 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3142 ::Control( theCommandID );
3147 SUIT_MessageBox::warning(desktop(),
3148 tr( "SMESH_WRN_WARNING" ),
3149 tr( "SMESH_BAD_SELECTION" ) );
3153 SUIT_MessageBox::warning(desktop(),
3154 tr( "SMESH_WRN_WARNING" ),
3155 tr( "NOT_A_VTK_VIEWER" ) );
3160 LightApp_SelectionMgr* mgr = selectionMgr();
3161 SALOME_ListIO selected; mgr->selectedObjects( selected );
3163 SALOME_ListIteratorOfListIO it(selected);
3164 for( ; it.More(); it.Next()) {
3165 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3166 if(anIObject->hasEntry()) {
3167 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3168 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3176 LightApp_SelectionMgr* mgr = selectionMgr();
3177 SALOME_ListIO selected; mgr->selectedObjects( selected );
3179 SALOME_ListIteratorOfListIO it(selected);
3180 for( ; it.More(); it.Next()) {
3181 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3182 if(anIObject->hasEntry())
3183 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3184 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3192 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3193 EmitSignalDeactivateDialog();
3194 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3200 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3201 //updateObjBrowser();
3205 //=============================================================================
3209 //=============================================================================
3210 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3215 //=============================================================================
3219 //=============================================================================
3220 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3225 //=============================================================================
3229 //=============================================================================
3230 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3235 //=============================================================================
3236 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3237 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3239 //=============================================================================
3240 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3241 SUIT_ViewWindow* wnd )
3243 if(theIO->hasEntry()){
3244 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3245 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3249 //=======================================================================
3250 // function : createSMESHAction
3252 //=======================================================================
3253 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3254 const int key, const bool toggle, const QString& shortcutAction )
3257 QWidget* parent = application()->desktop();
3258 SUIT_ResourceMgr* resMgr = resourceMgr();
3260 if ( !icon_id.isEmpty() )
3261 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3263 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3264 if ( !pix.isNull() )
3265 icon = QIcon( pix );
3267 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3268 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3269 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3271 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3272 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3275 //=======================================================================
3276 // function : createPopupItem
3278 //=======================================================================
3279 void SMESHGUI::createPopupItem( const int id,
3280 const QString& clients,
3281 const QString& types,
3282 const QString& theRule,
3287 parentId = popupMgr()->actionId( action( pId ) );
3289 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3290 popupMgr()->insert( action( id ), parentId, 0 );
3292 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3293 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3294 QString rule = "(%1) and (%2) and (%3)";
3295 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3296 if( clients.isEmpty() )
3297 rule = rule.arg( QString( "true" ) );
3299 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3300 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3303 bool cont = myRules.contains( id );
3305 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3307 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3308 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3311 //=======================================================================
3312 // function : initialize
3314 //=======================================================================
3315 void SMESHGUI::initialize( CAM_Application* app )
3317 SalomeApp_Module::initialize( app );
3319 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3321 /* Automatic Update flag */
3322 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3324 // ----- create actions --------------
3326 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3327 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3328 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3329 createSMESHAction( 114, "NUM" );
3330 createSMESHAction( 115, "STL" );
3331 createSMESHAction( 116, "CGNS" );
3332 createSMESHAction( 121, "DAT" );
3333 createSMESHAction( 122, "MED" );
3334 createSMESHAction( 123, "UNV" );
3335 createSMESHAction( 140, "STL" );
3336 createSMESHAction( 142, "CGNS" );
3337 createSMESHAction( 124, "EXPORT_DAT" );
3338 createSMESHAction( 125, "EXPORT_MED" );
3339 createSMESHAction( 126, "EXPORT_UNV" );
3340 createSMESHAction( 141, "EXPORT_STL" );
3341 createSMESHAction( 143, "EXPORT_CGNS" );
3342 createSMESHAction( 150, "FILE_INFO" );
3343 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3344 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3345 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3346 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3347 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3348 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3349 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3350 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3351 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3352 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3353 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3354 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3355 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3356 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3357 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3358 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3359 createSMESHAction( 804, "ADD" );
3360 createSMESHAction( 805, "REMOVE" );
3361 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3362 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3363 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3364 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3365 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3366 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3367 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3368 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3369 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3370 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3371 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3372 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3373 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3374 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3375 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3376 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3377 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3378 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3379 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3380 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3381 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3382 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3383 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3384 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3385 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3386 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3387 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3388 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3389 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3390 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3391 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3392 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3393 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3394 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3395 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3396 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3397 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3398 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3399 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3400 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3401 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3402 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3403 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3404 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3405 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3406 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3407 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3408 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3409 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3410 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3411 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3412 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3413 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3414 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3415 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3416 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3417 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3418 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3419 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3420 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3421 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3422 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3423 createSMESHAction( 415, "MAP", "ICON_MAP" );
3424 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3425 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3426 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3427 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3428 createSMESHAction( 200, "RESET" );
3429 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3430 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3431 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3432 #ifndef DISABLE_PLOT2DVIEWER
3433 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3435 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3436 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3437 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3438 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3439 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3440 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3441 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3442 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3443 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3444 createSMESHAction( 220, "ALL" );
3445 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3447 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3448 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3450 createSMESHAction( 1100, "EDIT_HYPO" );
3451 createSMESHAction( 1102, "UNASSIGN" );
3452 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3453 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3454 createSMESHAction( 1131, "DISPMODE" );
3455 createSMESHAction( 1132, "COLORS" );
3456 createSMESHAction( 1133, "TRANSP" );
3457 createSMESHAction( 1134, "CLIP" );
3458 createSMESHAction( 1135, "DISP_ENT" );
3459 createSMESHAction( 1136, "AUTO_COLOR" );
3460 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3461 createSMESHAction( 2000, "CTRL" );
3463 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3464 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3466 createSMESHAction( 300, "ERASE" );
3467 createSMESHAction( 301, "DISPLAY" );
3468 createSMESHAction( 302, "DISPLAY_ONLY" );
3469 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3470 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3471 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3472 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3473 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3474 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3475 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3476 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3478 // ----- create menu --------------
3479 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3480 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3481 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3482 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3483 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3484 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3485 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3486 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3488 createMenu( separator(), fileId );
3490 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3491 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3492 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3493 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3494 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3495 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3496 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3497 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3498 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3499 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3501 createMenu( 111, importId, -1 );
3502 createMenu( 112, importId, -1 );
3503 createMenu( 113, importId, -1 );
3504 createMenu( 115, importId, -1 );
3506 createMenu( 116, importId, -1 );
3508 createMenu( 121, exportId, -1 );
3509 createMenu( 122, exportId, -1 );
3510 createMenu( 123, exportId, -1 );
3511 createMenu( 140, exportId, -1 ); // export to STL
3513 createMenu( 142, exportId, -1 ); // export to CGNS
3515 createMenu( separator(), fileId, 10 );
3517 createMenu( 33, editId, -1 );
3519 createMenu( 5105, toolsId, -1 );
3521 createMenu( 702, meshId, -1 ); // "Mesh" menu
3522 createMenu( 703, meshId, -1 );
3523 createMenu( 704, meshId, -1 );
3524 createMenu( 710, meshId, -1 );
3525 createMenu( 705, meshId, -1 );
3526 createMenu( separator(), meshId, -1 );
3527 createMenu( 701, meshId, -1 );
3528 createMenu( 711, meshId, -1 );
3529 createMenu( 712, meshId, -1 );
3530 createMenu( 713, meshId, -1 );
3531 createMenu( separator(), meshId, -1 );
3532 createMenu( 801, meshId, -1 );
3533 createMenu( 806, meshId, -1 );
3534 createMenu( 802, meshId, -1 );
3535 createMenu( 803, meshId, -1 );
3536 createMenu( 815, meshId, -1 );
3537 createMenu( separator(), meshId, -1 );
3538 createMenu( 810, meshId, -1 );
3539 createMenu( 811, meshId, -1 );
3540 createMenu( 812, meshId, -1 );
3541 createMenu( separator(), meshId, -1 );
3542 createMenu( 814, meshId, -1 );
3543 createMenu( separator(), meshId, -1 );
3544 createMenu( 900, meshId, -1 );
3545 //createMenu( 902, meshId, -1 );
3546 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3547 createMenu( 904, meshId, -1 );
3548 createMenu( separator(), meshId, -1 );
3550 createMenu( 6005, nodeId, -1 );
3551 createMenu( 6002, edgeId, -1 );
3552 createMenu( 6003, edgeId, -1 );
3553 createMenu( 6001, edgeId, -1 );
3554 createMenu( 6004, edgeId, -1 );
3555 createMenu( 6021, faceId, -1 );
3556 createMenu( 6025, faceId, -1 );
3557 createMenu( 6027, faceId, -1 );
3558 createMenu( 6018, faceId, -1 );
3559 createMenu( 6019, faceId, -1 );
3560 createMenu( 6011, faceId, -1 );
3561 createMenu( 6012, faceId, -1 );
3562 createMenu( 6013, faceId, -1 );
3563 createMenu( 6014, faceId, -1 );
3564 createMenu( 6015, faceId, -1 );
3565 createMenu( 6016, faceId, -1 );
3566 createMenu( 6022, faceId, -1 );
3567 createMenu( 6017, volumeId, -1 );
3568 createMenu( 6009, volumeId, -1 );
3569 createMenu( 6023, volumeId, -1 );
3570 createMenu( 6024, volumeId, -1 );
3571 createMenu( 6026, volumeId, -1 );
3573 createMenu( 4000, addId, -1 );
3574 createMenu( 4009, addId, -1 );
3575 createMenu( 4010, addId, -1 );
3576 createMenu( 4021, addId, -1 );
3577 createMenu( 4022, addId, -1 );
3578 createMenu( 4023, addId, -1 );
3579 createMenu( 4031, addId, -1 );
3580 createMenu( 4032, addId, -1 );
3581 createMenu( 4033, addId, -1 );
3582 createMenu( separator(), addId, -1 );
3583 createMenu( 4034, addId, -1 );
3584 createMenu( 4035, addId, -1 );
3585 createMenu( 4036, addId, -1 );
3586 createMenu( 4037, addId, -1 );
3587 createMenu( 4038, addId, -1 );
3588 createMenu( 4039, addId, -1 );
3589 createMenu( 4040, addId, -1 );
3591 createMenu( 4041, removeId, -1 );
3592 createMenu( 4042, removeId, -1 );
3593 createMenu( 4044, removeId, -1 );
3594 createMenu( separator(), removeId, -1 );
3595 createMenu( 813, removeId, -1 );
3596 createMenu( separator(), removeId, -1 );
3597 createMenu( 4043, removeId, -1 );
3599 createMenu( 4051, renumId, -1 );
3600 createMenu( 4052, renumId, -1 );
3602 createMenu( 4061, transfId, -1 );
3603 createMenu( 4062, transfId, -1 );
3604 createMenu( 4063, transfId, -1 );
3605 createMenu( 4068, transfId, -1 );
3606 createMenu( 4064, transfId, -1 );
3607 createMenu( 4065, transfId, -1 );
3608 createMenu( 4066, transfId, -1 );
3609 createMenu( 4069, transfId, -1 );
3611 createMenu( 4067,modifyId, -1 );
3612 createMenu( 407, modifyId, -1 );
3613 createMenu( 408, modifyId, -1 );
3614 createMenu( 409, modifyId, -1 );
3615 createMenu( 410, modifyId, -1 );
3616 createMenu( 411, modifyId, -1 );
3617 createMenu( 419, modifyId, -1 );
3618 createMenu( 412, modifyId, -1 );
3619 createMenu( 413, modifyId, -1 );
3620 createMenu( 416, modifyId, -1 );
3621 createMenu( 414, modifyId, -1 );
3622 createMenu( 415, modifyId, -1 );
3623 createMenu( 417, modifyId, -1 );
3624 createMenu( 418, modifyId, -1 );
3626 createMenu( 501, measureId, -1 );
3627 createMenu( 502, measureId, -1 );
3628 createMenu( 214, viewId, -1 );
3630 // ----- create toolbars --------------
3631 int meshTb = createTool( tr( "TB_MESH" ) ),
3632 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3633 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3634 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3635 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3637 createTool( 702, meshTb );
3638 createTool( 703, meshTb );
3639 createTool( 704, meshTb );
3640 createTool( 710, meshTb );
3641 createTool( 705, meshTb );
3642 createTool( separator(), meshTb );
3643 createTool( 701, meshTb );
3644 createTool( 711, meshTb );
3645 createTool( 712, meshTb );
3646 createTool( 713, meshTb );
3647 createTool( separator(), meshTb );
3648 createTool( 801, meshTb );
3649 createTool( 806, meshTb );
3650 createTool( 802, meshTb );
3651 createTool( 803, meshTb );
3652 //createTool( 815, meshTb );
3653 createTool( separator(), meshTb );
3654 createTool( 900, meshTb );
3655 //createTool( 902, meshTb );
3656 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3657 createTool( 904, meshTb );
3658 createTool( separator(), meshTb );
3660 createTool( 6005, ctrlTb );
3661 createTool( separator(), ctrlTb );
3662 createTool( 6002, ctrlTb );
3663 createTool( 6003, ctrlTb );
3664 createTool( 6001, ctrlTb );
3665 createTool( 6004, ctrlTb );
3666 createTool( separator(), ctrlTb );
3667 createTool( 6021, ctrlTb );
3668 createTool( 6025, ctrlTb );
3669 createTool( 6027, ctrlTb );
3670 createTool( 6018, ctrlTb );
3671 createTool( 6019, ctrlTb );
3672 createTool( 6011, ctrlTb );
3673 createTool( 6012, ctrlTb );
3674 createTool( 6013, ctrlTb );
3675 createTool( 6014, ctrlTb );
3676 createTool( 6015, ctrlTb );
3677 createTool( 6016, ctrlTb );
3678 createTool( 6022, ctrlTb );
3679 createTool( separator(), ctrlTb );
3680 createTool( 6017, ctrlTb );
3681 createTool( 6009, ctrlTb );
3682 createTool( 6023, ctrlTb );
3683 createTool( 6024, ctrlTb );
3684 createTool( 6026, ctrlTb );
3685 createTool( separator(), ctrlTb );
3687 createTool( 4000, addRemTb );
3688 createTool( 4009, addRemTb );
3689 createTool( 4010, addRemTb );
3690 createTool( 4021, addRemTb );
3691 createTool( 4022, addRemTb );
3692 createTool( 4023, addRemTb );
3693 createTool( 4031, addRemTb );
3694 createTool( 4032, addRemTb );
3695 createTool( 4033, addRemTb );
3696 createTool( separator(), addRemTb );
3697 createTool( 4034, addRemTb );
3698 createTool( 4035, addRemTb );
3699 createTool( 4036, addRemTb );
3700 createTool( 4037, addRemTb );
3701 createTool( 4038, addRemTb );
3702 createTool( 4039, addRemTb );
3703 createTool( 4040, addRemTb );
3704 createTool( separator(), addRemTb );
3705 createTool( 4041, addRemTb );
3706 createTool( 4042, addRemTb );
3707 createTool( 4044, addRemTb );
3708 createTool( 4043, addRemTb );
3709 createTool( separator(), addRemTb );
3710 createTool( 4051, addRemTb );
3711 createTool( 4052, addRemTb );
3712 createTool( separator(), addRemTb );
3713 createTool( 4061, addRemTb );
3714 createTool( 4062, addRemTb );
3715 createTool( 4063, addRemTb );
3716 createTool( 4068, addRemTb );
3717 createTool( 4064, addRemTb );
3718 createTool( 4065, addRemTb );
3719 createTool( 4066, addRemTb );
3720 createTool( 4069, addRemTb );
3721 createTool( separator(), addRemTb );
3723 createTool( 4067,modifyTb );
3724 createTool( 407, modifyTb );
3725 createTool( 408, modifyTb );
3726 createTool( 409, modifyTb );
3727 createTool( 410, modifyTb );
3728 createTool( 411, modifyTb );
3729 createTool( 419, modifyTb );
3730 createTool( 412, modifyTb );
3731 createTool( 413, modifyTb );
3732 createTool( 416, modifyTb );
3733 createTool( 414, modifyTb );
3734 createTool( 415, modifyTb );
3735 createTool( 417, modifyTb );
3736 createTool( 418, modifyTb );
3738 createTool( 214, dispModeTb );
3740 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3741 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3744 QString OB = "'ObjectBrowser'",
3745 View = "'" + SVTK_Viewer::Type() + "'",
3747 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3748 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3749 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3750 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3751 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3752 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3753 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3754 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3755 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3756 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3757 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3759 mesh_part = mesh + " " + subMesh + " " + group,
3760 mesh_group = mesh + " " + group,
3761 hyp_alg = hypo + " " + algo;
3763 // popup for object browser
3765 isInvisible("not( isVisible )"),
3766 isEmpty("numberOfNodes = 0"),
3767 isNotEmpty("numberOfNodes <> 0"),
3769 // has nodes, edges, etc in VISIBLE! actor
3770 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3771 hasElems("(count( elemTypes ) > 0)"),
3772 hasDifferentElems("(count( elemTypes ) > 1)"),
3773 hasElems0d("({'Elem0d'} in elemTypes)"),
3774 hasEdges("({'Edge'} in elemTypes)"),
3775 hasFaces("({'Face'} in elemTypes)"),
3776 hasVolumes("({'Volume'} in elemTypes)");
3778 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3779 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3780 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3781 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3782 createPopupItem( 803, OB, group ); // EDIT_GROUP
3783 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3785 popupMgr()->insert( separator(), -1, 0 );
3786 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3787 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3788 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3789 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3790 createPopupItem( 214, OB, mesh_part ); // UPDATE
3791 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3792 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3793 popupMgr()->insert( separator(), -1, 0 );
3794 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3795 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3796 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3797 popupMgr()->insert( separator(), -1, 0 );
3798 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3799 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3800 popupMgr()->insert( separator(), -1, 0 );
3801 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3802 popupMgr()->insert( separator(), -1, 0 );
3803 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3804 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3806 popupMgr()->insert( separator(), -1, 0 );
3808 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3809 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3810 QString only_one_2D = only_one_non_empty + " && dim>1";
3812 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3813 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3814 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3816 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3818 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3819 popupMgr()->insert( separator(), -1, 0 );
3822 createPopupItem( 803, View, group ); // EDIT_GROUP
3823 createPopupItem( 804, View, elems ); // ADD
3824 createPopupItem( 805, View, elems ); // REMOVE
3826 popupMgr()->insert( separator(), -1, 0 );
3827 createPopupItem( 214, View, mesh_part ); // UPDATE
3828 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3829 createPopupItem( 904, View, mesh ); // FIND_ELEM
3830 popupMgr()->insert( separator(), -1, 0 );
3832 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3833 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3834 popupMgr()->insert( separator(), -1, 0 );
3837 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3838 QString aType = QString( "%1type in {%2}" ).arg( lc );
3839 aType = aType.arg( mesh_part );
3840 QString aMeshInVTK = aClient + "&&" + aType;
3842 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3843 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3844 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3846 //-------------------------------------------------
3848 //-------------------------------------------------
3849 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3851 popupMgr()->insert( action( 9010 ), anId, -1 );
3852 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3853 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3855 popupMgr()->insert( action( 9011 ), anId, -1 );
3856 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3857 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3859 popupMgr()->insert( separator(), -1, -1 );
3861 //-------------------------------------------------
3863 //-------------------------------------------------
3864 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3866 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3867 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3868 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3870 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3871 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3872 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3874 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3875 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3876 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3878 popupMgr()->insert( separator(), anId, -1 );
3880 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3881 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3882 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3884 //-------------------------------------------------
3886 //-------------------------------------------------
3887 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3889 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3891 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3892 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3893 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3895 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3896 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3897 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3899 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3900 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3901 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3903 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3904 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3905 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3907 popupMgr()->insert( separator(), anId, -1 );
3909 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3910 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3913 //-------------------------------------------------
3914 // Representation of the 2D Quadratic elements
3915 //-------------------------------------------------
3916 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3917 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3918 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3919 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3921 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3922 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3923 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3925 //-------------------------------------------------
3926 // Orientation of faces
3927 //-------------------------------------------------
3928 popupMgr()->insert( action( 221 ), -1, -1 );
3929 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3930 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3932 //-------------------------------------------------
3934 //-------------------------------------------------
3935 popupMgr()->insert( action( 1132 ), -1, -1 );
3936 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3938 //-------------------------------------------------
3940 //-------------------------------------------------
3941 popupMgr()->insert( action( 1133 ), -1, -1 );
3942 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3944 //-------------------------------------------------
3946 //-------------------------------------------------
3948 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3949 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3950 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3951 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3953 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3955 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3956 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3958 popupMgr()->insert( separator(), anId, -1 );
3960 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3962 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3963 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3964 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3966 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3968 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3969 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3970 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3972 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3973 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3974 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3976 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3977 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3978 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3980 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3981 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3982 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3984 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3986 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3987 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3988 QtxPopupMgr::VisibleRule );
3989 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3991 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3992 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3993 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3995 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3996 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3997 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3999 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4000 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4001 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4003 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4004 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4005 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4007 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4008 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4009 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4011 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4012 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4013 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4015 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4016 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4017 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4019 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4020 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4021 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4023 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4024 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4025 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4027 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4028 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4029 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4031 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4032 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4033 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4035 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4037 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4038 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4039 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4041 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4042 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4043 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4045 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4046 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4047 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4049 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4050 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4051 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4053 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4054 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4055 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4057 popupMgr()->insert( separator(), anId, -1 );
4059 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4060 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4062 popupMgr()->insert( separator(), anId, -1 );
4064 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4066 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4067 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4069 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4070 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4071 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4073 #ifndef DISABLE_PLOT2DVIEWER
4074 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4075 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4078 //-------------------------------------------------
4080 //-------------------------------------------------
4081 popupMgr()->insert( separator(), -1, -1 );
4082 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4083 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4084 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4085 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4087 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4088 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4090 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4091 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4093 popupMgr()->insert( separator(), -1, -1 );
4095 //-------------------------------------------------
4097 //-------------------------------------------------
4098 popupMgr()->insert( action( 1134 ), -1, -1 );
4099 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4101 popupMgr()->insert( separator(), -1, -1 );
4103 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4104 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4106 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4107 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4110 //================================================================================
4112 * \brief Return true if SMESH or GEOM objects are selected.
4113 * Is called form LightApp_Module::activateModule() which clear selection if
4114 * not isSelectionCompatible()
4116 //================================================================================
4118 bool SMESHGUI::isSelectionCompatible()
4120 bool isCompatible = true;
4121 SALOME_ListIO selected;
4122 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4123 Sel->selectedObjects( selected );
4125 SALOME_ListIteratorOfListIO It( selected );
4126 for ( ; isCompatible && It.More(); It.Next())
4128 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4129 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4131 return isCompatible;
4135 bool SMESHGUI::reusableOperation( const int id )
4137 // compute, evaluate and precompute are not reusable operations
4138 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4141 bool SMESHGUI::activateModule( SUIT_Study* study )
4143 bool res = SalomeApp_Module::activateModule( study );
4145 setMenuShown( true );
4146 setToolShown( true );
4148 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4149 PyGILState_STATE gstate = PyGILState_Ensure();
4150 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4151 if(pluginsmanager==NULL)
4155 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4160 PyGILState_Release(gstate);
4161 // end of GEOM plugins loading
4163 // Reset actions accelerator keys
4164 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4165 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4166 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4168 action( 33)->setEnabled(true); // Delete: Key_Delete
4170 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4171 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4172 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4173 if ( _PTR(Study) aStudy = s->studyDS()) {
4174 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4175 updateObjBrowser(); // objects can be removed
4178 // get all view currently opened in the study and connect their signals to
4179 // the corresponding slots of the class.
4180 SUIT_Desktop* aDesk = study->application()->desktop();
4182 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4183 SUIT_ViewWindow* wnd;
4184 foreach ( wnd, wndList )
4191 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4193 setMenuShown( false );
4194 setToolShown( false );
4196 EmitSignalCloseAllDialogs();
4198 // Unset actions accelerator keys
4199 action(111)->setShortcut(QKeySequence()); // Import DAT
4200 action(112)->setShortcut(QKeySequence()); // Import UNV
4201 action(113)->setShortcut(QKeySequence()); // Import MED
4203 action( 33)->setEnabled(false); // Delete: Key_Delete
4205 return SalomeApp_Module::deactivateModule( study );
4208 void SMESHGUI::studyClosed( SUIT_Study* s )
4210 SMESH::RemoveVisuData( s->id() );
4211 SalomeApp_Module::studyClosed( s );
4214 void SMESHGUI::OnGUIEvent()
4216 const QObject* obj = sender();
4217 if ( !obj || !obj->inherits( "QAction" ) )
4219 int id = actionId((QAction*)obj);
4224 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4226 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4227 if ( CORBA::is_nil( myComponentSMESH ) )
4229 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4231 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4232 return aGUI.myComponentSMESH;
4235 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4236 return myComponentSMESH;
4239 QString SMESHGUI::engineIOR() const
4241 CORBA::ORB_var anORB = getApp()->orb();
4242 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4243 return QString( anIOR.in() );
4246 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4248 SalomeApp_Module::contextMenuPopup( client, menu, title );
4250 selectionMgr()->selectedObjects( lst );
4251 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4252 Handle(SALOME_InteractiveObject) io = lst.First();
4253 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4254 _PTR(Study) study = appStudy->studyDS();
4255 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4257 QString aName = QString( obj->GetName().c_str() );
4258 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4259 aName.remove( (aName.length() - 1), 1 );
4265 LightApp_Selection* SMESHGUI::createSelection() const
4267 return new SMESHGUI_Selection();
4270 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4272 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4273 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4276 void SMESHGUI::viewManagers( QStringList& list ) const
4278 list.append( SVTK_Viewer::Type() );
4281 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4283 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4284 SMESH::UpdateSelectionProp( this );
4286 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4287 for(int i = 0; i < aViews.count() ; i++){
4288 SUIT_ViewWindow *sf = aViews[i];
4294 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4296 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4297 myClippingPlaneInfoMap.erase( theViewManager );
4300 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4302 theActor->AddObserver( SMESH::DeleteActorEvent,
4303 myEventCallbackCommand.GetPointer(),
4307 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4308 unsigned long theEvent,
4309 void* theClientData,
4312 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4313 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4314 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4315 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4316 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4317 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4318 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4319 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4320 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4321 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4322 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4323 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4324 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4325 if( anActor == *anIter3 ) {
4326 anActorList.erase( anIter3 );
4337 void SMESHGUI::createPreferences()
4339 // General tab ------------------------------------------------------------------------
4340 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4342 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4343 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4344 setPreferenceProperty( lim, "min", 0 );
4345 setPreferenceProperty( lim, "max", 100000000 );
4346 setPreferenceProperty( lim, "step", 1000 );
4347 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4349 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4350 setPreferenceProperty( qaGroup, "columns", 2 );
4351 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4352 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4353 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4354 setPreferenceProperty( prec, "min", 0 );
4355 setPreferenceProperty( prec, "max", 16 );
4357 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4358 setPreferenceProperty( dispgroup, "columns", 2 );
4359 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4361 modes.append( "Wireframe" );
4362 modes.append( "Shading" );
4363 modes.append( "Nodes" );
4364 modes.append( "Shrink" );
4365 QList<QVariant> indices;
4366 indices.append( 0 );
4367 indices.append( 1 );
4368 indices.append( 2 );
4369 indices.append( 3 );
4370 setPreferenceProperty( dispmode, "strings", modes );
4371 setPreferenceProperty( dispmode, "indexes", indices );
4373 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4374 setPreferenceProperty( arcgroup, "columns", 2 );
4375 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4376 QStringList quadraticModes;
4377 quadraticModes.append("Lines");
4378 quadraticModes.append("Arcs");
4380 indices.append( 0 );
4381 indices.append( 1 );
4382 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4383 setPreferenceProperty( quadraticmode, "indexes", indices );
4385 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4386 "SMESH", "max_angle" );
4387 setPreferenceProperty( maxAngle, "min", 1 );
4388 setPreferenceProperty( maxAngle, "max", 90 );
4392 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4393 setPreferenceProperty( exportgroup, "columns", 2 );
4394 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4395 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4397 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4398 setPreferenceProperty( computeGroup, "columns", 2 );
4399 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4401 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4402 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4403 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4405 indices.append( 0 );
4406 indices.append( 1 );
4407 indices.append( 2 );
4408 setPreferenceProperty( notifyMode, "strings", modes );
4409 setPreferenceProperty( notifyMode, "indexes", indices );
4411 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4412 setPreferenceProperty( computeGroup, "columns", 2 );
4413 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4415 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4416 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4418 indices.append( 0 );
4419 indices.append( 1 );
4420 setPreferenceProperty( elemInfo, "strings", modes );
4421 setPreferenceProperty( elemInfo, "indexes", indices );
4423 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4424 setPreferenceProperty( segGroup, "columns", 2 );
4425 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4426 "SMESH", "segmentation" );
4427 setPreferenceProperty( segLen, "min", 1 );
4428 setPreferenceProperty( segLen, "max", 10000000 );
4429 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4430 "SMESH", "nb_segments_per_edge" );
4431 setPreferenceProperty( nbSeg, "min", 1 );
4432 setPreferenceProperty( nbSeg, "max", 10000000 );
4434 // Quantities with individual precision settings
4435 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4436 setPreferenceProperty( precGroup, "columns", 2 );
4438 const int nbQuantities = 6;
4439 int precs[nbQuantities], ii = 0;
4440 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4441 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4442 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4443 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4444 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4445 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4446 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4447 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4448 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4449 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4450 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4451 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4453 // Set property for precision value for spinboxes
4454 for ( ii = 0; ii < nbQuantities; ii++ ){
4455 setPreferenceProperty( precs[ii], "min", -14 );
4456 setPreferenceProperty( precs[ii], "max", 14 );
4457 setPreferenceProperty( precs[ii], "precision", 2 );
4460 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4461 setPreferenceProperty( previewGroup, "columns", 2 );
4462 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4463 setPreferenceProperty( chunkSize, "min", 0 );
4464 setPreferenceProperty( chunkSize, "max", 1000 );
4465 setPreferenceProperty( chunkSize, "step", 50 );
4467 // Mesh tab ------------------------------------------------------------------------
4468 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4469 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4470 setPreferenceProperty( nodeGroup, "columns", 3 );
4472 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4474 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4476 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4477 QList<QVariant> aMarkerTypeIndicesList;
4478 QList<QVariant> aMarkerTypeIconsList;
4479 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4480 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4481 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4482 aMarkerTypeIndicesList << i;
4483 aMarkerTypeIconsList << pixmap;
4485 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4486 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4488 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4490 QList<QVariant> aMarkerScaleIndicesList;
4491 QStringList aMarkerScaleValuesList;
4492 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4493 aMarkerScaleIndicesList << i;
4494 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4496 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4497 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4499 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4500 setPreferenceProperty( elemGroup, "columns", 2 );
4502 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4503 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4504 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4505 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4507 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4508 setPreferenceProperty( grpGroup, "columns", 2 );
4510 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4512 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4513 //setPreferenceProperty( sp, "hstretch", 0 );
4514 //setPreferenceProperty( sp, "vstretch", 0 );
4516 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4517 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4518 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4519 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4520 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4521 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4522 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4524 setPreferenceProperty( size0d, "min", 1 );
4525 setPreferenceProperty( size0d, "max", 10 );
4527 setPreferenceProperty( sp, "hstretch", 0 );
4528 setPreferenceProperty( sp, "vstretch", 0 );
4530 setPreferenceProperty( elemW, "min", 1 );
4531 setPreferenceProperty( elemW, "max", 5 );
4533 setPreferenceProperty( shrink, "min", 0 );
4534 setPreferenceProperty( shrink, "max", 100 );
4536 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4537 setPreferenceProperty( orientGroup, "columns", 1 );
4539 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4540 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4542 setPreferenceProperty( orientScale, "min", 0.05 );
4543 setPreferenceProperty( orientScale, "max", 0.5 );
4544 setPreferenceProperty( orientScale, "step", 0.05 );
4546 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4548 // Selection tab ------------------------------------------------------------------------
4549 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4551 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4552 setPreferenceProperty( selGroup, "columns", 2 );
4554 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4555 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4556 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4558 setPreferenceProperty( selW, "min", 1 );
4559 setPreferenceProperty( selW, "max", 5 );
4561 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4562 setPreferenceProperty( preGroup, "columns", 2 );
4564 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4565 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4567 setPreferenceProperty( preW, "min", 1 );
4568 setPreferenceProperty( preW, "max", 5 );
4570 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4571 setPreferenceProperty( precSelGroup, "columns", 2 );
4573 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4574 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4575 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4577 // Scalar Bar tab ------------------------------------------------------------------------
4578 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4579 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4580 setPreferenceProperty( fontGr, "columns", 2 );
4582 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4583 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4585 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4586 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4588 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4589 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4591 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4592 setPreferenceProperty( numcol, "min", 2 );
4593 setPreferenceProperty( numcol, "max", 256 );
4595 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4596 setPreferenceProperty( numlab, "min", 2 );
4597 setPreferenceProperty( numlab, "max", 65 );
4599 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4600 setPreferenceProperty( orientGr, "columns", 2 );
4601 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4602 QStringList orients;
4603 orients.append( tr( "SMESH_VERTICAL" ) );
4604 orients.append( tr( "SMESH_HORIZONTAL" ) );
4605 indices.clear(); indices.append( 0 ); indices.append( 1 );
4606 setPreferenceProperty( orient, "strings", orients );
4607 setPreferenceProperty( orient, "indexes", indices );
4609 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4610 setPreferenceProperty( posVSizeGr, "columns", 2 );
4611 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4612 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4613 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4614 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4615 setPreferenceProperty( xv, "step", 0.1 );
4616 setPreferenceProperty( xv, "min", 0.0 );
4617 setPreferenceProperty( xv, "max", 1.0 );
4618 setPreferenceProperty( yv, "step", 0.1 );
4619 setPreferenceProperty( yv, "min", 0.0 );
4620 setPreferenceProperty( yv, "max", 1.0 );
4621 setPreferenceProperty( wv, "step", 0.1 );
4622 setPreferenceProperty( wv, "min", 0.0 );
4623 setPreferenceProperty( wv, "max", 1.0 );
4624 setPreferenceProperty( hv, "min", 0.0 );
4625 setPreferenceProperty( hv, "max", 1.0 );
4626 setPreferenceProperty( hv, "step", 0.1 );
4628 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4629 setPreferenceProperty( posHSizeGr, "columns", 2 );
4630 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4631 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4632 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4633 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4634 setPreferenceProperty( xv, "min", 0.0 );
4635 setPreferenceProperty( xv, "max", 1.0 );
4636 setPreferenceProperty( xv, "step", 0.1 );
4637 setPreferenceProperty( xh, "min", 0.0 );
4638 setPreferenceProperty( xh, "max", 1.0 );
4639 setPreferenceProperty( xh, "step", 0.1 );
4640 setPreferenceProperty( yh, "min", 0.0 );
4641 setPreferenceProperty( yh, "max", 1.0 );
4642 setPreferenceProperty( yh, "step", 0.1 );
4643 setPreferenceProperty( wh, "min", 0.0 );
4644 setPreferenceProperty( wh, "max", 1.0 );
4645 setPreferenceProperty( wh, "step", 0.1 );
4646 setPreferenceProperty( hh, "min", 0.0 );
4647 setPreferenceProperty( hh, "max", 1.0 );
4648 setPreferenceProperty( hh, "step", 0.1 );
4650 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4651 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4652 setPreferenceProperty( distributionGr, "columns", 3 );
4654 types.append( tr( "SMESH_MONOCOLOR" ) );
4655 types.append( tr( "SMESH_MULTICOLOR" ) );
4656 indices.clear(); indices.append( 0 ); indices.append( 1 );
4657 setPreferenceProperty( coloringType, "strings", types );
4658 setPreferenceProperty( coloringType, "indexes", indices );
4659 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4663 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4665 if( sect=="SMESH" ) {
4666 float sbX1,sbY1,sbW,sbH;
4667 float aTol = 1.00000009999999;
4668 std::string aWarning;
4669 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4670 if( name=="selection_object_color" || name=="selection_element_color" ||
4671 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4672 name=="selection_precision_node" || name=="selection_precision_element" ||
4673 name=="selection_precision_object")
4674 SMESH::UpdateSelectionProp( this );
4675 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4676 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4677 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4678 if(sbX1+sbW > aTol){
4679 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4682 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4683 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4686 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4687 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4688 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4689 if(sbY1+sbH > aTol){
4690 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4691 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4692 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4695 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4696 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4697 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4698 if(sbX1+sbW > aTol){
4699 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4702 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4703 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4706 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4707 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4708 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4709 if(sbY1+sbH > aTol){
4710 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4713 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4714 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4717 else if ( name == "segmentation" ) {
4718 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4719 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4721 else if ( name == "nb_segments_per_edge" ) {
4722 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4723 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4726 if(aWarning.size() != 0){
4727 aWarning += "The default values are applied instead.";
4728 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4729 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4730 QObject::tr(aWarning.c_str()));
4735 //================================================================================
4737 * \brief Update something in accordance with update flags
4738 * \param theFlags - update flags
4740 * Update viewer or/and object browser etc. in accordance with update flags ( see
4741 * LightApp_UpdateFlags enumeration ).
4743 //================================================================================
4744 void SMESHGUI::update( const int flags )
4746 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4747 SMESH::UpdateView();
4749 SalomeApp_Module::update( flags );
4752 //================================================================================
4754 * \brief Set default selection mode
4756 * SLOT called when operation commited. Sets default selection mode
4758 //================================================================================
4759 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4761 SVTK_ViewWindow* vtkWnd =
4762 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4764 vtkWnd->SetSelectionMode( ActorSelection );
4767 //================================================================================
4769 * \brief Set default selection mode
4771 * SLOT called when operation aborted. Sets default selection mode
4773 //================================================================================
4774 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4776 SVTK_ViewWindow* vtkWnd =
4777 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4779 vtkWnd->SetSelectionMode( ActorSelection );
4782 //================================================================================
4784 * \brief Creates operation with given identifier
4785 * \param id - identifier of operation to be started
4786 * \return Pointer on created operation or NULL if operation is not created
4788 * Virtual method redefined from the base class creates operation with given id.
4789 * It is called called automatically from startOperation method of base class.
4791 //================================================================================
4792 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4794 LightApp_Operation* op = 0;
4795 // to do : create operation here
4798 case 417: //convert to quadratic
4799 op = new SMESHGUI_ConvToQuadOp();
4801 case 418: // create 2D mesh as boundary on 3D
4802 op = new SMESHGUI_Make2DFrom3DOp();
4804 case 701: // Compute mesh
4805 op = new SMESHGUI_ComputeOp();
4807 case 702: // Create mesh
4808 op = new SMESHGUI_MeshOp( true, true );
4810 case 703: // Create sub-mesh
4811 op = new SMESHGUI_MeshOp( true, false );
4813 case 704: // Edit mesh/sub-mesh
4814 op = new SMESHGUI_MeshOp( false );
4816 case 711: // Precompute mesh
4817 op = new SMESHGUI_PrecomputeOp();
4819 case 712: // Evaluate mesh
4820 op = new SMESHGUI_EvaluateOp();
4822 case 713: // Evaluate mesh
4823 op = new SMESHGUI_MeshOrderOp();
4825 case 806: // Create group on geom
4826 op = new SMESHGUI_GroupOnShapeOp();
4828 case 904: // Find element
4829 op = new SMESHGUI_FindElemByPointOp();
4831 case 4067: // make mesh pass through point
4832 op = new SMESHGUI_MakeNodeAtPointOp();
4839 op = SalomeApp_Module::createOperation( id );
4843 //================================================================================
4845 * \brief Stops current operations and starts a given one
4846 * \param id - The id of the operation to start
4848 //================================================================================
4850 void SMESHGUI::switchToOperation(int id)
4852 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4853 activeStudy()->abortAllOperations();
4854 startOperation( id );
4857 LightApp_Displayer* SMESHGUI::displayer()
4860 myDisplayer = new SMESHGUI_Displayer( getApp() );
4864 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4867 int aTolerance = 64;
4868 int anIterations = 0;
4874 if( anIterations % aPeriod == 0 )
4877 if( aTolerance < 1 )
4881 aHue = (int)( 360.0 * rand() / RAND_MAX );
4884 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4885 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4886 for( ; it != itEnd; ++it )
4888 SALOMEDS::Color anAutoColor = *it;
4889 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4892 aQColor.getHsv( &h, &s, &v );
4893 if( abs( h - aHue ) < aTolerance )
4905 aColor.setHsv( aHue, 255, 255 );
4907 SALOMEDS::Color aSColor;
4908 aSColor.R = (double)aColor.red() / 255.0;
4909 aSColor.G = (double)aColor.green() / 255.0;
4910 aSColor.B = (double)aColor.blue() / 255.0;
4915 const char gSeparator = '_'; // character used to separate parameter names
4916 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4917 const char gPathSep = '|'; // character used to separate paths
4920 * \brief Store visual parameters
4922 * This method is called just before the study document is saved.
4923 * Store visual parameters in AttributeParameter attribue(s)
4925 void SMESHGUI::storeVisualParameters (int savePoint)
4927 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4928 if (!appStudy || !appStudy->studyDS())
4930 _PTR(Study) studyDS = appStudy->studyDS();
4932 // componentName is used for encoding of entries when storing them in IParameters
4933 std::string componentName = myComponentSMESH->ComponentDataType();
4934 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4935 //if (!aSComponent) return;
4938 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4939 componentName.c_str(),
4941 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4943 // store map of custom markers
4944 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4945 if( !aMarkerMap.empty() )
4947 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4948 for( ; anIter != aMarkerMap.end(); anIter++ )
4950 int anId = anIter->first;
4951 VTK::MarkerData aMarkerData = anIter->second;
4952 std::string aMarkerFileName = aMarkerData.first;
4953 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4954 if( aMarkerTexture.size() < 3 )
4955 continue; // should contain at least width, height and the first value
4957 QString aPropertyName( "texture" );
4958 aPropertyName += gSeparator;
4959 aPropertyName += QString::number( anId );
4961 QString aPropertyValue = aMarkerFileName.c_str();
4962 aPropertyValue += gPathSep;
4964 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4965 ushort aWidth = *aTextureIter++;
4966 ushort aHeight = *aTextureIter++;
4967 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4968 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4969 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4970 aPropertyValue += QString::number( *aTextureIter );
4972 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4976 // viewers counters are used for storing view_numbers in IParameters
4979 // main cycle to store parameters of displayed objects
4980 QList<SUIT_ViewManager*> lst;
4981 QList<SUIT_ViewManager*>::Iterator it;
4982 getApp()->viewManagers(lst);
4983 for (it = lst.begin(); it != lst.end(); it++)
4985 SUIT_ViewManager* vman = *it;
4986 QString vType = vman->getType();
4988 // saving VTK actors properties
4989 if (vType == SVTK_Viewer::Type())
4991 // store the clipping planes attached to the view manager
4992 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4993 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4994 if( anIter != myClippingPlaneInfoMap.end() )
4995 aClippingPlaneInfoList = anIter->second;
4997 if( !aClippingPlaneInfoList.empty() ) {
4998 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4999 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5001 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5002 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5004 QString aPropertyName( "ClippingPlane" );
5005 aPropertyName += gSeparator;
5006 aPropertyName += QString::number( vtkViewers );
5007 aPropertyName += gSeparator;
5008 aPropertyName += QString::number( anId );
5010 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5011 aPropertyValue += gDigitsSep;
5012 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5013 aPropertyValue += gDigitsSep;
5014 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5015 aPropertyValue += gDigitsSep;
5016 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5018 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5022 QVector<SUIT_ViewWindow*> views = vman->getViews();
5023 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5025 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5027 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5028 vtkActorCollection* allActors = aCopy.GetActors();
5029 allActors->InitTraversal();
5030 while (vtkActor* actor = allActors->GetNextActor())
5032 if (actor->GetVisibility()) // store only visible actors
5034 SMESH_Actor* aSmeshActor = 0;
5035 if (actor->IsA("SMESH_Actor"))
5036 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5037 if (aSmeshActor && aSmeshActor->hasIO())
5039 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5042 // entry is "encoded" = it does NOT contain component adress,
5043 // since it is a subject to change on next component loading
5044 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5046 std::string param, vtkParam = vType.toLatin1().data();
5047 vtkParam += gSeparator;
5048 vtkParam += QString::number(vtkViewers).toLatin1().data();
5049 vtkParam += gSeparator;
5052 param = vtkParam + "Visibility";
5053 ip->setParameter(entry, param, "On");
5056 param = vtkParam + "Representation";
5057 ip->setParameter(entry, param, QString::number
5058 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5061 param = vtkParam + "IsShrunk";
5062 ip->setParameter(entry, param, QString::number
5063 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5065 // Displayed entities
5066 unsigned int aMode = aSmeshActor->GetEntityMode();
5067 bool isE = aMode & SMESH_Actor::eEdges;
5068 bool isF = aMode & SMESH_Actor::eFaces;
5069 bool isV = aMode & SMESH_Actor::eVolumes;
5071 QString modeStr ("e");
5072 modeStr += gDigitsSep; modeStr += QString::number(isE);
5073 modeStr += gDigitsSep; modeStr += "f";
5074 modeStr += gDigitsSep; modeStr += QString::number(isF);
5075 modeStr += gDigitsSep; modeStr += "v";
5076 modeStr += gDigitsSep; modeStr += QString::number(isV);
5078 param = vtkParam + "Entities";
5079 ip->setParameter(entry, param, modeStr.toLatin1().data());
5081 // Colors (surface:edge:)
5082 vtkFloatingPointType r, g, b;
5084 aSmeshActor->GetSufaceColor(r, g, b);
5085 QString colorStr ("surface");
5086 colorStr += gDigitsSep; colorStr += QString::number(r);
5087 colorStr += gDigitsSep; colorStr += QString::number(g);
5088 colorStr += gDigitsSep; colorStr += QString::number(b);
5090 aSmeshActor->GetBackSufaceColor(r, g, b);
5091 colorStr += gDigitsSep; colorStr += "backsurface";
5092 colorStr += gDigitsSep; colorStr += QString::number(r);
5093 colorStr += gDigitsSep; colorStr += QString::number(g);
5094 colorStr += gDigitsSep; colorStr += QString::number(b);
5096 aSmeshActor->GetEdgeColor(r, g, b);
5097 colorStr += gDigitsSep; colorStr += "edge";
5098 colorStr += gDigitsSep; colorStr += QString::number(r);
5099 colorStr += gDigitsSep; colorStr += QString::number(g);
5100 colorStr += gDigitsSep; colorStr += QString::number(b);
5102 aSmeshActor->GetNodeColor(r, g, b);
5103 colorStr += gDigitsSep; colorStr += "node";
5104 colorStr += gDigitsSep; colorStr += QString::number(r);
5105 colorStr += gDigitsSep; colorStr += QString::number(g);
5106 colorStr += gDigitsSep; colorStr += QString::number(b);
5108 param = vtkParam + "Colors";
5109 ip->setParameter(entry, param, colorStr.toLatin1().data());
5111 // Sizes of lines and points
5112 QString sizeStr ("line");
5113 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5114 sizeStr += gDigitsSep; sizeStr += "shrink";
5115 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5117 param = vtkParam + "Sizes";
5118 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5123 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5124 if( aMarkerType == VTK::MT_USER ) {
5125 markerStr += "custom";
5126 markerStr += gDigitsSep;
5127 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5131 markerStr += gDigitsSep;
5132 markerStr += QString::number( (int)aMarkerType );
5133 markerStr += gDigitsSep;
5134 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5137 param = vtkParam + "PointMarker";
5138 ip->setParameter(entry, param, markerStr.toLatin1().data());
5141 param = vtkParam + "Opacity";
5142 ip->setParameter(entry, param,
5143 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5146 param = vtkParam + "ClippingPlane";
5148 if( !aClippingPlaneInfoList.empty() ) {
5149 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5150 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5152 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5153 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5154 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5155 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5156 if( aSmeshActor == *anIter2 ) {
5157 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5158 QString::number( anId ).toLatin1().constData() );
5165 ip->setParameter( entry, param, "Off" );
5166 } // if (io->hasEntry())
5167 } // SMESH_Actor && hasIO
5169 } // while.. actors traversal
5173 } // if (SVTK view model)
5174 } // for (viewManagers)
5177 // data structures for clipping planes processing
5180 vtkIdType Orientation;
5181 vtkFloatingPointType Distance;
5182 vtkFloatingPointType Angle[2];
5184 typedef std::list<TPlaneData> TPlaneDataList;
5185 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5187 typedef std::list<vtkActor*> TActorList;
5190 TActorList ActorList;
5191 SUIT_ViewManager* ViewManager;
5193 typedef std::list<TPlaneInfo> TPlaneInfoList;
5194 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5197 * \brief Restore visual parameters
5199 * This method is called after the study document is opened.
5200 * Restore visual parameters from AttributeParameter attribue(s)
5202 void SMESHGUI::restoreVisualParameters (int savePoint)
5204 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5205 if (!appStudy || !appStudy->studyDS())
5207 _PTR(Study) studyDS = appStudy->studyDS();
5209 // componentName is used for encoding of entries when storing them in IParameters
5210 std::string componentName = myComponentSMESH->ComponentDataType();
5211 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5212 //if (!aSComponent) return;
5215 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5216 componentName.c_str(),
5218 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5220 // restore map of custom markers and map of clipping planes
5221 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5222 TPlaneDataMap aPlaneDataMap;
5224 std::vector<std::string> properties = ip->getProperties();
5225 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5227 std::string property = *propIt;
5228 QString aPropertyName( property.c_str() );
5229 QString aPropertyValue( ip->getProperty( property ).c_str() );
5231 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5232 if( aPropertyNameList.isEmpty() )
5235 QString aPropertyType = aPropertyNameList[0];
5236 if( aPropertyType == "texture" )
5238 if( aPropertyNameList.size() != 2 )
5242 int anId = aPropertyNameList[1].toInt( &ok );
5243 if( !ok || anId < 1 )
5246 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5247 if( aPropertyValueList.size() != 2 )
5250 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5251 QString aMarkerTextureString = aPropertyValueList[1];
5252 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5253 if( aMarkerTextureStringList.size() != 3 )
5257 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5262 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5266 VTK::MarkerTexture aMarkerTexture;
5267 aMarkerTexture.push_back( aWidth );
5268 aMarkerTexture.push_back( aHeight );
5270 QString aMarkerTextureData = aMarkerTextureStringList[2];
5271 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5273 QChar aChar = aMarkerTextureData.at( i );
5274 if( aChar.isDigit() )
5275 aMarkerTexture.push_back( aChar.digitValue() );
5278 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5280 else if( aPropertyType == "ClippingPlane" )
5282 if( aPropertyNameList.size() != 3 )
5286 int aViewId = aPropertyNameList[1].toInt( &ok );
5287 if( !ok || aViewId < 0 )
5291 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5292 if( !ok || aClippingPlaneId < 0 )
5295 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5296 if( aPropertyValueList.size() != 4 )
5299 TPlaneData aPlaneData;
5300 aPlaneData.Id = aClippingPlaneId;
5303 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5308 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5313 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5318 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5322 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5323 aPlaneDataList.push_back( aPlaneData );
5327 TPlaneInfoMap aPlaneInfoMap;
5329 std::vector<std::string> entries = ip->getEntries();
5331 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5333 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5334 QString entry (ip->decodeEntry(*entIt).c_str());
5336 // Check that the entry corresponds to a real object in the Study
5337 // as the object may be deleted or modified after the visual state is saved.
5338 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5339 if (!so) continue; //Skip the not existent entry
5341 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5342 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5344 std::vector<std::string>::iterator namesIt = paramNames.begin();
5345 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5347 // actors are stored in a map after displaying of them for
5348 // quicker access in the future: map < viewID to actor >
5349 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5351 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5353 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5354 // '_' is used as separator and should not be used in viewer type or parameter names.
5355 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5356 if (lst.size() != 3)
5359 QString viewerTypStr = lst[0];
5360 QString viewIndexStr = lst[1];
5361 QString paramNameStr = lst[2];
5364 int viewIndex = viewIndexStr.toUInt(&ok);
5365 if (!ok) // bad conversion of view index to integer
5369 if (viewerTypStr == SVTK_Viewer::Type())
5371 SMESH_Actor* aSmeshActor = 0;
5372 if (vtkActors.IsBound(viewIndex))
5373 aSmeshActor = vtkActors.Find(viewIndex);
5375 QList<SUIT_ViewManager*> lst;
5376 getApp()->viewManagers(viewerTypStr, lst);
5378 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5379 SUIT_ViewManager* vman = NULL;
5380 if (viewIndex >= 0 && viewIndex < lst.count())
5381 vman = lst.at(viewIndex);
5383 if (paramNameStr == "Visibility")
5385 if (!aSmeshActor && displayer() && vman)
5387 SUIT_ViewModel* vmodel = vman->getViewModel();
5388 // SVTK view model can be casted to SALOME_View
5389 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5391 // store displayed actor in a temporary map for quicker
5392 // access later when restoring other parameters
5393 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5394 vtkRenderer* Renderer = vtkView->getRenderer();
5395 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5396 vtkActorCollection* theActors = aCopy.GetActors();
5397 theActors->InitTraversal();
5398 bool isFound = false;
5399 vtkActor *ac = theActors->GetNextActor();
5400 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5401 if (ac->IsA("SMESH_Actor")) {
5402 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5403 if (aGeomAc->hasIO()) {
5404 Handle(SALOME_InteractiveObject) io =
5405 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5406 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5408 vtkActors.Bind(viewIndex, aGeomAc);
5414 } // if (paramNameStr == "Visibility")
5417 // the rest properties "work" with SMESH_Actor
5420 QString val ((*valuesIt).c_str());
5423 if (paramNameStr == "Representation") {
5424 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5427 else if (paramNameStr == "IsShrunk") {
5429 if (!aSmeshActor->IsShrunk())
5430 aSmeshActor->SetShrink();
5433 if (aSmeshActor->IsShrunk())
5434 aSmeshActor->UnShrink();
5437 // Displayed entities
5438 else if (paramNameStr == "Entities") {
5439 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5440 if (mode.count() == 6) {
5441 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5442 MESSAGE("Invalid order of data in Entities, must be: "
5443 "e:0/1:f:0/1:v:0/1");
5446 unsigned int aMode = aSmeshActor->GetEntityMode();
5447 unsigned int aNewMode =
5448 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5449 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5450 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5451 if (aNewMode != aMode)
5452 aSmeshActor->SetEntityMode(aNewMode);
5457 else if (paramNameStr == "Colors") {
5458 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5459 if (colors.count() == 16) {
5460 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5461 colors[8] != "edge" || colors[12] != "node") {
5462 MESSAGE("Invalid order of data in Colors, must be: "
5463 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5466 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5467 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5468 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5469 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5473 // Sizes of lines and points
5474 else if (paramNameStr == "Sizes") {
5475 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5476 if (sizes.count() == 4) {
5477 if (sizes[0] != "line" || sizes[2] != "shrink") {
5478 MESSAGE("Invalid order of data in Sizes, must be: "
5479 "line:int:shrink:float");
5482 aSmeshActor->SetLineWidth(sizes[1].toInt());
5483 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5486 else if (sizes.count() == 6) { // just to support old format
5487 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5488 MESSAGE("Invalid order of data in Sizes, must be: "
5489 "line:int:node:int:shrink:float");
5492 aSmeshActor->SetLineWidth(sizes[1].toInt());
5493 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5494 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5499 else if (paramNameStr == "PointMarker") {
5500 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5501 if( data.count() >= 2 ) {
5503 int aParam1 = data[1].toInt( &ok );
5505 if( data[0] == "std" && data.count() == 3 ) {
5506 int aParam2 = data[2].toInt( &ok );
5507 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5509 else if( data[0] == "custom" ) {
5510 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5511 if( markerIt != aMarkerMap.end() ) {
5512 VTK::MarkerData aMarkerData = markerIt->second;
5513 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5520 else if (paramNameStr == "Opacity") {
5521 aSmeshActor->SetOpacity(val.toFloat());
5524 else if (paramNameStr.startsWith("ClippingPlane")) {
5525 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5526 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5527 // new format - val looks like "Off" or "0" (plane id)
5528 // (note: in new format "Off" value is used only for consistency,
5529 // so it is processed together with values in old format)
5530 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5531 if( anIsOldFormat ) {
5532 if (paramNameStr == "ClippingPlane1" || val == "Off")
5533 aSmeshActor->RemoveAllClippingPlanes();
5535 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5536 double aDistance = vals[1].toFloat();
5537 vtkFloatingPointType anAngle[2];
5538 anAngle[0] = vals[2].toFloat();
5539 anAngle[1] = vals[3].toFloat();
5541 QList<SUIT_ViewManager*> lst;
5542 getApp()->viewManagers(viewerTypStr, lst);
5543 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5544 if (viewIndex >= 0 && viewIndex < lst.count()) {
5545 SUIT_ViewManager* vman = lst.at(viewIndex);
5546 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5548 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5550 SMESH::TActorList anActorList;
5551 anActorList.push_back( aSmeshActor );
5552 SMESH::OrientedPlane* aPlane =
5553 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5555 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5556 aClippingPlaneInfo.Plane = aPlane;
5557 aClippingPlaneInfo.ActorList = anActorList;
5558 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5565 int aPlaneId = val.toInt( &ok );
5566 if( ok && aPlaneId >= 0 ) {
5567 bool anIsDefinedPlane = false;
5568 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5569 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5570 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5571 TPlaneInfo& aPlaneInfo = *anIter;
5572 if( aPlaneInfo.PlaneId == aPlaneId ) {
5573 aPlaneInfo.ActorList.push_back( aSmeshActor );
5574 anIsDefinedPlane = true;
5578 if( !anIsDefinedPlane ) {
5579 TPlaneInfo aPlaneInfo;
5580 aPlaneInfo.PlaneId = aPlaneId;
5581 aPlaneInfo.ActorList.push_back( aSmeshActor );
5582 aPlaneInfo.ViewManager = vman;
5584 // to make the list sorted by plane id
5585 anIter = aPlaneInfoList.begin();
5586 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5587 const TPlaneInfo& aPlaneInfoRef = *anIter;
5588 if( aPlaneInfoRef.PlaneId > aPlaneId )
5591 aPlaneInfoList.insert( anIter, aPlaneInfo );
5596 } // if (aSmeshActor)
5597 } // other parameters than Visibility
5599 } // for names/parameters iterator
5600 } // for entries iterator
5602 // take into account planes with empty list of actors referred to them
5603 QList<SUIT_ViewManager*> aVMList;
5604 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5606 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5607 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5608 int aViewId = aPlaneDataIter->first;
5609 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5610 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5612 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5614 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5615 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5616 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5617 const TPlaneData& aPlaneData = *anIter2;
5618 int aPlaneId = aPlaneData.Id;
5620 bool anIsFound = false;
5621 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5622 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5623 const TPlaneInfo& aPlaneInfo = *anIter3;
5624 if( aPlaneInfo.PlaneId == aPlaneId ) {
5631 TPlaneInfo aPlaneInfo; // ActorList field is empty
5632 aPlaneInfo.PlaneId = aPlaneId;
5633 aPlaneInfo.ViewManager = aViewManager;
5635 // to make the list sorted by plane id
5636 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5637 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5638 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5639 if( aPlaneInfoRef.PlaneId > aPlaneId )
5642 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5648 // add clipping planes to actors according to the restored parameters
5649 // and update the clipping plane map
5650 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5651 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5652 int aViewId = anIter1->first;
5653 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5655 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5656 if( anIter2 == aPlaneDataMap.end() )
5658 const TPlaneDataList& aPlaneDataList = anIter2->second;
5660 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5661 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5662 const TPlaneInfo& aPlaneInfo = *anIter3;
5663 int aPlaneId = aPlaneInfo.PlaneId;
5664 const TActorList& anActorList = aPlaneInfo.ActorList;
5665 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5669 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5673 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5675 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5676 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5677 const TPlaneData& aPlaneData = *anIter4;
5678 if( aPlaneData.Id == aPlaneId ) {
5679 SMESH::OrientedPlane* aPlane =
5680 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5682 (SMESH::Orientation)aPlaneData.Orientation,
5683 aPlaneData.Distance,
5686 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5687 aClippingPlaneInfo.Plane = aPlane;
5688 aClippingPlaneInfo.ActorList = anActorList;
5689 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5697 // update all VTK views
5698 QList<SUIT_ViewManager*> lst;
5699 getApp()->viewManagers(lst);
5700 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5701 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5702 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5703 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5704 vtkView->getRenderer()->ResetCameraClippingRange();
5711 \brief Adds preferences for dfont of VTK viewer
5713 \param pIf group identifier
5714 \param param parameter
5715 \return identifier of preferences
5717 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5719 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5721 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5724 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5725 fam.append( tr( "SMESH_FONT_COURIER" ) );
5726 fam.append( tr( "SMESH_FONT_TIMES" ) );
5728 setPreferenceProperty( tfont, "fonts", fam );
5730 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5731 setPreferenceProperty( tfont, "features", f );
5737 \brief Actions after hypothesis edition
5738 Updates object browser after hypothesis edition
5740 void SMESHGUI::onHypothesisEdit( int result )
5743 SMESHGUI::Modified();
5744 updateObjBrowser( true );
5749 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5750 \param pview view being closed
5752 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5753 #ifndef DISABLE_PLOT2DVIEWER
5754 //Crear all Plot2d Viewers if need.
5755 SMESH::ClearPlot2Viewers(pview);
5760 \brief Connects or disconnects signals about activating and cloning view on the module slots
5761 \param pview view which is connected/disconnected
5763 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5767 SUIT_ViewManager* viewMgr = pview->getViewManager();
5769 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5770 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5772 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5773 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5778 \brief Return \c true if object can be renamed
5780 bool SMESHGUI::renameAllowed( const QString& entry) const {
5781 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5785 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5789 bool appRes = SalomeApp_Module::renameAllowed(entry);
5793 // check type to prevent renaming of inappropriate objects
5794 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5795 if (aType == MESH || aType == GROUP ||
5796 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5797 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5798 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5799 aType == HYPOTHESIS || aType == ALGORITHM)
5806 Rename object by entry.
5807 \param entry entry of the object
5808 \param name new name of the object
5809 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5811 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5813 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5817 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5821 bool appRes = SalomeApp_Module::renameObject(entry,name);
5825 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5826 _PTR(GenericAttribute) anAttr;
5827 _PTR(AttributeName) aName;
5829 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5831 // check type to prevent renaming of inappropriate objects
5832 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5833 if (aType == MESH || aType == GROUP ||
5834 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5835 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5836 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5837 aType == HYPOTHESIS || aType == ALGORITHM) {
5838 if ( !name.isEmpty() ) {
5839 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5841 // update name of group object and its actor
5842 Handle(SALOME_InteractiveObject) IObject =
5843 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5845 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5846 if( !aGroupObject->_is_nil() ) {
5847 aGroupObject->SetName( qPrintable(name) );
5848 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5849 anActor->setName( qPrintable(name) );