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 );
3505 createMenu( 116, importId, -1 );
3507 createMenu( 121, exportId, -1 );
3508 createMenu( 122, exportId, -1 );
3509 createMenu( 123, exportId, -1 );
3510 createMenu( 140, exportId, -1 ); // export to STL
3511 createMenu( 142, exportId, -1 ); // export to CGNS
3513 createMenu( separator(), fileId, 10 );
3515 createMenu( 33, editId, -1 );
3517 createMenu( 5105, toolsId, -1 );
3519 createMenu( 702, meshId, -1 ); // "Mesh" menu
3520 createMenu( 703, meshId, -1 );
3521 createMenu( 704, meshId, -1 );
3522 createMenu( 710, meshId, -1 );
3523 createMenu( 705, meshId, -1 );
3524 createMenu( separator(), meshId, -1 );
3525 createMenu( 701, meshId, -1 );
3526 createMenu( 711, meshId, -1 );
3527 createMenu( 712, meshId, -1 );
3528 createMenu( 713, meshId, -1 );
3529 createMenu( separator(), meshId, -1 );
3530 createMenu( 801, meshId, -1 );
3531 createMenu( 806, meshId, -1 );
3532 createMenu( 802, meshId, -1 );
3533 createMenu( 803, meshId, -1 );
3534 createMenu( 815, meshId, -1 );
3535 createMenu( separator(), meshId, -1 );
3536 createMenu( 810, meshId, -1 );
3537 createMenu( 811, meshId, -1 );
3538 createMenu( 812, meshId, -1 );
3539 createMenu( separator(), meshId, -1 );
3540 createMenu( 814, meshId, -1 );
3541 createMenu( separator(), meshId, -1 );
3542 createMenu( 900, meshId, -1 );
3543 //createMenu( 902, meshId, -1 );
3544 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3545 createMenu( 904, meshId, -1 );
3546 createMenu( separator(), meshId, -1 );
3548 createMenu( 6005, nodeId, -1 );
3549 createMenu( 6002, edgeId, -1 );
3550 createMenu( 6003, edgeId, -1 );
3551 createMenu( 6001, edgeId, -1 );
3552 createMenu( 6004, edgeId, -1 );
3553 createMenu( 6021, faceId, -1 );
3554 createMenu( 6025, faceId, -1 );
3555 createMenu( 6027, faceId, -1 );
3556 createMenu( 6018, faceId, -1 );
3557 createMenu( 6019, faceId, -1 );
3558 createMenu( 6011, faceId, -1 );
3559 createMenu( 6012, faceId, -1 );
3560 createMenu( 6013, faceId, -1 );
3561 createMenu( 6014, faceId, -1 );
3562 createMenu( 6015, faceId, -1 );
3563 createMenu( 6016, faceId, -1 );
3564 createMenu( 6022, faceId, -1 );
3565 createMenu( 6017, volumeId, -1 );
3566 createMenu( 6009, volumeId, -1 );
3567 createMenu( 6023, volumeId, -1 );
3568 createMenu( 6024, volumeId, -1 );
3569 createMenu( 6026, volumeId, -1 );
3571 createMenu( 4000, addId, -1 );
3572 createMenu( 4009, addId, -1 );
3573 createMenu( 4010, addId, -1 );
3574 createMenu( 4021, addId, -1 );
3575 createMenu( 4022, addId, -1 );
3576 createMenu( 4023, addId, -1 );
3577 createMenu( 4031, addId, -1 );
3578 createMenu( 4032, addId, -1 );
3579 createMenu( 4033, addId, -1 );
3580 createMenu( separator(), addId, -1 );
3581 createMenu( 4034, addId, -1 );
3582 createMenu( 4035, addId, -1 );
3583 createMenu( 4036, addId, -1 );
3584 createMenu( 4037, addId, -1 );
3585 createMenu( 4038, addId, -1 );
3586 createMenu( 4039, addId, -1 );
3587 createMenu( 4040, addId, -1 );
3589 createMenu( 4041, removeId, -1 );
3590 createMenu( 4042, removeId, -1 );
3591 createMenu( 4044, removeId, -1 );
3592 createMenu( separator(), removeId, -1 );
3593 createMenu( 813, removeId, -1 );
3594 createMenu( separator(), removeId, -1 );
3595 createMenu( 4043, removeId, -1 );
3597 createMenu( 4051, renumId, -1 );
3598 createMenu( 4052, renumId, -1 );
3600 createMenu( 4061, transfId, -1 );
3601 createMenu( 4062, transfId, -1 );
3602 createMenu( 4063, transfId, -1 );
3603 createMenu( 4068, transfId, -1 );
3604 createMenu( 4064, transfId, -1 );
3605 createMenu( 4065, transfId, -1 );
3606 createMenu( 4066, transfId, -1 );
3607 createMenu( 4069, transfId, -1 );
3609 createMenu( 4067,modifyId, -1 );
3610 createMenu( 407, modifyId, -1 );
3611 createMenu( 408, modifyId, -1 );
3612 createMenu( 409, modifyId, -1 );
3613 createMenu( 410, modifyId, -1 );
3614 createMenu( 411, modifyId, -1 );
3615 createMenu( 419, modifyId, -1 );
3616 createMenu( 412, modifyId, -1 );
3617 createMenu( 413, modifyId, -1 );
3618 createMenu( 416, modifyId, -1 );
3619 createMenu( 414, modifyId, -1 );
3620 createMenu( 415, modifyId, -1 );
3621 createMenu( 417, modifyId, -1 );
3622 createMenu( 418, modifyId, -1 );
3624 createMenu( 501, measureId, -1 );
3625 createMenu( 502, measureId, -1 );
3626 createMenu( 214, viewId, -1 );
3628 // ----- create toolbars --------------
3629 int meshTb = createTool( tr( "TB_MESH" ) ),
3630 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3631 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3632 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3633 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3635 createTool( 702, meshTb );
3636 createTool( 703, meshTb );
3637 createTool( 704, meshTb );
3638 createTool( 710, meshTb );
3639 createTool( 705, meshTb );
3640 createTool( separator(), meshTb );
3641 createTool( 701, meshTb );
3642 createTool( 711, meshTb );
3643 createTool( 712, meshTb );
3644 createTool( 713, meshTb );
3645 createTool( separator(), meshTb );
3646 createTool( 801, meshTb );
3647 createTool( 806, meshTb );
3648 createTool( 802, meshTb );
3649 createTool( 803, meshTb );
3650 //createTool( 815, meshTb );
3651 createTool( separator(), meshTb );
3652 createTool( 900, meshTb );
3653 //createTool( 902, meshTb );
3654 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3655 createTool( 904, meshTb );
3656 createTool( separator(), meshTb );
3658 createTool( 6005, ctrlTb );
3659 createTool( separator(), ctrlTb );
3660 createTool( 6002, ctrlTb );
3661 createTool( 6003, ctrlTb );
3662 createTool( 6001, ctrlTb );
3663 createTool( 6004, ctrlTb );
3664 createTool( separator(), ctrlTb );
3665 createTool( 6021, ctrlTb );
3666 createTool( 6025, ctrlTb );
3667 createTool( 6027, ctrlTb );
3668 createTool( 6018, ctrlTb );
3669 createTool( 6019, ctrlTb );
3670 createTool( 6011, ctrlTb );
3671 createTool( 6012, ctrlTb );
3672 createTool( 6013, ctrlTb );
3673 createTool( 6014, ctrlTb );
3674 createTool( 6015, ctrlTb );
3675 createTool( 6016, ctrlTb );
3676 createTool( 6022, ctrlTb );
3677 createTool( separator(), ctrlTb );
3678 createTool( 6017, ctrlTb );
3679 createTool( 6009, ctrlTb );
3680 createTool( 6023, ctrlTb );
3681 createTool( 6024, ctrlTb );
3682 createTool( 6026, ctrlTb );
3683 createTool( separator(), ctrlTb );
3685 createTool( 4000, addRemTb );
3686 createTool( 4009, addRemTb );
3687 createTool( 4010, addRemTb );
3688 createTool( 4021, addRemTb );
3689 createTool( 4022, addRemTb );
3690 createTool( 4023, addRemTb );
3691 createTool( 4031, addRemTb );
3692 createTool( 4032, addRemTb );
3693 createTool( 4033, addRemTb );
3694 createTool( separator(), addRemTb );
3695 createTool( 4034, addRemTb );
3696 createTool( 4035, addRemTb );
3697 createTool( 4036, addRemTb );
3698 createTool( 4037, addRemTb );
3699 createTool( 4038, addRemTb );
3700 createTool( 4039, addRemTb );
3701 createTool( 4040, addRemTb );
3702 createTool( separator(), addRemTb );
3703 createTool( 4041, addRemTb );
3704 createTool( 4042, addRemTb );
3705 createTool( 4044, addRemTb );
3706 createTool( 4043, addRemTb );
3707 createTool( separator(), addRemTb );
3708 createTool( 4051, addRemTb );
3709 createTool( 4052, addRemTb );
3710 createTool( separator(), addRemTb );
3711 createTool( 4061, addRemTb );
3712 createTool( 4062, addRemTb );
3713 createTool( 4063, addRemTb );
3714 createTool( 4068, addRemTb );
3715 createTool( 4064, addRemTb );
3716 createTool( 4065, addRemTb );
3717 createTool( 4066, addRemTb );
3718 createTool( 4069, addRemTb );
3719 createTool( separator(), addRemTb );
3721 createTool( 4067,modifyTb );
3722 createTool( 407, modifyTb );
3723 createTool( 408, modifyTb );
3724 createTool( 409, modifyTb );
3725 createTool( 410, modifyTb );
3726 createTool( 411, modifyTb );
3727 createTool( 419, modifyTb );
3728 createTool( 412, modifyTb );
3729 createTool( 413, modifyTb );
3730 createTool( 416, modifyTb );
3731 createTool( 414, modifyTb );
3732 createTool( 415, modifyTb );
3733 createTool( 417, modifyTb );
3734 createTool( 418, modifyTb );
3736 createTool( 214, dispModeTb );
3738 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3739 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3742 QString OB = "'ObjectBrowser'",
3743 View = "'" + SVTK_Viewer::Type() + "'",
3745 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3746 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3747 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3748 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3749 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3750 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3751 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3752 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3753 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3754 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3755 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3757 mesh_part = mesh + " " + subMesh + " " + group,
3758 mesh_group = mesh + " " + group,
3759 hyp_alg = hypo + " " + algo;
3761 // popup for object browser
3763 isInvisible("not( isVisible )"),
3764 isEmpty("numberOfNodes = 0"),
3765 isNotEmpty("numberOfNodes <> 0"),
3767 // has nodes, edges, etc in VISIBLE! actor
3768 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3769 hasElems("(count( elemTypes ) > 0)"),
3770 hasDifferentElems("(count( elemTypes ) > 1)"),
3771 hasElems0d("({'Elem0d'} in elemTypes)"),
3772 hasEdges("({'Edge'} in elemTypes)"),
3773 hasFaces("({'Face'} in elemTypes)"),
3774 hasVolumes("({'Volume'} in elemTypes)");
3776 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3777 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3778 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3779 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3780 createPopupItem( 803, OB, group ); // EDIT_GROUP
3781 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3783 popupMgr()->insert( separator(), -1, 0 );
3784 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3785 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3786 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3787 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3788 createPopupItem( 214, OB, mesh_part ); // UPDATE
3789 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3790 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3791 popupMgr()->insert( separator(), -1, 0 );
3792 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3793 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3794 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3795 popupMgr()->insert( separator(), -1, 0 );
3796 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3797 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3798 popupMgr()->insert( separator(), -1, 0 );
3799 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3800 popupMgr()->insert( separator(), -1, 0 );
3801 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3802 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3804 popupMgr()->insert( separator(), -1, 0 );
3806 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3807 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3808 QString only_one_2D = only_one_non_empty + " && dim>1";
3810 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3811 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3812 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3813 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3814 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3815 popupMgr()->insert( separator(), -1, 0 );
3818 createPopupItem( 803, View, group ); // EDIT_GROUP
3819 createPopupItem( 804, View, elems ); // ADD
3820 createPopupItem( 805, View, elems ); // REMOVE
3822 popupMgr()->insert( separator(), -1, 0 );
3823 createPopupItem( 214, View, mesh_part ); // UPDATE
3824 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3825 createPopupItem( 904, View, mesh ); // FIND_ELEM
3826 popupMgr()->insert( separator(), -1, 0 );
3828 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3829 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3830 popupMgr()->insert( separator(), -1, 0 );
3833 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3834 QString aType = QString( "%1type in {%2}" ).arg( lc );
3835 aType = aType.arg( mesh_part );
3836 QString aMeshInVTK = aClient + "&&" + aType;
3838 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3839 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3840 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3842 //-------------------------------------------------
3844 //-------------------------------------------------
3845 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3847 popupMgr()->insert( action( 9010 ), anId, -1 );
3848 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3849 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3851 popupMgr()->insert( action( 9011 ), anId, -1 );
3852 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3853 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3855 popupMgr()->insert( separator(), -1, -1 );
3857 //-------------------------------------------------
3859 //-------------------------------------------------
3860 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3862 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3863 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3864 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3866 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3867 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3868 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3870 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3871 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3872 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3874 popupMgr()->insert( separator(), anId, -1 );
3876 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3877 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3878 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3880 //-------------------------------------------------
3882 //-------------------------------------------------
3883 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3885 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3887 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3888 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3889 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3891 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3892 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3893 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3895 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3896 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3897 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3899 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3900 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3901 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3903 popupMgr()->insert( separator(), anId, -1 );
3905 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3906 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3909 //-------------------------------------------------
3910 // Representation of the 2D Quadratic elements
3911 //-------------------------------------------------
3912 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3913 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3914 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3915 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3917 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3918 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3919 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3921 //-------------------------------------------------
3922 // Orientation of faces
3923 //-------------------------------------------------
3924 popupMgr()->insert( action( 221 ), -1, -1 );
3925 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3926 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3928 //-------------------------------------------------
3930 //-------------------------------------------------
3931 popupMgr()->insert( action( 1132 ), -1, -1 );
3932 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3934 //-------------------------------------------------
3936 //-------------------------------------------------
3937 popupMgr()->insert( action( 1133 ), -1, -1 );
3938 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3940 //-------------------------------------------------
3942 //-------------------------------------------------
3944 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3945 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3946 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3947 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3949 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3951 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3952 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3954 popupMgr()->insert( separator(), anId, -1 );
3956 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3958 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3959 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3960 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3962 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3964 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3965 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3966 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3968 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3969 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3970 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3972 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3973 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3974 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3976 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3977 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3978 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3980 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3982 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3983 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3984 QtxPopupMgr::VisibleRule );
3985 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3987 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3988 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3989 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3991 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3992 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3993 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
3995 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
3996 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3997 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
3999 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4000 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4001 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4003 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4004 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4005 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4007 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4008 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4009 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4011 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4012 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4013 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4015 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4016 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4017 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4019 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4020 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4021 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4023 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4024 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4025 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4027 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4028 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4029 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4031 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4033 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4034 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4035 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4037 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4038 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4039 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4041 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4042 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4043 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4045 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4046 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4047 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4049 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4050 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4051 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4053 popupMgr()->insert( separator(), anId, -1 );
4055 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4056 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4058 popupMgr()->insert( separator(), anId, -1 );
4060 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4062 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4063 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4065 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4066 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4067 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4069 #ifndef DISABLE_PLOT2DVIEWER
4070 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4071 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4074 //-------------------------------------------------
4076 //-------------------------------------------------
4077 popupMgr()->insert( separator(), -1, -1 );
4078 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4079 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4080 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4081 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4083 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4084 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4086 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4087 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4089 popupMgr()->insert( separator(), -1, -1 );
4091 //-------------------------------------------------
4093 //-------------------------------------------------
4094 popupMgr()->insert( action( 1134 ), -1, -1 );
4095 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4097 popupMgr()->insert( separator(), -1, -1 );
4099 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4100 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4102 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4103 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4106 //================================================================================
4108 * \brief Return true if SMESH or GEOM objects are selected.
4109 * Is called form LightApp_Module::activateModule() which clear selection if
4110 * not isSelectionCompatible()
4112 //================================================================================
4114 bool SMESHGUI::isSelectionCompatible()
4116 bool isCompatible = true;
4117 SALOME_ListIO selected;
4118 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4119 Sel->selectedObjects( selected );
4121 SALOME_ListIteratorOfListIO It( selected );
4122 for ( ; isCompatible && It.More(); It.Next())
4124 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4125 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4127 return isCompatible;
4131 bool SMESHGUI::reusableOperation( const int id )
4133 // compute, evaluate and precompute are not reusable operations
4134 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4137 bool SMESHGUI::activateModule( SUIT_Study* study )
4139 bool res = SalomeApp_Module::activateModule( study );
4141 setMenuShown( true );
4142 setToolShown( true );
4144 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4145 PyGILState_STATE gstate = PyGILState_Ensure();
4146 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4147 if(pluginsmanager==NULL)
4151 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4156 PyGILState_Release(gstate);
4157 // end of GEOM plugins loading
4159 // Reset actions accelerator keys
4160 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4161 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4162 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4164 action( 33)->setEnabled(true); // Delete: Key_Delete
4166 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4167 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4168 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4169 if ( _PTR(Study) aStudy = s->studyDS()) {
4170 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4171 updateObjBrowser(); // objects can be removed
4174 // get all view currently opened in the study and connect their signals to
4175 // the corresponding slots of the class.
4176 SUIT_Desktop* aDesk = study->application()->desktop();
4178 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4179 SUIT_ViewWindow* wnd;
4180 foreach ( wnd, wndList )
4187 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4189 setMenuShown( false );
4190 setToolShown( false );
4192 EmitSignalCloseAllDialogs();
4194 // Unset actions accelerator keys
4195 action(111)->setShortcut(QKeySequence()); // Import DAT
4196 action(112)->setShortcut(QKeySequence()); // Import UNV
4197 action(113)->setShortcut(QKeySequence()); // Import MED
4199 action( 33)->setEnabled(false); // Delete: Key_Delete
4201 return SalomeApp_Module::deactivateModule( study );
4204 void SMESHGUI::studyClosed( SUIT_Study* s )
4206 SMESH::RemoveVisuData( s->id() );
4207 SalomeApp_Module::studyClosed( s );
4210 void SMESHGUI::OnGUIEvent()
4212 const QObject* obj = sender();
4213 if ( !obj || !obj->inherits( "QAction" ) )
4215 int id = actionId((QAction*)obj);
4220 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4222 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4223 if ( CORBA::is_nil( myComponentSMESH ) )
4225 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4227 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4228 return aGUI.myComponentSMESH;
4231 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4232 return myComponentSMESH;
4235 QString SMESHGUI::engineIOR() const
4237 CORBA::ORB_var anORB = getApp()->orb();
4238 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4239 return QString( anIOR.in() );
4242 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4244 SalomeApp_Module::contextMenuPopup( client, menu, title );
4246 selectionMgr()->selectedObjects( lst );
4247 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4248 Handle(SALOME_InteractiveObject) io = lst.First();
4249 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4250 _PTR(Study) study = appStudy->studyDS();
4251 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4253 QString aName = QString( obj->GetName().c_str() );
4254 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4255 aName.remove( (aName.length() - 1), 1 );
4261 LightApp_Selection* SMESHGUI::createSelection() const
4263 return new SMESHGUI_Selection();
4266 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4268 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4269 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4272 void SMESHGUI::viewManagers( QStringList& list ) const
4274 list.append( SVTK_Viewer::Type() );
4277 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4279 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4280 SMESH::UpdateSelectionProp( this );
4282 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4283 for(int i = 0; i < aViews.count() ; i++){
4284 SUIT_ViewWindow *sf = aViews[i];
4290 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4292 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4293 myClippingPlaneInfoMap.erase( theViewManager );
4296 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4298 theActor->AddObserver( SMESH::DeleteActorEvent,
4299 myEventCallbackCommand.GetPointer(),
4303 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4304 unsigned long theEvent,
4305 void* theClientData,
4308 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4309 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4310 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4311 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4312 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4313 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4314 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4315 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4316 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4317 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4318 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4319 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4320 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4321 if( anActor == *anIter3 ) {
4322 anActorList.erase( anIter3 );
4333 void SMESHGUI::createPreferences()
4335 // General tab ------------------------------------------------------------------------
4336 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4338 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4339 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4340 setPreferenceProperty( lim, "min", 0 );
4341 setPreferenceProperty( lim, "max", 100000000 );
4342 setPreferenceProperty( lim, "step", 1000 );
4343 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4345 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4346 setPreferenceProperty( qaGroup, "columns", 2 );
4347 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4348 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4349 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4350 setPreferenceProperty( prec, "min", 0 );
4351 setPreferenceProperty( prec, "max", 16 );
4353 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4354 setPreferenceProperty( dispgroup, "columns", 2 );
4355 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4357 modes.append( "Wireframe" );
4358 modes.append( "Shading" );
4359 modes.append( "Nodes" );
4360 modes.append( "Shrink" );
4361 QList<QVariant> indices;
4362 indices.append( 0 );
4363 indices.append( 1 );
4364 indices.append( 2 );
4365 indices.append( 3 );
4366 setPreferenceProperty( dispmode, "strings", modes );
4367 setPreferenceProperty( dispmode, "indexes", indices );
4369 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4370 setPreferenceProperty( arcgroup, "columns", 2 );
4371 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4372 QStringList quadraticModes;
4373 quadraticModes.append("Lines");
4374 quadraticModes.append("Arcs");
4376 indices.append( 0 );
4377 indices.append( 1 );
4378 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4379 setPreferenceProperty( quadraticmode, "indexes", indices );
4381 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4382 "SMESH", "max_angle" );
4383 setPreferenceProperty( maxAngle, "min", 1 );
4384 setPreferenceProperty( maxAngle, "max", 90 );
4388 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4389 setPreferenceProperty( exportgroup, "columns", 2 );
4390 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4391 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4393 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4394 setPreferenceProperty( computeGroup, "columns", 2 );
4395 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4397 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4398 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4399 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4401 indices.append( 0 );
4402 indices.append( 1 );
4403 indices.append( 2 );
4404 setPreferenceProperty( notifyMode, "strings", modes );
4405 setPreferenceProperty( notifyMode, "indexes", indices );
4407 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4408 setPreferenceProperty( computeGroup, "columns", 2 );
4409 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4411 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4412 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4414 indices.append( 0 );
4415 indices.append( 1 );
4416 setPreferenceProperty( elemInfo, "strings", modes );
4417 setPreferenceProperty( elemInfo, "indexes", indices );
4419 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4420 setPreferenceProperty( segGroup, "columns", 2 );
4421 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4422 "SMESH", "segmentation" );
4423 setPreferenceProperty( segLen, "min", 1 );
4424 setPreferenceProperty( segLen, "max", 10000000 );
4425 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4426 "SMESH", "nb_segments_per_edge" );
4427 setPreferenceProperty( nbSeg, "min", 1 );
4428 setPreferenceProperty( nbSeg, "max", 10000000 );
4430 // Quantities with individual precision settings
4431 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4432 setPreferenceProperty( precGroup, "columns", 2 );
4434 const int nbQuantities = 6;
4435 int precs[nbQuantities], ii = 0;
4436 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4437 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4438 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4439 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4440 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4441 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4442 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4443 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4444 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4445 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4446 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4447 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4449 // Set property for precision value for spinboxes
4450 for ( ii = 0; ii < nbQuantities; ii++ ){
4451 setPreferenceProperty( precs[ii], "min", -14 );
4452 setPreferenceProperty( precs[ii], "max", 14 );
4453 setPreferenceProperty( precs[ii], "precision", 2 );
4456 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4457 setPreferenceProperty( previewGroup, "columns", 2 );
4458 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4459 setPreferenceProperty( chunkSize, "min", 0 );
4460 setPreferenceProperty( chunkSize, "max", 1000 );
4461 setPreferenceProperty( chunkSize, "step", 50 );
4463 // Mesh tab ------------------------------------------------------------------------
4464 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4465 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4466 setPreferenceProperty( nodeGroup, "columns", 3 );
4468 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4470 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4472 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4473 QList<QVariant> aMarkerTypeIndicesList;
4474 QList<QVariant> aMarkerTypeIconsList;
4475 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4476 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4477 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4478 aMarkerTypeIndicesList << i;
4479 aMarkerTypeIconsList << pixmap;
4481 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4482 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4484 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4486 QList<QVariant> aMarkerScaleIndicesList;
4487 QStringList aMarkerScaleValuesList;
4488 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4489 aMarkerScaleIndicesList << i;
4490 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4492 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4493 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4495 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4496 setPreferenceProperty( elemGroup, "columns", 2 );
4498 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4499 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4500 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4501 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4503 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4504 setPreferenceProperty( grpGroup, "columns", 2 );
4506 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4508 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4509 //setPreferenceProperty( sp, "hstretch", 0 );
4510 //setPreferenceProperty( sp, "vstretch", 0 );
4512 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4513 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4514 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4515 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4516 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4517 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4518 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4520 setPreferenceProperty( size0d, "min", 1 );
4521 setPreferenceProperty( size0d, "max", 10 );
4523 setPreferenceProperty( sp, "hstretch", 0 );
4524 setPreferenceProperty( sp, "vstretch", 0 );
4526 setPreferenceProperty( elemW, "min", 1 );
4527 setPreferenceProperty( elemW, "max", 5 );
4529 setPreferenceProperty( shrink, "min", 0 );
4530 setPreferenceProperty( shrink, "max", 100 );
4532 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4533 setPreferenceProperty( orientGroup, "columns", 1 );
4535 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4536 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4538 setPreferenceProperty( orientScale, "min", 0.05 );
4539 setPreferenceProperty( orientScale, "max", 0.5 );
4540 setPreferenceProperty( orientScale, "step", 0.05 );
4542 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4544 // Selection tab ------------------------------------------------------------------------
4545 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4547 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4548 setPreferenceProperty( selGroup, "columns", 2 );
4550 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4551 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4552 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4554 setPreferenceProperty( selW, "min", 1 );
4555 setPreferenceProperty( selW, "max", 5 );
4557 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4558 setPreferenceProperty( preGroup, "columns", 2 );
4560 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4561 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4563 setPreferenceProperty( preW, "min", 1 );
4564 setPreferenceProperty( preW, "max", 5 );
4566 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4567 setPreferenceProperty( precSelGroup, "columns", 2 );
4569 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4570 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4571 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4573 // Scalar Bar tab ------------------------------------------------------------------------
4574 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4575 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4576 setPreferenceProperty( fontGr, "columns", 2 );
4578 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4579 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4581 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4582 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4584 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4585 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4587 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4588 setPreferenceProperty( numcol, "min", 2 );
4589 setPreferenceProperty( numcol, "max", 256 );
4591 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4592 setPreferenceProperty( numlab, "min", 2 );
4593 setPreferenceProperty( numlab, "max", 65 );
4595 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4596 setPreferenceProperty( orientGr, "columns", 2 );
4597 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4598 QStringList orients;
4599 orients.append( tr( "SMESH_VERTICAL" ) );
4600 orients.append( tr( "SMESH_HORIZONTAL" ) );
4601 indices.clear(); indices.append( 0 ); indices.append( 1 );
4602 setPreferenceProperty( orient, "strings", orients );
4603 setPreferenceProperty( orient, "indexes", indices );
4605 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4606 setPreferenceProperty( posVSizeGr, "columns", 2 );
4607 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4608 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4609 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4610 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4611 setPreferenceProperty( xv, "step", 0.1 );
4612 setPreferenceProperty( xv, "min", 0.0 );
4613 setPreferenceProperty( xv, "max", 1.0 );
4614 setPreferenceProperty( yv, "step", 0.1 );
4615 setPreferenceProperty( yv, "min", 0.0 );
4616 setPreferenceProperty( yv, "max", 1.0 );
4617 setPreferenceProperty( wv, "step", 0.1 );
4618 setPreferenceProperty( wv, "min", 0.0 );
4619 setPreferenceProperty( wv, "max", 1.0 );
4620 setPreferenceProperty( hv, "min", 0.0 );
4621 setPreferenceProperty( hv, "max", 1.0 );
4622 setPreferenceProperty( hv, "step", 0.1 );
4624 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4625 setPreferenceProperty( posHSizeGr, "columns", 2 );
4626 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4627 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4628 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4629 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4630 setPreferenceProperty( xv, "min", 0.0 );
4631 setPreferenceProperty( xv, "max", 1.0 );
4632 setPreferenceProperty( xv, "step", 0.1 );
4633 setPreferenceProperty( xh, "min", 0.0 );
4634 setPreferenceProperty( xh, "max", 1.0 );
4635 setPreferenceProperty( xh, "step", 0.1 );
4636 setPreferenceProperty( yh, "min", 0.0 );
4637 setPreferenceProperty( yh, "max", 1.0 );
4638 setPreferenceProperty( yh, "step", 0.1 );
4639 setPreferenceProperty( wh, "min", 0.0 );
4640 setPreferenceProperty( wh, "max", 1.0 );
4641 setPreferenceProperty( wh, "step", 0.1 );
4642 setPreferenceProperty( hh, "min", 0.0 );
4643 setPreferenceProperty( hh, "max", 1.0 );
4644 setPreferenceProperty( hh, "step", 0.1 );
4646 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4647 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4648 setPreferenceProperty( distributionGr, "columns", 3 );
4650 types.append( tr( "SMESH_MONOCOLOR" ) );
4651 types.append( tr( "SMESH_MULTICOLOR" ) );
4652 indices.clear(); indices.append( 0 ); indices.append( 1 );
4653 setPreferenceProperty( coloringType, "strings", types );
4654 setPreferenceProperty( coloringType, "indexes", indices );
4655 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4659 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4661 if( sect=="SMESH" ) {
4662 float sbX1,sbY1,sbW,sbH;
4663 float aTol = 1.00000009999999;
4664 std::string aWarning;
4665 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4666 if( name=="selection_object_color" || name=="selection_element_color" ||
4667 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4668 name=="selection_precision_node" || name=="selection_precision_element" ||
4669 name=="selection_precision_object")
4670 SMESH::UpdateSelectionProp( this );
4671 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4672 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4673 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4674 if(sbX1+sbW > aTol){
4675 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4678 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4679 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4682 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4683 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4684 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4685 if(sbY1+sbH > aTol){
4686 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4687 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4688 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4691 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4692 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4693 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4694 if(sbX1+sbW > aTol){
4695 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4698 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4699 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4702 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4703 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4704 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4705 if(sbY1+sbH > aTol){
4706 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4709 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4710 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4713 else if ( name == "segmentation" ) {
4714 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4715 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4717 else if ( name == "nb_segments_per_edge" ) {
4718 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4719 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4722 if(aWarning.size() != 0){
4723 aWarning += "The default values are applied instead.";
4724 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4725 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4726 QObject::tr(aWarning.c_str()));
4731 //================================================================================
4733 * \brief Update something in accordance with update flags
4734 * \param theFlags - update flags
4736 * Update viewer or/and object browser etc. in accordance with update flags ( see
4737 * LightApp_UpdateFlags enumeration ).
4739 //================================================================================
4740 void SMESHGUI::update( const int flags )
4742 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4743 SMESH::UpdateView();
4745 SalomeApp_Module::update( flags );
4748 //================================================================================
4750 * \brief Set default selection mode
4752 * SLOT called when operation commited. Sets default selection mode
4754 //================================================================================
4755 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4757 SVTK_ViewWindow* vtkWnd =
4758 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4760 vtkWnd->SetSelectionMode( ActorSelection );
4763 //================================================================================
4765 * \brief Set default selection mode
4767 * SLOT called when operation aborted. Sets default selection mode
4769 //================================================================================
4770 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4772 SVTK_ViewWindow* vtkWnd =
4773 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4775 vtkWnd->SetSelectionMode( ActorSelection );
4778 //================================================================================
4780 * \brief Creates operation with given identifier
4781 * \param id - identifier of operation to be started
4782 * \return Pointer on created operation or NULL if operation is not created
4784 * Virtual method redefined from the base class creates operation with given id.
4785 * It is called called automatically from startOperation method of base class.
4787 //================================================================================
4788 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4790 LightApp_Operation* op = 0;
4791 // to do : create operation here
4794 case 417: //convert to quadratic
4795 op = new SMESHGUI_ConvToQuadOp();
4797 case 418: // create 2D mesh as boundary on 3D
4798 op = new SMESHGUI_Make2DFrom3DOp();
4800 case 701: // Compute mesh
4801 op = new SMESHGUI_ComputeOp();
4803 case 702: // Create mesh
4804 op = new SMESHGUI_MeshOp( true, true );
4806 case 703: // Create sub-mesh
4807 op = new SMESHGUI_MeshOp( true, false );
4809 case 704: // Edit mesh/sub-mesh
4810 op = new SMESHGUI_MeshOp( false );
4812 case 711: // Precompute mesh
4813 op = new SMESHGUI_PrecomputeOp();
4815 case 712: // Evaluate mesh
4816 op = new SMESHGUI_EvaluateOp();
4818 case 713: // Evaluate mesh
4819 op = new SMESHGUI_MeshOrderOp();
4821 case 806: // Create group on geom
4822 op = new SMESHGUI_GroupOnShapeOp();
4824 case 904: // Find element
4825 op = new SMESHGUI_FindElemByPointOp();
4827 case 4067: // make mesh pass through point
4828 op = new SMESHGUI_MakeNodeAtPointOp();
4835 op = SalomeApp_Module::createOperation( id );
4839 //================================================================================
4841 * \brief Stops current operations and starts a given one
4842 * \param id - The id of the operation to start
4844 //================================================================================
4846 void SMESHGUI::switchToOperation(int id)
4848 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4849 activeStudy()->abortAllOperations();
4850 startOperation( id );
4853 LightApp_Displayer* SMESHGUI::displayer()
4856 myDisplayer = new SMESHGUI_Displayer( getApp() );
4860 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4863 int aTolerance = 64;
4864 int anIterations = 0;
4870 if( anIterations % aPeriod == 0 )
4873 if( aTolerance < 1 )
4877 aHue = (int)( 360.0 * rand() / RAND_MAX );
4880 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4881 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4882 for( ; it != itEnd; ++it )
4884 SALOMEDS::Color anAutoColor = *it;
4885 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4888 aQColor.getHsv( &h, &s, &v );
4889 if( abs( h - aHue ) < aTolerance )
4901 aColor.setHsv( aHue, 255, 255 );
4903 SALOMEDS::Color aSColor;
4904 aSColor.R = (double)aColor.red() / 255.0;
4905 aSColor.G = (double)aColor.green() / 255.0;
4906 aSColor.B = (double)aColor.blue() / 255.0;
4911 const char gSeparator = '_'; // character used to separate parameter names
4912 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4913 const char gPathSep = '|'; // character used to separate paths
4916 * \brief Store visual parameters
4918 * This method is called just before the study document is saved.
4919 * Store visual parameters in AttributeParameter attribue(s)
4921 void SMESHGUI::storeVisualParameters (int savePoint)
4923 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4924 if (!appStudy || !appStudy->studyDS())
4926 _PTR(Study) studyDS = appStudy->studyDS();
4928 // componentName is used for encoding of entries when storing them in IParameters
4929 std::string componentName = myComponentSMESH->ComponentDataType();
4930 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4931 //if (!aSComponent) return;
4934 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4935 componentName.c_str(),
4937 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4939 // store map of custom markers
4940 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4941 if( !aMarkerMap.empty() )
4943 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4944 for( ; anIter != aMarkerMap.end(); anIter++ )
4946 int anId = anIter->first;
4947 VTK::MarkerData aMarkerData = anIter->second;
4948 std::string aMarkerFileName = aMarkerData.first;
4949 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4950 if( aMarkerTexture.size() < 3 )
4951 continue; // should contain at least width, height and the first value
4953 QString aPropertyName( "texture" );
4954 aPropertyName += gSeparator;
4955 aPropertyName += QString::number( anId );
4957 QString aPropertyValue = aMarkerFileName.c_str();
4958 aPropertyValue += gPathSep;
4960 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4961 ushort aWidth = *aTextureIter++;
4962 ushort aHeight = *aTextureIter++;
4963 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4964 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4965 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4966 aPropertyValue += QString::number( *aTextureIter );
4968 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4972 // viewers counters are used for storing view_numbers in IParameters
4975 // main cycle to store parameters of displayed objects
4976 QList<SUIT_ViewManager*> lst;
4977 QList<SUIT_ViewManager*>::Iterator it;
4978 getApp()->viewManagers(lst);
4979 for (it = lst.begin(); it != lst.end(); it++)
4981 SUIT_ViewManager* vman = *it;
4982 QString vType = vman->getType();
4984 // saving VTK actors properties
4985 if (vType == SVTK_Viewer::Type())
4987 // store the clipping planes attached to the view manager
4988 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4989 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4990 if( anIter != myClippingPlaneInfoMap.end() )
4991 aClippingPlaneInfoList = anIter->second;
4993 if( !aClippingPlaneInfoList.empty() ) {
4994 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
4995 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
4997 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
4998 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5000 QString aPropertyName( "ClippingPlane" );
5001 aPropertyName += gSeparator;
5002 aPropertyName += QString::number( vtkViewers );
5003 aPropertyName += gSeparator;
5004 aPropertyName += QString::number( anId );
5006 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5007 aPropertyValue += gDigitsSep;
5008 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5009 aPropertyValue += gDigitsSep;
5010 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5011 aPropertyValue += gDigitsSep;
5012 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5014 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5018 QVector<SUIT_ViewWindow*> views = vman->getViews();
5019 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5021 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5023 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5024 vtkActorCollection* allActors = aCopy.GetActors();
5025 allActors->InitTraversal();
5026 while (vtkActor* actor = allActors->GetNextActor())
5028 if (actor->GetVisibility()) // store only visible actors
5030 SMESH_Actor* aSmeshActor = 0;
5031 if (actor->IsA("SMESH_Actor"))
5032 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5033 if (aSmeshActor && aSmeshActor->hasIO())
5035 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5038 // entry is "encoded" = it does NOT contain component adress,
5039 // since it is a subject to change on next component loading
5040 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5042 std::string param, vtkParam = vType.toLatin1().data();
5043 vtkParam += gSeparator;
5044 vtkParam += QString::number(vtkViewers).toLatin1().data();
5045 vtkParam += gSeparator;
5048 param = vtkParam + "Visibility";
5049 ip->setParameter(entry, param, "On");
5052 param = vtkParam + "Representation";
5053 ip->setParameter(entry, param, QString::number
5054 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5057 param = vtkParam + "IsShrunk";
5058 ip->setParameter(entry, param, QString::number
5059 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5061 // Displayed entities
5062 unsigned int aMode = aSmeshActor->GetEntityMode();
5063 bool isE = aMode & SMESH_Actor::eEdges;
5064 bool isF = aMode & SMESH_Actor::eFaces;
5065 bool isV = aMode & SMESH_Actor::eVolumes;
5067 QString modeStr ("e");
5068 modeStr += gDigitsSep; modeStr += QString::number(isE);
5069 modeStr += gDigitsSep; modeStr += "f";
5070 modeStr += gDigitsSep; modeStr += QString::number(isF);
5071 modeStr += gDigitsSep; modeStr += "v";
5072 modeStr += gDigitsSep; modeStr += QString::number(isV);
5074 param = vtkParam + "Entities";
5075 ip->setParameter(entry, param, modeStr.toLatin1().data());
5077 // Colors (surface:edge:)
5078 vtkFloatingPointType r, g, b;
5080 aSmeshActor->GetSufaceColor(r, g, b);
5081 QString colorStr ("surface");
5082 colorStr += gDigitsSep; colorStr += QString::number(r);
5083 colorStr += gDigitsSep; colorStr += QString::number(g);
5084 colorStr += gDigitsSep; colorStr += QString::number(b);
5086 aSmeshActor->GetBackSufaceColor(r, g, b);
5087 colorStr += gDigitsSep; colorStr += "backsurface";
5088 colorStr += gDigitsSep; colorStr += QString::number(r);
5089 colorStr += gDigitsSep; colorStr += QString::number(g);
5090 colorStr += gDigitsSep; colorStr += QString::number(b);
5092 aSmeshActor->GetEdgeColor(r, g, b);
5093 colorStr += gDigitsSep; colorStr += "edge";
5094 colorStr += gDigitsSep; colorStr += QString::number(r);
5095 colorStr += gDigitsSep; colorStr += QString::number(g);
5096 colorStr += gDigitsSep; colorStr += QString::number(b);
5098 aSmeshActor->GetNodeColor(r, g, b);
5099 colorStr += gDigitsSep; colorStr += "node";
5100 colorStr += gDigitsSep; colorStr += QString::number(r);
5101 colorStr += gDigitsSep; colorStr += QString::number(g);
5102 colorStr += gDigitsSep; colorStr += QString::number(b);
5104 param = vtkParam + "Colors";
5105 ip->setParameter(entry, param, colorStr.toLatin1().data());
5107 // Sizes of lines and points
5108 QString sizeStr ("line");
5109 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5110 sizeStr += gDigitsSep; sizeStr += "shrink";
5111 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5113 param = vtkParam + "Sizes";
5114 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5119 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5120 if( aMarkerType == VTK::MT_USER ) {
5121 markerStr += "custom";
5122 markerStr += gDigitsSep;
5123 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5127 markerStr += gDigitsSep;
5128 markerStr += QString::number( (int)aMarkerType );
5129 markerStr += gDigitsSep;
5130 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5133 param = vtkParam + "PointMarker";
5134 ip->setParameter(entry, param, markerStr.toLatin1().data());
5137 param = vtkParam + "Opacity";
5138 ip->setParameter(entry, param,
5139 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5142 param = vtkParam + "ClippingPlane";
5144 if( !aClippingPlaneInfoList.empty() ) {
5145 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5146 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5148 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5149 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5150 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5151 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5152 if( aSmeshActor == *anIter2 ) {
5153 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5154 QString::number( anId ).toLatin1().constData() );
5161 ip->setParameter( entry, param, "Off" );
5162 } // if (io->hasEntry())
5163 } // SMESH_Actor && hasIO
5165 } // while.. actors traversal
5169 } // if (SVTK view model)
5170 } // for (viewManagers)
5173 // data structures for clipping planes processing
5176 vtkIdType Orientation;
5177 vtkFloatingPointType Distance;
5178 vtkFloatingPointType Angle[2];
5180 typedef std::list<TPlaneData> TPlaneDataList;
5181 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5183 typedef std::list<vtkActor*> TActorList;
5186 TActorList ActorList;
5187 SUIT_ViewManager* ViewManager;
5189 typedef std::list<TPlaneInfo> TPlaneInfoList;
5190 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5193 * \brief Restore visual parameters
5195 * This method is called after the study document is opened.
5196 * Restore visual parameters from AttributeParameter attribue(s)
5198 void SMESHGUI::restoreVisualParameters (int savePoint)
5200 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5201 if (!appStudy || !appStudy->studyDS())
5203 _PTR(Study) studyDS = appStudy->studyDS();
5205 // componentName is used for encoding of entries when storing them in IParameters
5206 std::string componentName = myComponentSMESH->ComponentDataType();
5207 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5208 //if (!aSComponent) return;
5211 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5212 componentName.c_str(),
5214 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5216 // restore map of custom markers and map of clipping planes
5217 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5218 TPlaneDataMap aPlaneDataMap;
5220 std::vector<std::string> properties = ip->getProperties();
5221 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5223 std::string property = *propIt;
5224 QString aPropertyName( property.c_str() );
5225 QString aPropertyValue( ip->getProperty( property ).c_str() );
5227 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5228 if( aPropertyNameList.isEmpty() )
5231 QString aPropertyType = aPropertyNameList[0];
5232 if( aPropertyType == "texture" )
5234 if( aPropertyNameList.size() != 2 )
5238 int anId = aPropertyNameList[1].toInt( &ok );
5239 if( !ok || anId < 1 )
5242 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5243 if( aPropertyValueList.size() != 2 )
5246 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5247 QString aMarkerTextureString = aPropertyValueList[1];
5248 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5249 if( aMarkerTextureStringList.size() != 3 )
5253 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5258 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5262 VTK::MarkerTexture aMarkerTexture;
5263 aMarkerTexture.push_back( aWidth );
5264 aMarkerTexture.push_back( aHeight );
5266 QString aMarkerTextureData = aMarkerTextureStringList[2];
5267 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5269 QChar aChar = aMarkerTextureData.at( i );
5270 if( aChar.isDigit() )
5271 aMarkerTexture.push_back( aChar.digitValue() );
5274 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5276 else if( aPropertyType == "ClippingPlane" )
5278 if( aPropertyNameList.size() != 3 )
5282 int aViewId = aPropertyNameList[1].toInt( &ok );
5283 if( !ok || aViewId < 0 )
5287 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5288 if( !ok || aClippingPlaneId < 0 )
5291 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5292 if( aPropertyValueList.size() != 4 )
5295 TPlaneData aPlaneData;
5296 aPlaneData.Id = aClippingPlaneId;
5299 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5304 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5309 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5314 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5318 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5319 aPlaneDataList.push_back( aPlaneData );
5323 TPlaneInfoMap aPlaneInfoMap;
5325 std::vector<std::string> entries = ip->getEntries();
5327 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5329 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5330 QString entry (ip->decodeEntry(*entIt).c_str());
5332 // Check that the entry corresponds to a real object in the Study
5333 // as the object may be deleted or modified after the visual state is saved.
5334 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5335 if (!so) continue; //Skip the not existent entry
5337 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5338 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5340 std::vector<std::string>::iterator namesIt = paramNames.begin();
5341 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5343 // actors are stored in a map after displaying of them for
5344 // quicker access in the future: map < viewID to actor >
5345 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5347 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5349 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5350 // '_' is used as separator and should not be used in viewer type or parameter names.
5351 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5352 if (lst.size() != 3)
5355 QString viewerTypStr = lst[0];
5356 QString viewIndexStr = lst[1];
5357 QString paramNameStr = lst[2];
5360 int viewIndex = viewIndexStr.toUInt(&ok);
5361 if (!ok) // bad conversion of view index to integer
5365 if (viewerTypStr == SVTK_Viewer::Type())
5367 SMESH_Actor* aSmeshActor = 0;
5368 if (vtkActors.IsBound(viewIndex))
5369 aSmeshActor = vtkActors.Find(viewIndex);
5371 QList<SUIT_ViewManager*> lst;
5372 getApp()->viewManagers(viewerTypStr, lst);
5374 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5375 SUIT_ViewManager* vman = NULL;
5376 if (viewIndex >= 0 && viewIndex < lst.count())
5377 vman = lst.at(viewIndex);
5379 if (paramNameStr == "Visibility")
5381 if (!aSmeshActor && displayer() && vman)
5383 SUIT_ViewModel* vmodel = vman->getViewModel();
5384 // SVTK view model can be casted to SALOME_View
5385 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5387 // store displayed actor in a temporary map for quicker
5388 // access later when restoring other parameters
5389 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5390 vtkRenderer* Renderer = vtkView->getRenderer();
5391 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5392 vtkActorCollection* theActors = aCopy.GetActors();
5393 theActors->InitTraversal();
5394 bool isFound = false;
5395 vtkActor *ac = theActors->GetNextActor();
5396 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5397 if (ac->IsA("SMESH_Actor")) {
5398 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5399 if (aGeomAc->hasIO()) {
5400 Handle(SALOME_InteractiveObject) io =
5401 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5402 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5404 vtkActors.Bind(viewIndex, aGeomAc);
5410 } // if (paramNameStr == "Visibility")
5413 // the rest properties "work" with SMESH_Actor
5416 QString val ((*valuesIt).c_str());
5419 if (paramNameStr == "Representation") {
5420 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5423 else if (paramNameStr == "IsShrunk") {
5425 if (!aSmeshActor->IsShrunk())
5426 aSmeshActor->SetShrink();
5429 if (aSmeshActor->IsShrunk())
5430 aSmeshActor->UnShrink();
5433 // Displayed entities
5434 else if (paramNameStr == "Entities") {
5435 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5436 if (mode.count() == 6) {
5437 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5438 MESSAGE("Invalid order of data in Entities, must be: "
5439 "e:0/1:f:0/1:v:0/1");
5442 unsigned int aMode = aSmeshActor->GetEntityMode();
5443 unsigned int aNewMode =
5444 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5445 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5446 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5447 if (aNewMode != aMode)
5448 aSmeshActor->SetEntityMode(aNewMode);
5453 else if (paramNameStr == "Colors") {
5454 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5455 if (colors.count() == 16) {
5456 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5457 colors[8] != "edge" || colors[12] != "node") {
5458 MESSAGE("Invalid order of data in Colors, must be: "
5459 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5462 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5463 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5464 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5465 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5469 // Sizes of lines and points
5470 else if (paramNameStr == "Sizes") {
5471 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5472 if (sizes.count() == 4) {
5473 if (sizes[0] != "line" || sizes[2] != "shrink") {
5474 MESSAGE("Invalid order of data in Sizes, must be: "
5475 "line:int:shrink:float");
5478 aSmeshActor->SetLineWidth(sizes[1].toInt());
5479 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5482 else if (sizes.count() == 6) { // just to support old format
5483 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5484 MESSAGE("Invalid order of data in Sizes, must be: "
5485 "line:int:node:int:shrink:float");
5488 aSmeshActor->SetLineWidth(sizes[1].toInt());
5489 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5490 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5495 else if (paramNameStr == "PointMarker") {
5496 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5497 if( data.count() >= 2 ) {
5499 int aParam1 = data[1].toInt( &ok );
5501 if( data[0] == "std" && data.count() == 3 ) {
5502 int aParam2 = data[2].toInt( &ok );
5503 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5505 else if( data[0] == "custom" ) {
5506 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5507 if( markerIt != aMarkerMap.end() ) {
5508 VTK::MarkerData aMarkerData = markerIt->second;
5509 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5516 else if (paramNameStr == "Opacity") {
5517 aSmeshActor->SetOpacity(val.toFloat());
5520 else if (paramNameStr.startsWith("ClippingPlane")) {
5521 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5522 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5523 // new format - val looks like "Off" or "0" (plane id)
5524 // (note: in new format "Off" value is used only for consistency,
5525 // so it is processed together with values in old format)
5526 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5527 if( anIsOldFormat ) {
5528 if (paramNameStr == "ClippingPlane1" || val == "Off")
5529 aSmeshActor->RemoveAllClippingPlanes();
5531 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5532 double aDistance = vals[1].toFloat();
5533 vtkFloatingPointType anAngle[2];
5534 anAngle[0] = vals[2].toFloat();
5535 anAngle[1] = vals[3].toFloat();
5537 QList<SUIT_ViewManager*> lst;
5538 getApp()->viewManagers(viewerTypStr, lst);
5539 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5540 if (viewIndex >= 0 && viewIndex < lst.count()) {
5541 SUIT_ViewManager* vman = lst.at(viewIndex);
5542 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5544 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5546 SMESH::TActorList anActorList;
5547 anActorList.push_back( aSmeshActor );
5548 SMESH::OrientedPlane* aPlane =
5549 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5551 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5552 aClippingPlaneInfo.Plane = aPlane;
5553 aClippingPlaneInfo.ActorList = anActorList;
5554 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5561 int aPlaneId = val.toInt( &ok );
5562 if( ok && aPlaneId >= 0 ) {
5563 bool anIsDefinedPlane = false;
5564 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5565 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5566 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5567 TPlaneInfo& aPlaneInfo = *anIter;
5568 if( aPlaneInfo.PlaneId == aPlaneId ) {
5569 aPlaneInfo.ActorList.push_back( aSmeshActor );
5570 anIsDefinedPlane = true;
5574 if( !anIsDefinedPlane ) {
5575 TPlaneInfo aPlaneInfo;
5576 aPlaneInfo.PlaneId = aPlaneId;
5577 aPlaneInfo.ActorList.push_back( aSmeshActor );
5578 aPlaneInfo.ViewManager = vman;
5580 // to make the list sorted by plane id
5581 anIter = aPlaneInfoList.begin();
5582 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5583 const TPlaneInfo& aPlaneInfoRef = *anIter;
5584 if( aPlaneInfoRef.PlaneId > aPlaneId )
5587 aPlaneInfoList.insert( anIter, aPlaneInfo );
5592 } // if (aSmeshActor)
5593 } // other parameters than Visibility
5595 } // for names/parameters iterator
5596 } // for entries iterator
5598 // take into account planes with empty list of actors referred to them
5599 QList<SUIT_ViewManager*> aVMList;
5600 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5602 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5603 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5604 int aViewId = aPlaneDataIter->first;
5605 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5606 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5608 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5610 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5611 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5612 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5613 const TPlaneData& aPlaneData = *anIter2;
5614 int aPlaneId = aPlaneData.Id;
5616 bool anIsFound = false;
5617 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5618 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5619 const TPlaneInfo& aPlaneInfo = *anIter3;
5620 if( aPlaneInfo.PlaneId == aPlaneId ) {
5627 TPlaneInfo aPlaneInfo; // ActorList field is empty
5628 aPlaneInfo.PlaneId = aPlaneId;
5629 aPlaneInfo.ViewManager = aViewManager;
5631 // to make the list sorted by plane id
5632 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5633 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5634 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5635 if( aPlaneInfoRef.PlaneId > aPlaneId )
5638 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5644 // add clipping planes to actors according to the restored parameters
5645 // and update the clipping plane map
5646 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5647 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5648 int aViewId = anIter1->first;
5649 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5651 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5652 if( anIter2 == aPlaneDataMap.end() )
5654 const TPlaneDataList& aPlaneDataList = anIter2->second;
5656 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5657 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5658 const TPlaneInfo& aPlaneInfo = *anIter3;
5659 int aPlaneId = aPlaneInfo.PlaneId;
5660 const TActorList& anActorList = aPlaneInfo.ActorList;
5661 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5665 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5669 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5671 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5672 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5673 const TPlaneData& aPlaneData = *anIter4;
5674 if( aPlaneData.Id == aPlaneId ) {
5675 SMESH::OrientedPlane* aPlane =
5676 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5678 (SMESH::Orientation)aPlaneData.Orientation,
5679 aPlaneData.Distance,
5682 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5683 aClippingPlaneInfo.Plane = aPlane;
5684 aClippingPlaneInfo.ActorList = anActorList;
5685 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5693 // update all VTK views
5694 QList<SUIT_ViewManager*> lst;
5695 getApp()->viewManagers(lst);
5696 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5697 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5698 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5699 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5700 vtkView->getRenderer()->ResetCameraClippingRange();
5707 \brief Adds preferences for dfont of VTK viewer
5709 \param pIf group identifier
5710 \param param parameter
5711 \return identifier of preferences
5713 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5715 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5717 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5720 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5721 fam.append( tr( "SMESH_FONT_COURIER" ) );
5722 fam.append( tr( "SMESH_FONT_TIMES" ) );
5724 setPreferenceProperty( tfont, "fonts", fam );
5726 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5727 setPreferenceProperty( tfont, "features", f );
5733 \brief Actions after hypothesis edition
5734 Updates object browser after hypothesis edition
5736 void SMESHGUI::onHypothesisEdit( int result )
5739 SMESHGUI::Modified();
5740 updateObjBrowser( true );
5745 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5746 \param pview view being closed
5748 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5749 #ifndef DISABLE_PLOT2DVIEWER
5750 //Crear all Plot2d Viewers if need.
5751 SMESH::ClearPlot2Viewers(pview);
5756 \brief Connects or disconnects signals about activating and cloning view on the module slots
5757 \param pview view which is connected/disconnected
5759 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5763 SUIT_ViewManager* viewMgr = pview->getViewManager();
5765 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5766 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5768 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5769 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5774 \brief Return \c true if object can be renamed
5776 bool SMESHGUI::renameAllowed( const QString& entry) const {
5777 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5781 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5785 bool appRes = SalomeApp_Module::renameAllowed(entry);
5789 // check type to prevent renaming of inappropriate objects
5790 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5791 if (aType == MESH || aType == GROUP ||
5792 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5793 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5794 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5795 aType == HYPOTHESIS || aType == ALGORITHM)
5802 Rename object by entry.
5803 \param entry entry of the object
5804 \param name new name of the object
5805 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5807 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5809 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5813 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5817 bool appRes = SalomeApp_Module::renameObject(entry,name);
5821 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5822 _PTR(GenericAttribute) anAttr;
5823 _PTR(AttributeName) aName;
5825 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5827 // check type to prevent renaming of inappropriate objects
5828 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5829 if (aType == MESH || aType == GROUP ||
5830 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5831 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5832 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5833 aType == HYPOTHESIS || aType == ALGORITHM) {
5834 if ( !name.isEmpty() ) {
5835 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5837 // update name of group object and its actor
5838 Handle(SALOME_InteractiveObject) IObject =
5839 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5841 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5842 if( !aGroupObject->_is_nil() ) {
5843 aGroupObject->SetName( qPrintable(name) );
5844 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5845 anActor->setName( qPrintable(name) );