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_version.h>
90 #include <SMESH_Client.hxx>
91 #include <SMESH_Actor.h>
92 #include <SMESH_ScalarBarActor.h>
93 #include <SMESH_ActorUtils.h>
94 #include <SMESH_TypeFilter.hxx>
95 #include "SMESH_ControlsDef.hxx"
97 // SALOME GUI includes
98 #include <SalomeApp_Tools.h>
99 #include <SalomeApp_Study.h>
100 #include <SalomeApp_Application.h>
101 #include <SalomeApp_CheckFileDlg.h>
103 #include <LightApp_DataOwner.h>
104 #include <LightApp_Preferences.h>
105 #include <LightApp_SelectionMgr.h>
106 #include <LightApp_UpdateFlags.h>
107 #include <LightApp_NameDlg.h>
109 #include <SVTK_ViewWindow.h>
110 #include <SVTK_ViewModel.h>
111 #include <SVTK_ViewManager.h>
113 #include <VTKViewer_Algorithm.h>
115 #include <SUIT_MessageBox.h>
116 #include <SUIT_ResourceMgr.h>
117 #include <SUIT_FileDlg.h>
118 #include <SUIT_Desktop.h>
119 #include <SUIT_OverrideCursor.h>
120 #include <SUIT_Session.h>
122 #include <QtxPopupMgr.h>
123 #include <QtxFontEdit.h>
125 #include <SALOME_ListIO.hxx>
126 #include <SALOME_ListIteratorOfListIO.hxx>
128 #ifndef DISABLE_PLOT2DVIEWER
129 #include <SPlot2d_ViewModel.h>
130 #include <SPlot2d_Histogram.h>
134 #include <SALOMEconfig.h>
135 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
136 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
137 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
140 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
142 #include <QTextStream>
145 #include <boost/shared_ptr.hpp>
148 #include <vtkCamera.h>
149 #include <vtkRenderer.h>
150 #include <vtkPlane.h>
151 #include <vtkCallbackCommand.h>
152 #include <vtkLookupTable.h>
154 // SALOME KERNEL includes
155 #include <SALOMEDS_Study.hxx>
156 #include <SALOMEDSClient_StudyBuilder.hxx>
157 #include <SALOMEDSClient_SComponent.hxx>
158 #include <SALOMEDSClient_ClientFactory.hxx>
159 #include <SALOMEDSClient_IParameters.hxx>
162 #include <Standard_ErrorHandler.hxx>
163 #include <NCollection_DataMap.hxx>
165 //To disable automatic genericobj management, the following line should be commented.
166 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
167 #define WITHGENERICOBJ
171 //=============================================================
172 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
175 void ExportMeshToFile(int theCommandID);
177 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
179 void SetDisplayEntity(int theCommandID);
181 void Control( int theCommandID );
185 //=============================================================
186 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
190 std::string myExtension;
192 if ( theCommandID == 113 ) {
193 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
194 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
196 else if ( theCommandID == 112 ) {
197 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
199 else if ( theCommandID == 111 ) {
200 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
202 else if ( theCommandID == 115 ) {
203 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
205 else if ( theCommandID == 116 ) {
206 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
209 QString anInitialPath = "";
210 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
211 anInitialPath = QDir::currentPath();
213 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
216 QObject::tr( "SMESH_IMPORT_MESH" ) );
217 if ( filenames.count() > 0 ) {
218 SUIT_OverrideCursor wc;
219 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
222 QStringList anEntryList;
223 bool isEmpty = false;
224 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
225 QString filename = *it;
226 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
228 switch ( theCommandID ) {
231 // DAT format (currently unsupported)
232 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
233 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
239 aMeshes->length( 1 );
240 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
241 if ( aMeshes[0]->_is_nil() )
242 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
243 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
249 SMESH::DriverMED_ReadStatus res;
250 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
251 if ( res != SMESH::DRS_OK ) {
252 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
253 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
260 aMeshes->length( 1 );
261 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
262 if ( aMeshes[0]->_is_nil() ) {
263 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
264 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
271 SMESH::DriverMED_ReadStatus res;
272 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
273 if ( res != SMESH::DRS_OK ) {
274 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
275 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
281 catch ( const SALOME::SALOME_Exception& S_ex ) {
282 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
283 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
286 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
287 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
289 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
290 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
291 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
292 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
293 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
295 anEntryList.append( aMeshSO->GetID().c_str() );
297 #ifdef WITHGENERICOBJ
298 // obj has been published in study. Its refcount has been incremented.
299 // It is safe to decrement its refcount
300 // so that it will be destroyed when the entry in study will be removed
301 aMeshes[i]->UnRegister();
310 // update Object browser
311 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
313 // browse to the published meshes
314 if( LightApp_Application* anApp =
315 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
316 anApp->browseObjects( anEntryList );
318 // show Error message box if there were errors
319 if ( errors.count() > 0 ) {
320 SUIT_MessageBox::critical( SMESHGUI::desktop(),
321 QObject::tr( "SMESH_ERROR" ),
322 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
325 // show warning message box, if some imported mesh is empty
327 SUIT_MessageBox::warning( SMESHGUI::desktop(),
328 QObject::tr( "SMESH_WRN_WARNING" ),
329 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
334 //================================================================================
336 * \brief Export selected meshes or groups into a file
338 //================================================================================
340 void ExportMeshToFile( int theCommandID )
342 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
343 SALOME_ListIO selected;
345 aSel->selectedObjects( selected );
347 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
348 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
349 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
350 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
351 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
353 // actually, the following condition can't be met (added for insurance)
354 if( selected.Extent() == 0 ||
355 ( selected.Extent() > 1 && !isMED && !isSTL ))
358 // get mesh object from selection and check duplication of their names
359 bool hasDuplicatedMeshNames = false;
360 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
361 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
362 SALOME_ListIteratorOfListIO It( selected );
363 for( ; It.More(); It.Next() )
365 Handle(SALOME_InteractiveObject) anIObject = It.Value();
366 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
367 if ( aMeshItem->_is_nil() ) {
368 SUIT_MessageBox::warning( SMESHGUI::desktop(),
369 QObject::tr( "SMESH_WRN_WARNING" ),
370 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
374 QString aMeshName = anIObject->getName();
376 // check for name duplications
377 if ( !hasDuplicatedMeshNames )
378 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
379 if( aMeshName == (*aMeshIter).second ) {
380 hasDuplicatedMeshNames = true;
385 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
388 if( hasDuplicatedMeshNames && isMED ) {
389 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
390 QObject::tr("SMESH_WRN_WARNING"),
391 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
392 QObject::tr("SMESH_BUT_YES"),
393 QObject::tr("SMESH_BUT_NO"), 0, 1);
398 aMeshIter = aMeshList.begin();
399 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
400 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
401 QString aMeshName = (*aMeshIter).second;
403 if ( isMED || isCGNS )
405 // check for equal group names within each mesh
406 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
407 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
408 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
409 int aRet = SUIT_MessageBox::warning
410 (SMESHGUI::desktop(),
411 QObject::tr("SMESH_WRN_WARNING"),
412 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
413 QObject::tr("SMESH_BUT_YES"),
414 QObject::tr("SMESH_BUT_NO"), 0, 1);
422 // warn the user about presence of not supported elements
423 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
424 int nbPyramids = nbElems[ SMESH::Entity_Pyramid ] + nbElems[ SMESH::Entity_Quad_Pyramid ];
425 if ( nbPyramids > 0 ) {
426 int aRet = SUIT_MessageBox::warning
427 (SMESHGUI::desktop(),
428 QObject::tr("SMESH_WRN_WARNING"),
429 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
430 QObject::tr("SMESH_BUT_YES"),
431 QObject::tr("SMESH_BUT_NO"), 0, 1);
437 // Get parameters of export operation
440 SMESH::MED_VERSION aFormat;
441 // Init the parameters with the default values
442 bool aIsASCII_STL = true;
443 bool toCreateGroups = false;
444 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
446 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
447 bool toOverwrite = true;
449 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
450 QString anInitialPath = "";
451 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
452 anInitialPath = QDir::currentPath();
454 if ( isUNV || isDAT )
457 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
459 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
460 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
461 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
462 anInitialPath + QString("/") + aMeshName,
463 aFilter, aTitle, false);
465 else if ( isCGNS )// Export to CGNS
467 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
468 fd->setWindowTitle( aTitle );
469 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
470 if ( !anInitialPath.isEmpty() )
471 fd->setDirectory( anInitialPath );
472 fd->selectFile(aMeshName);
473 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
474 fd->setValidator( fv );
477 aFilename = fd->selectedFile();
478 toOverwrite = fv->isOverwrite();
482 else if ( isSTL ) // Export to STL
484 QMap<QString, int> aFilterMap;
485 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
486 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
489 QMap<QString, int>::const_iterator it = aFilterMap.begin();
490 for ( ; it != aFilterMap.end(); ++it )
491 filters.push_back( it.key() );
493 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
494 fd->setWindowTitle( aTitle );
495 fd->setNameFilters( filters );
496 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
497 if ( !anInitialPath.isEmpty() )
498 fd->setDirectory( anInitialPath );
499 fd->selectFile(aMeshName);
503 aFilename = fd->selectedFile();
504 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
509 else if ( isMED ) // Export to MED
511 QMap<QString, SMESH::MED_VERSION> aFilterMap;
512 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
513 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
514 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
515 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
518 QString aDefaultFilter;
519 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
520 for ( ; it != aFilterMap.end(); ++it ) {
521 filters.push_back( it.key() );
522 if (it.value() == SMESH::MED_V2_2)
523 aDefaultFilter = it.key();
526 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
527 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
528 fd->setWindowTitle( aTitle );
529 fd->setNameFilters( filters );
530 fd->selectNameFilter(aDefaultFilter);
531 fd->SetChecked(toCreateGroups);
532 if ( !anInitialPath.isEmpty() )
533 fd->setDirectory( anInitialPath );
534 fd->selectFile(aMeshName);
536 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
537 fd->setValidator( fv );
542 aFilename = fd->selectedFile();
544 aFilename = QString::null;
547 aFormat = aFilterMap[fd->selectedNameFilter()];
548 toOverwrite = fv->isOverwrite();
550 if ( !aFilename.isEmpty() ) {
551 // med-2.1 does not support poly elements
552 if ( aFormat==SMESH::MED_V2_1 )
553 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
554 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
555 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
556 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
557 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
559 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
560 QObject::tr("SMESH_WRN_WARNING"),
561 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
562 QObject::tr("SMESH_BUT_YES"),
563 QObject::tr("SMESH_BUT_NO"), 0, 1);
571 // can't append to an existing using other format
572 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
573 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
574 if( !isVersionOk || aVersion != aFormat ) {
575 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
576 QObject::tr("SMESH_WRN_WARNING"),
577 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
578 QObject::tr("SMESH_BUT_YES"),
579 QObject::tr("SMESH_BUT_NO"), 0, 1);
586 QStringList aMeshNamesCollisionList;
587 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
588 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
589 QString anExistingMeshName( aMeshNames[ i ] );
590 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
591 QString anExportMeshName = (*aMeshIter).second;
592 if( anExportMeshName == anExistingMeshName ) {
593 aMeshNamesCollisionList.append( anExportMeshName );
598 if( !aMeshNamesCollisionList.isEmpty() ) {
599 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
600 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
601 QObject::tr("SMESH_WRN_WARNING"),
602 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
603 QObject::tr("SMESH_BUT_YES"),
604 QObject::tr("SMESH_BUT_NO"),
605 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
614 toCreateGroups = fd->IsChecked();
624 if ( !aFilename.isEmpty() ) {
625 // Check whether the file already exists and delete it if yes
626 QFile aFile( aFilename );
627 if ( aFile.exists() && toOverwrite )
629 SUIT_OverrideCursor wc;
632 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
633 // bool Renumber = false;
634 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
636 // Renumber= resMgr->booleanValue("SMESH","renumbering");
638 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
639 // aMeshEditor->RenumberNodes();
640 // aMeshEditor->RenumberElements();
641 // if ( SMESHGUI::automaticUpdate() )
642 // SMESH::UpdateView();
646 aMeshIter = aMeshList.begin();
647 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
649 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
650 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
651 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
652 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
653 aFormat, toOverwrite && aMeshIndex == 0 );
655 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
656 aFormat, toOverwrite && aMeshIndex == 0 );
661 if ( aMeshOrGroup->_is_equivalent( aMesh ))
662 aMesh->ExportDAT( aFilename.toLatin1().data() );
664 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
668 if ( aMeshOrGroup->_is_equivalent( aMesh ))
669 aMesh->ExportUNV( aFilename.toLatin1().data() );
671 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
675 if ( aMeshOrGroup->_is_equivalent( aMesh ))
676 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
678 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
682 aMeshIter = aMeshList.begin();
683 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
685 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
686 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
687 aMeshItem->ExportCGNS( aMeshOrGroup,
688 aFilename.toLatin1().data(),
689 toOverwrite && aMeshIndex == 0 );
693 catch (const SALOME::SALOME_Exception& S_ex){
695 SUIT_MessageBox::warning(SMESHGUI::desktop(),
696 QObject::tr("SMESH_WRN_WARNING"),
697 QObject::tr("SMESH_EXPORT_FAILED"));
703 inline void InverseEntityMode(unsigned int& theOutputMode,
704 unsigned int theMode)
706 bool anIsNotPresent = ~theOutputMode & theMode;
708 theOutputMode |= theMode;
710 theOutputMode &= ~theMode;
713 void SetDisplayEntity(int theCommandID){
714 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
715 SALOME_ListIO selected;
717 aSel->selectedObjects( selected );
719 if(selected.Extent() >= 1){
720 SALOME_ListIteratorOfListIO It( selected );
721 for( ; It.More(); It.Next()){
722 Handle(SALOME_InteractiveObject) IObject = It.Value();
723 if(IObject->hasEntry()){
724 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
725 unsigned int aMode = anActor->GetEntityMode();
726 switch(theCommandID){
728 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
731 InverseEntityMode(aMode,SMESH_Actor::eEdges);
734 InverseEntityMode(aMode,SMESH_Actor::eFaces);
737 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
740 aMode = SMESH_Actor::eAllEntity;
744 anActor->SetEntityMode(aMode);
752 SALOME_ListIO selected;
753 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
757 LightApp_SelectionMgr* aSel = app->selectionMgr();
758 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
759 if( !aSel || !appStudy )
762 aSel->selectedObjects( selected );
763 if( selected.IsEmpty() )
766 Handle(SALOME_InteractiveObject) anIObject = selected.First();
768 _PTR(Study) aStudy = appStudy->studyDS();
769 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
770 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
771 if( aMainObject->_is_nil() )
774 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
776 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
777 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
779 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
780 SALOMEDS::Color aColor = aGroupObject->GetColor();
781 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
783 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
784 if( aGroupObject->GetType() == SMESH::NODE )
785 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
786 else if( aGroupObject->GetType() == SMESH::EDGE )
787 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
788 else if( aGroupObject->GetType() == SMESH::ELEM0D )
789 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
793 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
794 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
800 SMESH::RepaintCurrentView();
803 QString functorToString( SMESH::Controls::FunctorPtr f )
805 QString type = QObject::tr( "UNKNOWN_CONTROL" );
806 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
807 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
808 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
809 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
810 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
811 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
812 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
813 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
814 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
815 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
816 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
817 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
818 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
819 type = QObject::tr( "WARP_ELEMENTS" );
820 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
821 type = QObject::tr( "TAPER_ELEMENTS" );
822 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
823 type = QObject::tr( "SKEW_ELEMENTS" );
824 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
825 type = QObject::tr( "AREA_ELEMENTS" );
826 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
827 type = QObject::tr( "LENGTH_EDGES" );
828 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
829 type = QObject::tr( "LENGTH2D_EDGES" );
830 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
831 type = QObject::tr( "MULTI_BORDERS" );
832 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
833 type = QObject::tr( "MULTI2D_BORDERS" );
834 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
835 type = QObject::tr( "FREE_NODES" );
836 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
837 type = QObject::tr( "FREE_EDGES" );
838 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
839 type = QObject::tr( "FREE_BORDERS" );
840 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
841 type = QObject::tr( "FREE_FACES" );
842 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
843 type = QObject::tr( "BARE_BORDER_VOLUME" );
844 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
845 type = QObject::tr( "BARE_BORDER_FACE" );
846 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
847 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
848 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
849 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
853 void SaveDistribution()
855 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
856 SALOME_ListIO selected;
858 aSel->selectedObjects( selected );
860 if ( selected.Extent() == 1 ) {
861 Handle(SALOME_InteractiveObject) anIO = selected.First();
862 if ( anIO->hasEntry() ) {
863 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
864 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
865 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
866 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
867 if ( aScalarBarActor && aFunctor ) {
868 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
870 std::vector<int> elements;
871 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
872 if ( mesh->_is_nil() ) {
873 SMESH::SMESH_IDSource_var idSource =
874 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
875 if ( !idSource->_is_nil() )
877 SMESH::long_array_var ids = idSource->GetIDs();
878 elements.resize( ids->length() );
879 for ( unsigned i = 0; i < elements.size(); ++i )
880 elements[i] = ids[i];
883 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
884 vtkLookupTable* lookupTable =
885 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
886 double * minmax = lookupTable->GetRange();
887 std::vector<int> nbEvents;
888 std::vector<double> funValues;
889 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
890 QString anInitialPath = "";
891 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
892 anInitialPath = QDir::currentPath();
893 QString aMeshName = anIO->getName();
895 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
896 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
897 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
898 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
899 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
902 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
904 if ( !aFilename.isEmpty() ) {
905 QFile f( aFilename );
906 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
907 QTextStream out( &f );
908 out << "# Mesh: " << aMeshName << endl;
909 out << "# Control: " << functorToString( aFunctor ) << endl;
911 out.setFieldWidth( 10 );
912 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
913 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
924 void ShowDistribution() {
925 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
926 SALOME_ListIO selected;
928 aSel->selectedObjects( selected );
930 if ( selected.Extent() == 1 ) {
931 Handle(SALOME_InteractiveObject) anIO = selected.First();
932 if ( anIO->hasEntry() ) {
933 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
934 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
935 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
936 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
942 #ifndef DISABLE_PLOT2DVIEWER
943 void PlotDistribution() {
944 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
948 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
949 SALOME_ListIO selected;
951 aSel->selectedObjects( selected );
953 if ( selected.Extent() == 1 ) {
954 Handle(SALOME_InteractiveObject) anIO = selected.First();
955 if ( anIO->hasEntry() ) {
956 //Find Actor by entry before getting Plot2d viewer,
957 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
958 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
960 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
965 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
969 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
973 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
974 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
975 QString functorName = functorToString( anActor->GetFunctor());
976 QString aHistogramName("%1 : %2");
977 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
978 aHistogram->setName(aHistogramName);
979 aHistogram->setHorTitle(functorName);
980 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
981 aPlot->displayObject(aHistogram, true);
986 #endif //DISABLE_PLOT2DVIEWER
988 void DisableAutoColor(){
989 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
990 SALOME_ListIO selected;
992 aSel->selectedObjects( selected );
994 if(selected.Extent()){
995 Handle(SALOME_InteractiveObject) anIObject = selected.First();
996 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
997 if ( !aMesh->_is_nil() ) {
998 aMesh->SetAutoColor( false );
1003 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1004 SALOME_ListIO selected;
1005 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1009 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1010 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1011 if( !aSel || !appStudy )
1014 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1015 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1016 aModule->EmitSignalDeactivateDialog();
1017 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1018 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1023 _PTR(Study) aStudy = appStudy->studyDS();
1025 aSel->selectedObjects( selected );
1027 if(selected.Extent() >= 1){
1028 switch(theCommandID){
1030 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1031 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1035 QColor c, e, b, n, c0D, o;
1039 vtkFloatingPointType Shrink = 0.0;
1040 vtkFloatingPointType faces_orientation_scale = 0.0;
1041 bool faces_orientation_3dvectors = false;
1043 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1044 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1045 int aMarkerTextureCurrent = 0;
1047 SALOME_ListIteratorOfListIO It( selected );
1048 for( ; It.More(); It.Next()){
1049 Handle(SALOME_InteractiveObject) IObject = It.Value();
1050 if(IObject->hasEntry()){
1051 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1052 vtkFloatingPointType color[3];
1053 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1054 int c0 = int (color[0] * 255);
1055 int c1 = int (color[1] * 255);
1056 int c2 = int (color[2] * 255);
1057 c.setRgb(c0, c1, c2);
1059 vtkFloatingPointType edgecolor[3];
1060 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1061 c0 = int (edgecolor[0] * 255);
1062 c1 = int (edgecolor[1] * 255);
1063 c2 = int (edgecolor[2] * 255);
1064 e.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->SetDeltaBrightness(delta);
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);
1137 int delta = aDlg->GetDeltaBrightness();
1140 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1142 SALOME_ListIteratorOfListIO It( selected );
1143 for( ; It.More(); It.Next()){
1144 Handle(SALOME_InteractiveObject) IObject = It.Value();
1145 if(IObject->hasEntry()){
1146 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1147 /* actor color and backface color */
1148 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1149 vtkFloatingPointType (color.green()) / 255.,
1150 vtkFloatingPointType (color.blue()) / 255.,
1153 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1154 vtkFloatingPointType (edgecolor.green()) / 255.,
1155 vtkFloatingPointType (edgecolor.blue()) / 255.);
1157 /* Shrink factor and size edges */
1158 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1159 anActor->SetLineWidth(aDlg->GetIntValue(1));
1161 /* Nodes color and size */
1162 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1163 vtkFloatingPointType (nodecolor.green()) / 255.,
1164 vtkFloatingPointType (nodecolor.blue()) / 255.);
1167 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1168 vtkFloatingPointType (color0D.green()) / 255.,
1169 vtkFloatingPointType (color0D.blue()) / 255.);
1170 anActor->Set0DSize(aDlg->GetIntValue(3));
1172 /* Faces orientation */
1173 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1174 vtkFloatingPointType(faces_orientation_color.greenF()),
1175 vtkFloatingPointType(faces_orientation_color.blueF())};
1176 anActor->SetFacesOrientationColor(c);
1177 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1178 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1180 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1181 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1182 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1183 if( aMarkerTypeNew != VTK::MT_USER )
1184 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1186 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1187 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1188 if( anIter != aMarkerMap.end() )
1189 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1192 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1193 if( !aGroupObject->_is_nil() )
1195 SMESH::ElementType anElementType = aGroupObject->GetType();
1197 switch( anElementType )
1199 case SMESH::NODE: aColor = nodecolor; break;
1200 case SMESH::EDGE: aColor = edgecolor; break;
1201 default: aColor = color; break;
1204 SALOMEDS::Color aGroupColor;
1205 aGroupColor.R = (float)aColor.red() / 255.0;
1206 aGroupColor.G = (float)aColor.green() / 255.0;
1207 aGroupColor.B = (float)aColor.blue() / 255.0;
1208 aGroupObject->SetColor( aGroupColor );
1213 SMESH::RepaintCurrentView();
1219 SALOME_ListIteratorOfListIO It( selected );
1220 for( ; It.More(); It.Next()){
1221 Handle(SALOME_InteractiveObject) IObject = It.Value();
1222 if(IObject->hasEntry()){
1223 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1224 switch(theCommandID){
1226 anActor->SetRepresentation(SMESH_Actor::eEdge);
1229 anActor->SetRepresentation(SMESH_Actor::eSurface);
1232 if(anActor->IsShrunk())
1233 anActor->UnShrink();
1235 anActor->SetShrink();
1238 anActor->SetRepresentation(SMESH_Actor::ePoint);
1241 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1242 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1245 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1246 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1252 SMESH::RepaintCurrentView();
1256 void Control( int theCommandID )
1258 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1259 SALOME_ListIO selected;
1261 aSel->selectedObjects( selected );
1263 if( !selected.IsEmpty() ){
1264 Handle(SALOME_InteractiveObject) anIO = selected.First();
1266 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1267 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1268 switch ( theCommandID ){
1270 aControl = SMESH_Actor::eLength;
1273 aControl = SMESH_Actor::eLength2D;
1276 aControl = SMESH_Actor::eFreeEdges;
1279 aControl = SMESH_Actor::eFreeBorders;
1282 aControl = SMESH_Actor::eMultiConnection;
1285 aControl = SMESH_Actor::eFreeNodes;
1288 aControl = SMESH_Actor::eMultiConnection2D;
1291 aControl = SMESH_Actor::eArea;
1294 aControl = SMESH_Actor::eTaper;
1297 aControl = SMESH_Actor::eAspectRatio;
1300 aControl = SMESH_Actor::eAspectRatio3D;
1303 aControl = SMESH_Actor::eMinimumAngle;
1306 aControl = SMESH_Actor::eWarping;
1309 aControl = SMESH_Actor::eSkew;
1312 aControl = SMESH_Actor::eVolume3D;
1315 aControl = SMESH_Actor::eFreeFaces;
1318 aControl = SMESH_Actor::eMaxElementLength2D;
1321 aControl = SMESH_Actor::eMaxElementLength3D;
1324 aControl = SMESH_Actor::eBareBorderVolume;
1327 aControl = SMESH_Actor::eBareBorderFace;
1330 aControl = SMESH_Actor::eOverConstrainedVolume;
1333 aControl = SMESH_Actor::eOverConstrainedFace;
1336 anActor->SetControlMode(aControl);
1337 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1338 SMESH::RepaintCurrentView();
1339 #ifndef DISABLE_PLOT2DVIEWER
1340 if(anActor->GetPlot2Histogram()) {
1341 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1342 QString functorName = functorToString( anActor->GetFunctor());
1343 QString aHistogramName("%1 : %2");
1344 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1345 aHistogram->setName(aHistogramName);
1346 aHistogram->setHorTitle(functorName);
1347 SMESH::ProcessIn2DViewers(anActor);
1356 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1357 MeshObjectType theType,
1358 const QString theInTypeName,
1359 QString & theOutTypeName)
1361 SMESH_TypeFilter aTypeFilter( theType );
1363 if( !theIO.IsNull() )
1365 entry = theIO->getEntry();
1366 LightApp_DataOwner owner( entry );
1367 if ( aTypeFilter.isOk( &owner )) {
1368 theOutTypeName = theInTypeName;
1376 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1378 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1379 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1381 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1382 CORBA::String_var anID = aSComp->GetID().c_str();
1383 if (!strcmp(anID.in(),theIO->getEntry()))
1389 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1390 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1391 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1392 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1393 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1401 QString CheckHomogeneousSelection()
1403 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1404 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1405 SALOME_ListIO selected;
1407 aSel->selectedObjects( selected );
1409 QString RefType = CheckTypeObject(selected.First());
1410 SALOME_ListIteratorOfListIO It(selected);
1411 for ( ; It.More(); It.Next())
1413 Handle(SALOME_InteractiveObject) IObject = It.Value();
1414 QString Type = CheckTypeObject(IObject);
1415 if (Type.compare(RefType) != 0)
1416 return "Heterogeneous Selection";
1423 void SMESHGUI::OnEditDelete()
1425 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1426 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1427 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1429 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1430 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1431 _PTR(GenericAttribute) anAttr;
1432 _PTR(AttributeIOR) anIOR;
1434 int objectCount = 0;
1436 QString aParentComponent = QString::null;
1437 Handle(SALOME_InteractiveObject) anIO;
1438 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1440 anIO = anIt.Value();
1441 QString cur = anIO->getComponentDataType();
1442 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1444 // check if object is reference
1445 _PTR(SObject) aRefSObj;
1446 aNameList.append("\n - ");
1447 if ( aSO->ReferencedObject( aRefSObj ) ) {
1448 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1449 aNameList.append( aRefName );
1450 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1453 aNameList.append(anIO->getName());
1457 if( aParentComponent.isNull() )
1458 aParentComponent = cur;
1459 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1460 aParentComponent = "";
1463 if ( objectCount == 0 )
1464 return; // No Valid Objects Selected
1466 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1467 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1468 QObject::tr("ERR_ERROR"),
1469 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1472 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1473 if (SUIT_MessageBox::warning
1474 (SMESHGUI::desktop(),
1475 QObject::tr("SMESH_WRN_WARNING"),
1476 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1477 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1478 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1481 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1483 SALOME_ListIteratorOfListIO It(selected);
1485 aStudyBuilder->NewCommand(); // There is a transaction
1486 for( ; It.More(); It.Next()){ // loop on selected IO's
1487 Handle(SALOME_InteractiveObject) IObject = It.Value();
1488 if(IObject->hasEntry()) {
1489 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1491 // disable removal of "SMESH" component object
1492 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1494 if ( engineIOR() == anIOR->Value().c_str() )
1497 //Check the referenced object
1498 _PTR(SObject) aRefSObject;
1499 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1500 aSO = aRefSObject; // Delete main Object instead of reference
1502 // put the whole hierarchy of sub-objects of the selected SO into a list and
1503 // then treat them all starting from the deepest objects (at list back)
1505 std::list< _PTR(SObject) > listSO;
1506 listSO.push_back( aSO );
1507 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1508 for ( ; itSO != listSO.end(); ++itSO ) {
1509 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1510 for (it->InitEx(false); it->More(); it->Next())
1511 listSO.push_back( it->Value() );
1514 // treat SO's in the list starting from the back
1516 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1517 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1518 _PTR(SObject) SO = *ritSO;
1519 if ( !SO ) continue;
1520 std::string anEntry = SO->GetID();
1522 /** Erase graphical object **/
1523 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1524 ViewManagerList aViewMenegers = anApp->viewManagers();
1525 ViewManagerList::const_iterator it = aViewMenegers.begin();
1526 for( ; it != aViewMenegers.end(); it++) {
1527 SUIT_ViewManager* vm = *it;
1528 int nbSf = vm ? vm->getViewsCount() : 0;
1530 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1531 for(int i = 0; i < nbSf; i++){
1532 SUIT_ViewWindow *sf = aViews[i];
1533 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1534 SMESH::RemoveActor(sf,anActor);
1540 /** Remove an object from data structures **/
1541 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1542 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1543 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1544 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1545 aMesh->RemoveGroup( aGroup );
1547 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1548 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1549 aMesh->RemoveSubMesh( aSubMesh );
1551 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1553 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1556 IObject = new SALOME_InteractiveObject
1557 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1558 QString objType = CheckTypeObject(IObject);
1559 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1560 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1561 aStudyBuilder->RemoveObjectWithChildren( SO );
1563 else {// default action: remove SObject from the study
1564 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1565 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1567 aStudyBuilder->RemoveObjectWithChildren( SO );
1571 } /* listSO back loop */
1572 } /* IObject->hasEntry() */
1575 aStudyBuilder->CommitCommand();
1577 /* Clear any previous selection */
1579 aSel->setSelectedObjects( l1 );
1581 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1586 SMESHGUI_EXPORT CAM_Module* createModule()
1588 return new SMESHGUI();
1591 SMESHGUI_EXPORT char* getModuleVersion() {
1592 return (char*)SMESH_VERSION_STR;
1596 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1598 //=============================================================================
1602 //=============================================================================
1603 SMESHGUI::SMESHGUI() :
1604 SalomeApp_Module( "SMESH" ),
1605 LightApp_Module( "SMESH" )
1607 if ( CORBA::is_nil( myComponentSMESH ) )
1609 CORBA::Boolean anIsEmbeddedMode;
1610 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1611 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1613 // 0019923: EDF 765 SMESH : default values of hypothesis
1614 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1615 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1616 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1617 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1618 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1621 myActiveDialogBox = 0;
1622 myFilterLibraryDlg = 0;
1626 myEventCallbackCommand = vtkCallbackCommand::New();
1627 myEventCallbackCommand->Delete();
1628 myEventCallbackCommand->SetClientData( this );
1629 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1632 SMESH::GetFilterManager();
1633 SMESH::GetPattern();
1634 SMESH::GetMeasurements();
1636 /* load resources for all available meshers */
1637 SMESH::InitAvailableHypotheses();
1640 //=============================================================================
1644 //=============================================================================
1645 SMESHGUI::~SMESHGUI()
1647 #ifdef WITHGENERICOBJ
1648 SMESH::GetFilterManager()->UnRegister();
1649 SMESH::GetMeasurements()->UnRegister();
1651 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1652 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1655 //=============================================================================
1659 //=============================================================================
1660 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1662 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1664 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1669 //=============================================================================
1673 //=============================================================================
1674 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1676 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1680 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1681 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1682 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1683 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1684 return autoUpdate && !exceeded;
1687 //=============================================================================
1691 //=============================================================================
1692 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1694 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1697 //=============================================================================
1701 //=============================================================================
1702 SMESHGUI* SMESHGUI::GetSMESHGUI()
1704 SMESHGUI* smeshMod = 0;
1705 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1708 CAM_Module* module = app->module( "Mesh" );
1709 smeshMod = dynamic_cast<SMESHGUI*>( module );
1712 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1714 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1717 _PTR(Study) aStudy = study->studyDS();
1719 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1728 Standard_EXPORT SMESHGUI* GetComponentGUI()
1730 return SMESHGUI::GetSMESHGUI();
1734 //=============================================================================
1738 //=============================================================================
1739 void SMESHGUI::SetState(int aState)
1744 //=============================================================================
1748 //=============================================================================
1749 void SMESHGUI::ResetState()
1754 //=============================================================================
1758 //=============================================================================
1759 void SMESHGUI::EmitSignalDeactivateDialog()
1761 emit SignalDeactivateActiveDialog();
1764 //=============================================================================
1768 //=============================================================================
1769 void SMESHGUI::EmitSignalStudyFrameChanged()
1771 emit SignalStudyFrameChanged();
1774 //=============================================================================
1778 //=============================================================================
1779 void SMESHGUI::EmitSignalCloseAllDialogs()
1781 emit SignalCloseAllDialogs();
1784 //=============================================================================
1788 //=============================================================================
1789 void SMESHGUI::EmitSignalVisibilityChanged()
1791 emit SignalVisibilityChanged();
1794 //=============================================================================
1798 //=============================================================================
1799 QDialog *SMESHGUI::GetActiveDialogBox()
1801 return myActiveDialogBox;
1804 //=============================================================================
1808 //=============================================================================
1809 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1811 myActiveDialogBox = (QDialog *) aDlg;
1815 //=============================================================================
1819 //=============================================================================
1820 SUIT_Desktop* SMESHGUI::desktop()
1822 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1824 return app->desktop();
1829 //=============================================================================
1833 //=============================================================================
1834 SalomeApp_Study* SMESHGUI::activeStudy()
1836 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1838 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1843 //=============================================================================
1847 //=============================================================================
1848 void SMESHGUI::Modified( bool theIsUpdateActions )
1850 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1851 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1852 appStudy->Modified();
1853 if( theIsUpdateActions )
1854 app->updateActions();
1859 //=============================================================================
1863 //=============================================================================
1864 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1866 /* Here the position is on the bottom right corner - 10 */
1867 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1869 SUIT_Desktop *PP = desktop();
1870 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1871 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1875 //=============================================================================
1879 //=============================================================================
1880 static int isStudyLocked(_PTR(Study) theStudy){
1881 return theStudy->GetProperties()->IsLocked();
1884 static bool checkLock(_PTR(Study) theStudy) {
1885 if (isStudyLocked(theStudy)) {
1886 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1887 QObject::tr("WRN_WARNING"),
1888 QObject::tr("WRN_STUDY_LOCKED") );
1894 //=======================================================================
1895 //function : CheckActiveStudyLocked
1897 //=======================================================================
1899 bool SMESHGUI::isActiveStudyLocked()
1901 _PTR(Study) aStudy = activeStudy()->studyDS();
1902 return checkLock( aStudy );
1905 //=============================================================================
1909 //=============================================================================
1910 bool SMESHGUI::OnGUIEvent( int theCommandID )
1912 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1916 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1917 SUIT_ResourceMgr* mgr = resourceMgr();
1921 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1922 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1925 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1926 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1928 //QAction* act = action( theCommandID );
1930 switch (theCommandID) {
1932 if(checkLock(aStudy)) break;
1942 if(checkLock(aStudy)) break;
1943 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1947 case 150: //MED FILE INFORMATION
1949 SALOME_ListIO selected;
1950 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1952 aSel->selectedObjects( selected );
1953 if( selected.Extent() )
1955 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1956 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1957 if ( !aMesh->_is_nil() )
1959 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1966 case 122: // EXPORT MED
1977 ::ExportMeshToFile(theCommandID);
1981 case 200: // SCALAR BAR
1983 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1984 SALOME_ListIO selected;
1986 aSel->selectedObjects( selected );
1988 if( selected.Extent() ) {
1989 Handle(SALOME_InteractiveObject) anIO = selected.First();
1990 if( anIO->hasEntry() ) {
1991 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1992 anActor->SetControlMode( SMESH_Actor::eNone );
1993 #ifndef DISABLE_PLOT2DVIEWER
1994 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2003 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2008 // dump control distribution data to the text file
2009 ::SaveDistribution();
2015 // show/ distribution
2016 ::ShowDistribution();
2020 #ifndef DISABLE_PLOT2DVIEWER
2023 // plot distribution
2024 ::PlotDistribution();
2035 ::DisableAutoColor();
2038 case 1134: // Clipping
2039 case 1133: // Tranparency
2040 case 1132: // Colors / Size
2047 ::SetDisplayMode(theCommandID, myMarkerMap);
2050 //2D quadratic representation
2053 ::SetDisplayMode(theCommandID, myMarkerMap);
2057 case 216: // 0D elements
2060 case 219: // Volumes
2061 case 220: // All Entity
2062 ::SetDisplayEntity(theCommandID);
2065 case 221: // Orientation of faces
2067 LightApp_SelectionMgr* mgr = selectionMgr();
2068 SALOME_ListIO selected; mgr->selectedObjects( selected );
2070 SALOME_ListIteratorOfListIO it(selected);
2071 for( ; it.More(); it.Next()) {
2072 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2073 if(anIObject->hasEntry()) {
2074 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2075 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2084 if(checkLock(aStudy)) break;
2086 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2089 SMESH::UpdateView();
2091 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2092 SMESH::OnVisuException();
2094 catch (...) { // PAL16774 (Crash after display of many groups)
2095 SMESH::OnVisuException();
2099 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2100 aSel->selectedObjects( l );
2101 aSel->setSelectedObjects( l );
2106 case 301: // DISPLAY
2107 case 302: // DISPLAY ONLY
2109 SMESH::EDisplaing anAction;
2110 switch (theCommandID) {
2111 case 300: anAction = SMESH::eErase; break;
2112 case 301: anAction = SMESH::eDisplay; break;
2113 case 302: anAction = SMESH::eDisplayOnly; break;
2116 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2117 SALOME_ListIO sel_objects, to_process;
2119 aSel->selectedObjects( sel_objects );
2121 if( theCommandID==302 )
2123 MESSAGE("anAction = SMESH::eDisplayOnly");
2124 startOperation( myEraseAll );
2127 extractContainers( sel_objects, to_process );
2130 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2134 SALOME_ListIteratorOfListIO It( to_process );
2135 for ( ; It.More(); It.Next()) {
2137 Handle(SALOME_InteractiveObject) IOS = It.Value();
2138 if (IOS->hasEntry()) {
2140 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2141 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2142 break; // PAL16774 (Crash after display of many groups)
2144 if (anAction == SMESH::eDisplayOnly)
2146 MESSAGE("anAction = SMESH::eDisplayOnly");
2147 anAction = SMESH::eDisplay;
2153 // PAL13338 + PAL15161 -->
2154 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2155 MESSAGE("anAction = SMESH::eDisplayOnly");
2156 SMESH::UpdateView();
2157 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2159 // PAL13338 + PAL15161 <--
2161 catch (...) { // PAL16774 (Crash after display of many groups)
2162 SMESH::OnVisuException();
2165 if (anAction == SMESH::eErase) {
2166 MESSAGE("anAction == SMESH::eErase");
2168 aSel->setSelectedObjects( l1 );
2171 aSel->setSelectedObjects( to_process );
2178 if(checkLock(aStudy)) break;
2181 EmitSignalDeactivateDialog();
2183 ( new SMESHGUI_NodesDlg( this ) )->show();
2186 SUIT_MessageBox::warning(desktop(),
2187 tr("SMESH_WRN_WARNING"),
2188 tr("SMESH_WRN_VIEWER_VTK"));
2193 case 2151: // FILTER
2197 EmitSignalDeactivateDialog();
2198 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2203 case 701: // COMPUTE MESH
2204 case 711: // PRECOMPUTE MESH
2205 case 712: // EVALUATE MESH
2206 case 713: // MESH ORDER
2208 if (checkLock(aStudy)) break;
2209 startOperation( theCommandID );
2213 case 702: // Create mesh
2214 case 703: // Create sub-mesh
2215 case 704: // Edit mesh/sub-mesh
2216 startOperation( theCommandID );
2218 case 705: // copy mesh
2220 if (checkLock(aStudy)) break;
2221 EmitSignalDeactivateDialog();
2222 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2225 case 710: // Build compound mesh
2227 if (checkLock(aStudy)) break;
2228 EmitSignalDeactivateDialog();
2229 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2233 case 407: // DIAGONAL INVERSION
2234 case 408: // Delete diagonal
2238 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2239 tr( "NOT_A_VTK_VIEWER" ) );
2243 if ( checkLock( aStudy ) )
2246 /*Standard_Boolean aRes;
2247 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2248 if ( aMesh->_is_nil() )
2250 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2251 tr( "SMESH_BAD_SELECTION" ) );
2255 EmitSignalDeactivateDialog();
2256 if ( theCommandID == 407 )
2257 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2259 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2262 case 409: // Change orientation
2263 case 410: // Union of triangles
2264 case 411: // Cutting of quadrangles
2265 case 419: // Splitting volumes into tetrahedra
2269 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2270 tr( "NOT_A_VTK_VIEWER" ) );
2274 if ( checkLock( aStudy ) )
2277 EmitSignalDeactivateDialog();
2278 SMESHGUI_MultiEditDlg* aDlg = NULL;
2279 if ( theCommandID == 409 )
2280 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2281 else if ( theCommandID == 410 )
2282 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2283 else if ( theCommandID == 419 )
2284 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2286 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2291 case 412: // Smoothing
2293 if(checkLock(aStudy)) break;
2295 EmitSignalDeactivateDialog();
2296 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2299 SUIT_MessageBox::warning(desktop(),
2300 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2304 case 413: // Extrusion
2306 if (checkLock(aStudy)) break;
2308 EmitSignalDeactivateDialog();
2309 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2311 SUIT_MessageBox::warning(desktop(),
2312 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2316 case 414: // Revolution
2318 if(checkLock(aStudy)) break;
2320 EmitSignalDeactivateDialog();
2321 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2324 SUIT_MessageBox::warning(desktop(),
2325 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2329 case 415: // Pattern mapping
2331 if ( checkLock( aStudy ) )
2335 EmitSignalDeactivateDialog();
2336 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2339 SUIT_MessageBox::warning(desktop(),
2340 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2344 case 416: // Extrusion along a path
2346 if (checkLock(aStudy)) break;
2348 EmitSignalDeactivateDialog();
2349 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2351 SUIT_MessageBox::warning(desktop(),
2352 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2356 case 417: // Convert mesh to quadratic
2358 startOperation( 417 );
2359 /* if (checkLock(aStudy)) break;
2361 EmitSignalDeactivateDialog();
2362 new SMESHGUI_ConvToQuadDlg();
2364 SUIT_MessageBox::warning(desktop(),
2365 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2369 case 418: // create 2D mesh from 3D
2371 startOperation( 418 );
2374 case 806: // CREATE GEO GROUP
2376 startOperation( 806 );
2379 case 801: // CREATE GROUP
2383 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2384 tr( "NOT_A_VTK_VIEWER" ) );
2388 if(checkLock(aStudy)) break;
2389 EmitSignalDeactivateDialog();
2390 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2392 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2393 SALOME_ListIO selected;
2395 aSel->selectedObjects( selected );
2397 int nbSel = selected.Extent();
2399 // check if mesh is selected
2400 aMesh = SMESH::GetMeshByIO( selected.First() );
2402 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2407 case 802: // CONSTRUCT GROUP
2411 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2412 tr( "NOT_A_VTK_VIEWER" ) );
2416 if(checkLock(aStudy)) break;
2417 EmitSignalDeactivateDialog();
2419 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2420 SALOME_ListIO selected;
2422 aSel->selectedObjects( selected );
2424 int nbSel = selected.Extent();
2426 // check if submesh is selected
2427 Handle(SALOME_InteractiveObject) IObject = selected.First();
2428 if (IObject->hasEntry()) {
2429 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2431 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2432 if (!aSubMesh->_is_nil()) {
2434 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2435 // get submesh elements list by types
2436 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2437 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2438 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2439 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2440 // create group for each type o elements
2441 QString aName = IObject->getName();
2442 QStringList anEntryList;
2443 if (aNodes->length() > 0) {
2444 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2445 aGroup->Add(aNodes.inout());
2446 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2447 anEntryList.append( aSObject->GetID().c_str() );
2449 if (aEdges->length() > 0) {
2450 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2451 aGroup->Add(aEdges.inout());
2452 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2453 anEntryList.append( aSObject->GetID().c_str() );
2455 if (aFaces->length() > 0) {
2456 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2457 aGroup->Add(aFaces.inout());
2458 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2459 anEntryList.append( aSObject->GetID().c_str() );
2461 if (aVolumes->length() > 0) {
2462 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2463 aGroup->Add(aVolumes.inout());
2464 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2465 anEntryList.append( aSObject->GetID().c_str() );
2468 anApp->browseObjects( anEntryList );
2470 catch(const SALOME::SALOME_Exception & S_ex){
2471 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2478 SUIT_MessageBox::warning(desktop(),
2479 tr("SMESH_WRN_WARNING"),
2480 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2485 case 803: // EDIT GROUP
2489 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2490 tr( "NOT_A_VTK_VIEWER" ) );
2494 if(checkLock(aStudy)) break;
2495 EmitSignalDeactivateDialog();
2497 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2498 SALOME_ListIO selected;
2500 aSel->selectedObjects( selected );
2502 SALOME_ListIteratorOfListIO It (selected);
2503 int nbSelectedGroups = 0;
2504 for ( ; It.More(); It.Next() )
2506 SMESH::SMESH_GroupBase_var aGroup =
2507 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2508 if (!aGroup->_is_nil()) {
2510 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2514 if (nbSelectedGroups == 0)
2516 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2522 case 804: // Add elements to group
2524 if(checkLock(aStudy)) break;
2525 if (myState == 800) {
2526 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2527 if (aDlg) aDlg->onAdd();
2532 case 805: // Remove elements from group
2534 if(checkLock(aStudy)) break;
2535 if (myState == 800) {
2536 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2537 if (aDlg) aDlg->onRemove();
2542 case 815: // Edit GEOM GROUP as standalone
2546 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2547 tr( "NOT_A_VTK_VIEWER" ) );
2551 if(checkLock(aStudy)) break;
2552 EmitSignalDeactivateDialog();
2554 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2555 SALOME_ListIO selected;
2557 aSel->selectedObjects( selected );
2559 SALOME_ListIteratorOfListIO It (selected);
2560 for ( ; It.More(); It.Next() )
2562 SMESH::SMESH_GroupOnGeom_var aGroup =
2563 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2564 if (!aGroup->_is_nil()) {
2565 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2570 SMESH::SMESH_GroupOnFilter_var aGroup =
2571 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2572 if (!aGroup->_is_nil()) {
2573 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2581 case 810: // Union Groups
2582 case 811: // Intersect groups
2583 case 812: // Cut groups
2587 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2588 tr( "NOT_A_VTK_VIEWER" ) );
2592 if ( checkLock( aStudy ) )
2595 EmitSignalDeactivateDialog();
2597 SMESHGUI_GroupOpDlg* aDlg = 0;
2598 if ( theCommandID == 810 )
2599 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2600 else if ( theCommandID == 811 )
2601 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2603 aDlg = new SMESHGUI_CutGroupsDlg( this );
2610 case 814: // Create groups of entities from existing groups of superior dimensions
2612 if ( checkLock( aStudy ) )
2615 EmitSignalDeactivateDialog();
2616 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2622 case 813: // Delete groups with their contents
2626 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2627 tr( "NOT_A_VTK_VIEWER" ) );
2631 if ( checkLock( aStudy ) )
2634 EmitSignalDeactivateDialog();
2636 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2640 case 900: // MESH INFOS
2641 case 903: // WHAT IS
2643 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2644 EmitSignalDeactivateDialog();
2645 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2646 SALOME_ListIO selected;
2648 aSel->selectedObjects( selected );
2650 if ( selected.Extent() > 1 ) { // a dlg for each IO
2651 SALOME_ListIteratorOfListIO It( selected );
2652 for ( ; It.More(); It.Next() ) {
2653 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2654 dlg->showInfo( It.Value() );
2659 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2665 case 902: // STANDARD MESH INFOS
2667 EmitSignalDeactivateDialog();
2668 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2669 SALOME_ListIO selected;
2671 aSel->selectedObjects( selected );
2673 if ( selected.Extent() > 1 ) { // a dlg for each IO
2675 SALOME_ListIteratorOfListIO It (selected);
2676 for ( ; It.More(); It.Next() ) {
2678 IOs.Append( It.Value() );
2679 aSel->setSelectedObjects( IOs );
2680 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2682 // restore selection
2683 aSel->setSelectedObjects( selected );
2686 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2689 case 903: // WHAT IS
2691 EmitSignalDeactivateDialog();
2692 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2697 case 904: // FIND ELEM
2699 startOperation( theCommandID );
2703 case 1100: // EDIT HYPOTHESIS
2705 if(checkLock(aStudy)) break;
2707 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2708 SALOME_ListIO selected;
2710 aSel->selectedObjects( selected );
2712 int nbSel = selected.Extent();
2715 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2716 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2718 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2719 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2720 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2721 if ( !aHypothesis->_is_nil() )
2724 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2725 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2727 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2737 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2739 if(checkLock(aStudy)) break;
2740 SUIT_OverrideCursor wc;
2742 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2743 SALOME_ListIO selected;
2745 aSel->selectedObjects( selected, QString::null, false );
2747 SALOME_ListIteratorOfListIO It(selected);
2748 for (int i = 0; It.More(); It.Next(), i++) {
2749 Handle(SALOME_InteractiveObject) IObject = It.Value();
2750 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2753 aSel->setSelectedObjects( l1 );
2758 case 4009: // ELEM0D
2759 case 4010: // GEOM::EDGE
2760 case 4021: // TRIANGLE
2762 case 4023: // POLYGON
2766 if(checkLock(aStudy)) break;
2768 EmitSignalDeactivateDialog();
2769 SMDSAbs_ElementType type = SMDSAbs_Edge;
2771 switch (theCommandID) {
2772 case 4009: // ELEM0D
2773 type = SMDSAbs_0DElement; nbNodes = 1; break;
2774 case 4021: // TRIANGLE
2775 type = SMDSAbs_Face; nbNodes = 3; break;
2777 type = SMDSAbs_Face; nbNodes = 4; break;
2779 type = SMDSAbs_Volume; nbNodes = 4; break;
2780 case 4023: // POLYGON
2781 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2783 type = SMDSAbs_Volume; nbNodes = 8; break;
2784 case 4033: // POLYHEDRE
2785 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2788 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2791 SUIT_MessageBox::warning(desktop(),
2792 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2796 case 4033: // POLYHEDRON
2798 if(checkLock(aStudy)) break;
2800 EmitSignalDeactivateDialog();
2801 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2804 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2805 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2809 case 4034: // QUADRATIC EDGE
2810 case 4035: // QUADRATIC TRIANGLE
2811 case 4036: // QUADRATIC QUADRANGLE
2812 case 4037: // QUADRATIC TETRAHEDRON
2813 case 4038: // QUADRATIC PYRAMID
2814 case 4039: // QUADRATIC PENTAHEDRON
2815 case 4040: // QUADRATIC HEXAHEDRON
2817 if(checkLock(aStudy)) break;
2819 EmitSignalDeactivateDialog();
2822 switch (theCommandID) {
2824 type = QUAD_EDGE; break;
2826 type = QUAD_TRIANGLE; break;
2828 type = QUAD_QUADRANGLE; break;
2830 type = QUAD_TETRAHEDRON; break;
2832 type = QUAD_PYRAMID; break;
2834 type = QUAD_PENTAHEDRON; break;
2836 type = QUAD_HEXAHEDRON;
2840 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2843 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2844 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2848 case 4041: // REMOVES NODES
2850 if(checkLock(aStudy)) break;
2852 EmitSignalDeactivateDialog();
2853 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2856 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2857 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2861 case 4042: // REMOVES ELEMENTS
2863 if(checkLock(aStudy)) break;
2865 EmitSignalDeactivateDialog();
2866 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2870 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2871 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2875 case 4043: { // CLEAR_MESH
2877 if(checkLock(aStudy)) break;
2879 SALOME_ListIO selected;
2880 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2881 aSel->selectedObjects( selected );
2883 SUIT_OverrideCursor wc;
2884 SALOME_ListIteratorOfListIO It (selected);
2885 for ( ; It.More(); It.Next() )
2887 Handle(SALOME_InteractiveObject) IOS = It.Value();
2888 SMESH::SMESH_Mesh_var aMesh =
2889 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2890 if ( aMesh->_is_nil()) continue;
2892 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2894 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2895 SMESH::ModifiedMesh( aMeshSObj, false, true);
2896 // hide groups and submeshes
2897 _PTR(ChildIterator) anIter =
2898 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2899 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2901 _PTR(SObject) so = anIter->Value();
2902 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2905 catch (const SALOME::SALOME_Exception& S_ex){
2907 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2911 SMESH::UpdateView();
2915 case 4044: // REMOVE ORPHAN NODES
2917 if(checkLock(aStudy)) break;
2918 SALOME_ListIO selected;
2919 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2920 aSel->selectedObjects( selected );
2921 if ( selected.Extent() == 1 ) {
2922 Handle(SALOME_InteractiveObject) anIO = selected.First();
2923 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2924 if ( !aMesh->_is_nil() ) {
2925 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2926 tr( "SMESH_WARNING" ),
2927 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2928 SUIT_MessageBox::Yes |
2929 SUIT_MessageBox::No,
2930 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2933 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2934 int removed = aMeshEditor->RemoveOrphanNodes();
2935 SUIT_MessageBox::information(SMESHGUI::desktop(),
2936 tr("SMESH_INFORMATION"),
2937 tr("NB_NODES_REMOVED").arg(removed));
2938 if ( removed > 0 ) {
2939 SMESH::UpdateView();
2940 SMESHGUI::Modified();
2943 catch (const SALOME::SALOME_Exception& S_ex) {
2944 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2953 case 4051: // RENUMBERING NODES
2955 if(checkLock(aStudy)) break;
2957 EmitSignalDeactivateDialog();
2958 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2962 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2963 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2967 case 4052: // RENUMBERING ELEMENTS
2969 if(checkLock(aStudy)) break;
2971 EmitSignalDeactivateDialog();
2972 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2976 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2977 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2981 case 4061: // TRANSLATION
2983 if(checkLock(aStudy)) break;
2985 EmitSignalDeactivateDialog();
2986 ( new SMESHGUI_TranslationDlg( this ) )->show();
2989 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2990 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2994 case 4062: // ROTATION
2996 if(checkLock(aStudy)) break;
2998 EmitSignalDeactivateDialog();
2999 ( new SMESHGUI_RotationDlg( this ) )->show();
3002 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3003 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3007 case 4063: // SYMMETRY
3009 if(checkLock(aStudy)) break;
3011 EmitSignalDeactivateDialog();
3012 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3015 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3016 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3020 case 4064: // SEWING
3022 if(checkLock(aStudy)) break;
3024 EmitSignalDeactivateDialog();
3025 ( new SMESHGUI_SewingDlg( this ) )->show();
3028 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3029 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3033 case 4065: // MERGE NODES
3035 if(checkLock(aStudy)) break;
3037 EmitSignalDeactivateDialog();
3038 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3041 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3042 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3046 case 4066: // MERGE EQUAL ELEMENTS
3048 if (checkLock(aStudy)) break;
3050 EmitSignalDeactivateDialog();
3051 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3053 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3054 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3059 case 4067: // MAKE MESH PASS THROUGH POINT
3060 startOperation( 4067 );
3065 if(checkLock(aStudy)) break;
3067 EmitSignalDeactivateDialog();
3068 ( new SMESHGUI_ScaleDlg( this ) )->show();
3071 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3072 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3077 case 4069: // DUPLICATE NODES
3079 if(checkLock(aStudy)) break;
3081 EmitSignalDeactivateDialog();
3082 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3085 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3086 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3091 case 5105: // Library of selection filters
3093 static QList<int> aTypes;
3094 if ( aTypes.isEmpty() )
3096 aTypes.append( SMESH::NODE );
3097 aTypes.append( SMESH::EDGE );
3098 aTypes.append( SMESH::FACE );
3099 aTypes.append( SMESH::VOLUME );
3101 if (!myFilterLibraryDlg)
3102 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3103 else if (myFilterLibraryDlg->isHidden())
3104 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3105 myFilterLibraryDlg->raise();
3109 case 6017: // CONTROLS
3133 LightApp_SelectionMgr* mgr = selectionMgr();
3134 SALOME_ListIO selected; mgr->selectedObjects( selected );
3136 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3137 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3139 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3140 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3141 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3142 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3143 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3144 ::Control( theCommandID );
3149 SUIT_MessageBox::warning(desktop(),
3150 tr( "SMESH_WRN_WARNING" ),
3151 tr( "SMESH_BAD_SELECTION" ) );
3155 SUIT_MessageBox::warning(desktop(),
3156 tr( "SMESH_WRN_WARNING" ),
3157 tr( "NOT_A_VTK_VIEWER" ) );
3162 LightApp_SelectionMgr* mgr = selectionMgr();
3163 SALOME_ListIO selected; mgr->selectedObjects( selected );
3165 SALOME_ListIteratorOfListIO it(selected);
3166 for( ; it.More(); it.Next()) {
3167 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3168 if(anIObject->hasEntry()) {
3169 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3170 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3178 LightApp_SelectionMgr* mgr = selectionMgr();
3179 SALOME_ListIO selected; mgr->selectedObjects( selected );
3181 SALOME_ListIteratorOfListIO it(selected);
3182 for( ; it.More(); it.Next()) {
3183 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3184 if(anIObject->hasEntry())
3185 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3186 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3194 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3195 EmitSignalDeactivateDialog();
3196 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3202 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3203 //updateObjBrowser();
3207 //=============================================================================
3211 //=============================================================================
3212 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3217 //=============================================================================
3221 //=============================================================================
3222 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3227 //=============================================================================
3231 //=============================================================================
3232 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3237 //=============================================================================
3238 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3239 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3241 //=============================================================================
3242 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3243 SUIT_ViewWindow* wnd )
3245 if(theIO->hasEntry()){
3246 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3247 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3251 //=======================================================================
3252 // function : createSMESHAction
3254 //=======================================================================
3255 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3256 const int key, const bool toggle, const QString& shortcutAction )
3259 QWidget* parent = application()->desktop();
3260 SUIT_ResourceMgr* resMgr = resourceMgr();
3262 if ( !icon_id.isEmpty() )
3263 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3265 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3266 if ( !pix.isNull() )
3267 icon = QIcon( pix );
3269 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3270 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3271 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3273 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3274 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3277 //=======================================================================
3278 // function : createPopupItem
3280 //=======================================================================
3281 void SMESHGUI::createPopupItem( const int id,
3282 const QString& clients,
3283 const QString& types,
3284 const QString& theRule,
3289 parentId = popupMgr()->actionId( action( pId ) );
3291 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3292 popupMgr()->insert( action( id ), parentId, 0 );
3294 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3295 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3296 QString rule = "(%1) and (%2) and (%3)";
3297 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3298 if( clients.isEmpty() )
3299 rule = rule.arg( QString( "true" ) );
3301 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3302 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3305 bool cont = myRules.contains( id );
3307 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3309 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3310 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3313 //=======================================================================
3314 // function : initialize
3316 //=======================================================================
3317 void SMESHGUI::initialize( CAM_Application* app )
3319 SalomeApp_Module::initialize( app );
3321 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3323 /* Automatic Update flag */
3324 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3326 // ----- create actions --------------
3328 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3329 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3330 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3331 createSMESHAction( 114, "NUM" );
3332 createSMESHAction( 115, "STL" );
3333 createSMESHAction( 116, "CGNS" );
3334 createSMESHAction( 121, "DAT" );
3335 createSMESHAction( 122, "MED" );
3336 createSMESHAction( 123, "UNV" );
3337 createSMESHAction( 140, "STL" );
3338 createSMESHAction( 142, "CGNS" );
3339 createSMESHAction( 124, "EXPORT_DAT" );
3340 createSMESHAction( 125, "EXPORT_MED" );
3341 createSMESHAction( 126, "EXPORT_UNV" );
3342 createSMESHAction( 141, "EXPORT_STL" );
3343 createSMESHAction( 143, "EXPORT_CGNS" );
3344 createSMESHAction( 150, "FILE_INFO" );
3345 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3346 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3347 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3348 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3349 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3350 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3351 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3352 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3353 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3354 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3355 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3356 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3357 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3358 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3359 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3360 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3361 createSMESHAction( 804, "ADD" );
3362 createSMESHAction( 805, "REMOVE" );
3363 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3364 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3365 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3366 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3367 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3368 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3369 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3370 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3371 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3372 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3373 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3374 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3375 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3376 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3377 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3378 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3379 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3380 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3381 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3382 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3383 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3384 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3385 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3386 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3387 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3388 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3389 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3390 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3391 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3392 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3393 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3394 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3395 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3396 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3397 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3398 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3399 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3400 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3401 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3402 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3403 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3404 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3405 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3406 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3407 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3408 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3409 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3410 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3411 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3412 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3413 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3414 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3415 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3416 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3417 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3418 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3419 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3420 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3421 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3422 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3423 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3424 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3425 createSMESHAction( 415, "MAP", "ICON_MAP" );
3426 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3427 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3428 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3429 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3430 createSMESHAction( 200, "RESET" );
3431 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3432 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3433 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3434 #ifndef DISABLE_PLOT2DVIEWER
3435 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3437 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3438 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3439 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3440 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3441 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3442 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3443 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3444 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3445 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3446 createSMESHAction( 220, "ALL" );
3447 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3449 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3450 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3452 createSMESHAction( 1100, "EDIT_HYPO" );
3453 createSMESHAction( 1102, "UNASSIGN" );
3454 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3455 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3456 createSMESHAction( 1131, "DISPMODE" );
3457 createSMESHAction( 1132, "COLORS" );
3458 createSMESHAction( 1133, "TRANSP" );
3459 createSMESHAction( 1134, "CLIP" );
3460 createSMESHAction( 1135, "DISP_ENT" );
3461 createSMESHAction( 1136, "AUTO_COLOR" );
3462 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3463 createSMESHAction( 2000, "CTRL" );
3465 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3466 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3468 createSMESHAction( 300, "ERASE" );
3469 createSMESHAction( 301, "DISPLAY" );
3470 createSMESHAction( 302, "DISPLAY_ONLY" );
3471 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3472 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3473 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3474 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3475 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3476 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3477 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3478 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3480 // ----- create menu --------------
3481 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3482 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3483 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3484 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3485 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3486 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3487 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3488 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3490 createMenu( separator(), fileId );
3492 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3493 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3494 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3495 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3496 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3497 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3498 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3499 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3500 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3501 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3503 createMenu( 111, importId, -1 );
3504 createMenu( 112, importId, -1 );
3505 createMenu( 113, importId, -1 );
3506 createMenu( 115, importId, -1 );
3508 createMenu( 116, importId, -1 );
3510 createMenu( 121, exportId, -1 );
3511 createMenu( 122, exportId, -1 );
3512 createMenu( 123, exportId, -1 );
3513 createMenu( 140, exportId, -1 ); // export to STL
3515 createMenu( 142, exportId, -1 ); // export to CGNS
3517 createMenu( separator(), fileId, 10 );
3519 createMenu( 33, editId, -1 );
3521 createMenu( 5105, toolsId, -1 );
3523 createMenu( 702, meshId, -1 ); // "Mesh" menu
3524 createMenu( 703, meshId, -1 );
3525 createMenu( 704, meshId, -1 );
3526 createMenu( 710, meshId, -1 );
3527 createMenu( 705, meshId, -1 );
3528 createMenu( separator(), meshId, -1 );
3529 createMenu( 701, meshId, -1 );
3530 createMenu( 711, meshId, -1 );
3531 createMenu( 712, meshId, -1 );
3532 createMenu( 713, meshId, -1 );
3533 createMenu( separator(), meshId, -1 );
3534 createMenu( 801, meshId, -1 );
3535 createMenu( 806, meshId, -1 );
3536 createMenu( 802, meshId, -1 );
3537 createMenu( 803, meshId, -1 );
3538 createMenu( 815, meshId, -1 );
3539 createMenu( separator(), meshId, -1 );
3540 createMenu( 810, meshId, -1 );
3541 createMenu( 811, meshId, -1 );
3542 createMenu( 812, meshId, -1 );
3543 createMenu( separator(), meshId, -1 );
3544 createMenu( 814, meshId, -1 );
3545 createMenu( separator(), meshId, -1 );
3546 createMenu( 900, meshId, -1 );
3547 //createMenu( 902, meshId, -1 );
3548 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3549 createMenu( 904, meshId, -1 );
3550 createMenu( separator(), meshId, -1 );
3552 createMenu( 6005, nodeId, -1 );
3553 createMenu( 6002, edgeId, -1 );
3554 createMenu( 6003, edgeId, -1 );
3555 createMenu( 6001, edgeId, -1 );
3556 createMenu( 6004, edgeId, -1 );
3557 createMenu( 6021, faceId, -1 );
3558 createMenu( 6025, faceId, -1 );
3559 createMenu( 6027, faceId, -1 );
3560 createMenu( 6018, faceId, -1 );
3561 createMenu( 6019, faceId, -1 );
3562 createMenu( 6011, faceId, -1 );
3563 createMenu( 6012, faceId, -1 );
3564 createMenu( 6013, faceId, -1 );
3565 createMenu( 6014, faceId, -1 );
3566 createMenu( 6015, faceId, -1 );
3567 createMenu( 6016, faceId, -1 );
3568 createMenu( 6022, faceId, -1 );
3569 createMenu( 6017, volumeId, -1 );
3570 createMenu( 6009, volumeId, -1 );
3571 createMenu( 6023, volumeId, -1 );
3572 createMenu( 6024, volumeId, -1 );
3573 createMenu( 6026, volumeId, -1 );
3575 createMenu( 4000, addId, -1 );
3576 createMenu( 4009, addId, -1 );
3577 createMenu( 4010, addId, -1 );
3578 createMenu( 4021, addId, -1 );
3579 createMenu( 4022, addId, -1 );
3580 createMenu( 4023, addId, -1 );
3581 createMenu( 4031, addId, -1 );
3582 createMenu( 4032, addId, -1 );
3583 createMenu( 4033, addId, -1 );
3584 createMenu( separator(), addId, -1 );
3585 createMenu( 4034, addId, -1 );
3586 createMenu( 4035, addId, -1 );
3587 createMenu( 4036, addId, -1 );
3588 createMenu( 4037, addId, -1 );
3589 createMenu( 4038, addId, -1 );
3590 createMenu( 4039, addId, -1 );
3591 createMenu( 4040, addId, -1 );
3593 createMenu( 4041, removeId, -1 );
3594 createMenu( 4042, removeId, -1 );
3595 createMenu( 4044, removeId, -1 );
3596 createMenu( separator(), removeId, -1 );
3597 createMenu( 813, removeId, -1 );
3598 createMenu( separator(), removeId, -1 );
3599 createMenu( 4043, removeId, -1 );
3601 createMenu( 4051, renumId, -1 );
3602 createMenu( 4052, renumId, -1 );
3604 createMenu( 4061, transfId, -1 );
3605 createMenu( 4062, transfId, -1 );
3606 createMenu( 4063, transfId, -1 );
3607 createMenu( 4068, transfId, -1 );
3608 createMenu( 4064, transfId, -1 );
3609 createMenu( 4065, transfId, -1 );
3610 createMenu( 4066, transfId, -1 );
3611 createMenu( 4069, transfId, -1 );
3613 createMenu( 4067,modifyId, -1 );
3614 createMenu( 407, modifyId, -1 );
3615 createMenu( 408, modifyId, -1 );
3616 createMenu( 409, modifyId, -1 );
3617 createMenu( 410, modifyId, -1 );
3618 createMenu( 411, modifyId, -1 );
3619 createMenu( 419, modifyId, -1 );
3620 createMenu( 412, modifyId, -1 );
3621 createMenu( 413, modifyId, -1 );
3622 createMenu( 416, modifyId, -1 );
3623 createMenu( 414, modifyId, -1 );
3624 createMenu( 415, modifyId, -1 );
3625 createMenu( 417, modifyId, -1 );
3626 createMenu( 418, modifyId, -1 );
3628 createMenu( 501, measureId, -1 );
3629 createMenu( 502, measureId, -1 );
3630 createMenu( 214, viewId, -1 );
3632 // ----- create toolbars --------------
3633 int meshTb = createTool( tr( "TB_MESH" ) ),
3634 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3635 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3636 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3637 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3639 createTool( 702, meshTb );
3640 createTool( 703, meshTb );
3641 createTool( 704, meshTb );
3642 createTool( 710, meshTb );
3643 createTool( 705, meshTb );
3644 createTool( separator(), meshTb );
3645 createTool( 701, meshTb );
3646 createTool( 711, meshTb );
3647 createTool( 712, meshTb );
3648 createTool( 713, meshTb );
3649 createTool( separator(), meshTb );
3650 createTool( 801, meshTb );
3651 createTool( 806, meshTb );
3652 createTool( 802, meshTb );
3653 createTool( 803, meshTb );
3654 //createTool( 815, meshTb );
3655 createTool( separator(), meshTb );
3656 createTool( 900, meshTb );
3657 //createTool( 902, meshTb );
3658 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3659 createTool( 904, meshTb );
3660 createTool( separator(), meshTb );
3662 createTool( 6005, ctrlTb );
3663 createTool( separator(), ctrlTb );
3664 createTool( 6002, ctrlTb );
3665 createTool( 6003, ctrlTb );
3666 createTool( 6001, ctrlTb );
3667 createTool( 6004, ctrlTb );
3668 createTool( separator(), ctrlTb );
3669 createTool( 6021, ctrlTb );
3670 createTool( 6025, ctrlTb );
3671 createTool( 6027, ctrlTb );
3672 createTool( 6018, ctrlTb );
3673 createTool( 6019, ctrlTb );
3674 createTool( 6011, ctrlTb );
3675 createTool( 6012, ctrlTb );
3676 createTool( 6013, ctrlTb );
3677 createTool( 6014, ctrlTb );
3678 createTool( 6015, ctrlTb );
3679 createTool( 6016, ctrlTb );
3680 createTool( 6022, ctrlTb );
3681 createTool( separator(), ctrlTb );
3682 createTool( 6017, ctrlTb );
3683 createTool( 6009, ctrlTb );
3684 createTool( 6023, ctrlTb );
3685 createTool( 6024, ctrlTb );
3686 createTool( 6026, ctrlTb );
3687 createTool( separator(), ctrlTb );
3689 createTool( 4000, addRemTb );
3690 createTool( 4009, addRemTb );
3691 createTool( 4010, addRemTb );
3692 createTool( 4021, addRemTb );
3693 createTool( 4022, addRemTb );
3694 createTool( 4023, addRemTb );
3695 createTool( 4031, addRemTb );
3696 createTool( 4032, addRemTb );
3697 createTool( 4033, addRemTb );
3698 createTool( separator(), addRemTb );
3699 createTool( 4034, addRemTb );
3700 createTool( 4035, addRemTb );
3701 createTool( 4036, addRemTb );
3702 createTool( 4037, addRemTb );
3703 createTool( 4038, addRemTb );
3704 createTool( 4039, addRemTb );
3705 createTool( 4040, addRemTb );
3706 createTool( separator(), addRemTb );
3707 createTool( 4041, addRemTb );
3708 createTool( 4042, addRemTb );
3709 createTool( 4044, addRemTb );
3710 createTool( 4043, addRemTb );
3711 createTool( separator(), addRemTb );
3712 createTool( 4051, addRemTb );
3713 createTool( 4052, addRemTb );
3714 createTool( separator(), addRemTb );
3715 createTool( 4061, addRemTb );
3716 createTool( 4062, addRemTb );
3717 createTool( 4063, addRemTb );
3718 createTool( 4068, addRemTb );
3719 createTool( 4064, addRemTb );
3720 createTool( 4065, addRemTb );
3721 createTool( 4066, addRemTb );
3722 createTool( 4069, addRemTb );
3723 createTool( separator(), addRemTb );
3725 createTool( 4067,modifyTb );
3726 createTool( 407, modifyTb );
3727 createTool( 408, modifyTb );
3728 createTool( 409, modifyTb );
3729 createTool( 410, modifyTb );
3730 createTool( 411, modifyTb );
3731 createTool( 419, modifyTb );
3732 createTool( 412, modifyTb );
3733 createTool( 413, modifyTb );
3734 createTool( 416, modifyTb );
3735 createTool( 414, modifyTb );
3736 createTool( 415, modifyTb );
3737 createTool( 417, modifyTb );
3738 createTool( 418, modifyTb );
3740 createTool( 214, dispModeTb );
3742 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3743 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3746 QString OB = "'ObjectBrowser'",
3747 View = "'" + SVTK_Viewer::Type() + "'",
3749 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3750 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3751 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3752 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3753 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3754 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3755 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3756 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3757 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3758 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3759 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3761 mesh_part = mesh + " " + subMesh + " " + group,
3762 mesh_group = mesh + " " + group,
3763 hyp_alg = hypo + " " + algo;
3765 // popup for object browser
3767 isInvisible("not( isVisible )"),
3768 isEmpty("numberOfNodes = 0"),
3769 isNotEmpty("numberOfNodes <> 0"),
3771 // has nodes, edges, etc in VISIBLE! actor
3772 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3773 hasElems("(count( elemTypes ) > 0)"),
3774 hasDifferentElems("(count( elemTypes ) > 1)"),
3775 hasElems0d("({'Elem0d'} in elemTypes)"),
3776 hasEdges("({'Edge'} in elemTypes)"),
3777 hasFaces("({'Face'} in elemTypes)"),
3778 hasVolumes("({'Volume'} in elemTypes)");
3780 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3781 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3782 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3783 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3784 createPopupItem( 803, OB, group ); // EDIT_GROUP
3785 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3787 popupMgr()->insert( separator(), -1, 0 );
3788 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3789 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3790 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3791 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3792 createPopupItem( 214, OB, mesh_part ); // UPDATE
3793 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3794 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3795 popupMgr()->insert( separator(), -1, 0 );
3796 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3797 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3798 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3799 popupMgr()->insert( separator(), -1, 0 );
3800 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3801 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3802 popupMgr()->insert( separator(), -1, 0 );
3803 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3804 popupMgr()->insert( separator(), -1, 0 );
3805 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3806 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3808 popupMgr()->insert( separator(), -1, 0 );
3810 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3811 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3812 QString only_one_2D = only_one_non_empty + " && dim>1";
3814 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3815 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3816 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3818 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3820 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3821 popupMgr()->insert( separator(), -1, 0 );
3824 createPopupItem( 803, View, group ); // EDIT_GROUP
3825 createPopupItem( 804, View, elems ); // ADD
3826 createPopupItem( 805, View, elems ); // REMOVE
3828 popupMgr()->insert( separator(), -1, 0 );
3829 createPopupItem( 214, View, mesh_part ); // UPDATE
3830 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3831 createPopupItem( 904, View, mesh ); // FIND_ELEM
3832 popupMgr()->insert( separator(), -1, 0 );
3834 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3835 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3836 popupMgr()->insert( separator(), -1, 0 );
3839 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3840 QString aType = QString( "%1type in {%2}" ).arg( lc );
3841 aType = aType.arg( mesh_part );
3842 QString aMeshInVTK = aClient + "&&" + aType;
3844 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3845 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3846 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3848 //-------------------------------------------------
3850 //-------------------------------------------------
3851 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3853 popupMgr()->insert( action( 9010 ), anId, -1 );
3854 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3855 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3857 popupMgr()->insert( action( 9011 ), anId, -1 );
3858 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3859 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3861 popupMgr()->insert( separator(), -1, -1 );
3863 //-------------------------------------------------
3865 //-------------------------------------------------
3866 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3868 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3869 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3870 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3872 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3873 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3874 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3876 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3877 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3878 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3880 popupMgr()->insert( separator(), anId, -1 );
3882 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3883 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3884 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3886 //-------------------------------------------------
3888 //-------------------------------------------------
3889 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3891 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3893 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3894 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3895 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3897 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3898 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3899 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3901 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3902 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3903 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3905 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3906 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3907 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3909 popupMgr()->insert( separator(), anId, -1 );
3911 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3912 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3915 //-------------------------------------------------
3916 // Representation of the 2D Quadratic elements
3917 //-------------------------------------------------
3918 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3919 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3920 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3921 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3923 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3924 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3925 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3927 //-------------------------------------------------
3928 // Orientation of faces
3929 //-------------------------------------------------
3930 popupMgr()->insert( action( 221 ), -1, -1 );
3931 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3932 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3934 //-------------------------------------------------
3936 //-------------------------------------------------
3937 popupMgr()->insert( action( 1132 ), -1, -1 );
3938 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3940 //-------------------------------------------------
3942 //-------------------------------------------------
3943 popupMgr()->insert( action( 1133 ), -1, -1 );
3944 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3946 //-------------------------------------------------
3948 //-------------------------------------------------
3950 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3951 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3952 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3953 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3955 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3957 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3958 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3960 popupMgr()->insert( separator(), anId, -1 );
3962 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3964 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3965 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3966 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3968 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3970 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3971 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3972 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3974 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3975 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3976 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3978 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3979 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3980 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3982 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3983 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3984 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3986 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3988 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3989 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3990 QtxPopupMgr::VisibleRule );
3991 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3993 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3994 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3995 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
3997 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
3998 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3999 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4001 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4002 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4003 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4005 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4006 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4007 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4009 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4010 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4011 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4013 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4014 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4015 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4017 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4018 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4019 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4021 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4022 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4023 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4025 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4026 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4027 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4029 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4030 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4031 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4033 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4034 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4035 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4037 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4039 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4040 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4041 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4043 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4044 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4045 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4047 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4048 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4049 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4051 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4052 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4053 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4055 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4056 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4057 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4059 popupMgr()->insert( separator(), anId, -1 );
4061 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4062 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4064 popupMgr()->insert( separator(), anId, -1 );
4066 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4068 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4069 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4071 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4072 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4073 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4075 #ifndef DISABLE_PLOT2DVIEWER
4076 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4077 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4080 //-------------------------------------------------
4082 //-------------------------------------------------
4083 popupMgr()->insert( separator(), -1, -1 );
4084 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4085 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4086 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4087 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4089 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4090 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4092 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4093 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4095 popupMgr()->insert( separator(), -1, -1 );
4097 //-------------------------------------------------
4099 //-------------------------------------------------
4100 popupMgr()->insert( action( 1134 ), -1, -1 );
4101 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4103 popupMgr()->insert( separator(), -1, -1 );
4105 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4106 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4108 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4109 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4112 //================================================================================
4114 * \brief Return true if SMESH or GEOM objects are selected.
4115 * Is called form LightApp_Module::activateModule() which clear selection if
4116 * not isSelectionCompatible()
4118 //================================================================================
4120 bool SMESHGUI::isSelectionCompatible()
4122 bool isCompatible = true;
4123 SALOME_ListIO selected;
4124 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4125 Sel->selectedObjects( selected );
4127 SALOME_ListIteratorOfListIO It( selected );
4128 for ( ; isCompatible && It.More(); It.Next())
4130 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4131 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4133 return isCompatible;
4137 bool SMESHGUI::reusableOperation( const int id )
4139 // compute, evaluate and precompute are not reusable operations
4140 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4143 bool SMESHGUI::activateModule( SUIT_Study* study )
4145 bool res = SalomeApp_Module::activateModule( study );
4147 setMenuShown( true );
4148 setToolShown( true );
4150 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4151 PyGILState_STATE gstate = PyGILState_Ensure();
4152 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4153 if(pluginsmanager==NULL)
4157 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4162 PyGILState_Release(gstate);
4163 // end of GEOM plugins loading
4165 // Reset actions accelerator keys
4166 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4167 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4168 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4170 action( 33)->setEnabled(true); // Delete: Key_Delete
4172 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4173 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4174 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4175 if ( _PTR(Study) aStudy = s->studyDS()) {
4176 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4177 updateObjBrowser(); // objects can be removed
4180 // get all view currently opened in the study and connect their signals to
4181 // the corresponding slots of the class.
4182 SUIT_Desktop* aDesk = study->application()->desktop();
4184 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4185 SUIT_ViewWindow* wnd;
4186 foreach ( wnd, wndList )
4193 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4195 setMenuShown( false );
4196 setToolShown( false );
4198 EmitSignalCloseAllDialogs();
4200 // Unset actions accelerator keys
4201 action(111)->setShortcut(QKeySequence()); // Import DAT
4202 action(112)->setShortcut(QKeySequence()); // Import UNV
4203 action(113)->setShortcut(QKeySequence()); // Import MED
4205 action( 33)->setEnabled(false); // Delete: Key_Delete
4207 return SalomeApp_Module::deactivateModule( study );
4210 void SMESHGUI::studyClosed( SUIT_Study* s )
4212 SMESH::RemoveVisuData( s->id() );
4213 SalomeApp_Module::studyClosed( s );
4216 void SMESHGUI::OnGUIEvent()
4218 const QObject* obj = sender();
4219 if ( !obj || !obj->inherits( "QAction" ) )
4221 int id = actionId((QAction*)obj);
4226 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4228 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4229 if ( CORBA::is_nil( myComponentSMESH ) )
4231 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4233 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4234 return aGUI.myComponentSMESH;
4237 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4238 return myComponentSMESH;
4241 QString SMESHGUI::engineIOR() const
4243 CORBA::ORB_var anORB = getApp()->orb();
4244 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4245 return QString( anIOR.in() );
4248 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4250 SalomeApp_Module::contextMenuPopup( client, menu, title );
4252 selectionMgr()->selectedObjects( lst );
4253 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4254 Handle(SALOME_InteractiveObject) io = lst.First();
4255 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4256 _PTR(Study) study = appStudy->studyDS();
4257 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4259 QString aName = QString( obj->GetName().c_str() );
4260 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4261 aName.remove( (aName.length() - 1), 1 );
4267 LightApp_Selection* SMESHGUI::createSelection() const
4269 return new SMESHGUI_Selection();
4272 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4274 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4275 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4278 void SMESHGUI::viewManagers( QStringList& list ) const
4280 list.append( SVTK_Viewer::Type() );
4283 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4285 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4286 SMESH::UpdateSelectionProp( this );
4288 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4289 for(int i = 0; i < aViews.count() ; i++){
4290 SUIT_ViewWindow *sf = aViews[i];
4296 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4298 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4299 myClippingPlaneInfoMap.erase( theViewManager );
4302 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4304 theActor->AddObserver( SMESH::DeleteActorEvent,
4305 myEventCallbackCommand.GetPointer(),
4309 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4310 unsigned long theEvent,
4311 void* theClientData,
4314 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4315 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4316 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4317 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4318 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4319 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4320 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4321 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4322 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4323 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4324 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4325 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4326 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4327 if( anActor == *anIter3 ) {
4328 anActorList.erase( anIter3 );
4339 void SMESHGUI::createPreferences()
4341 // General tab ------------------------------------------------------------------------
4342 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4344 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4345 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4346 setPreferenceProperty( lim, "min", 0 );
4347 setPreferenceProperty( lim, "max", 100000000 );
4348 setPreferenceProperty( lim, "step", 1000 );
4349 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4351 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4352 setPreferenceProperty( qaGroup, "columns", 2 );
4353 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4354 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4355 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4356 setPreferenceProperty( prec, "min", 0 );
4357 setPreferenceProperty( prec, "max", 16 );
4359 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4360 setPreferenceProperty( dispgroup, "columns", 2 );
4361 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4363 modes.append( tr("MEN_WIRE") );
4364 modes.append( tr("MEN_SHADE") );
4365 modes.append( tr("MEN_NODES") );
4366 modes.append( tr("MEN_SHRINK") );
4367 QList<QVariant> indices;
4368 indices.append( 0 );
4369 indices.append( 1 );
4370 indices.append( 2 );
4371 indices.append( 3 );
4372 setPreferenceProperty( dispmode, "strings", modes );
4373 setPreferenceProperty( dispmode, "indexes", indices );
4375 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4376 setPreferenceProperty( arcgroup, "columns", 2 );
4377 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4378 QStringList quadraticModes;
4379 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4380 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4382 indices.append( 0 );
4383 indices.append( 1 );
4384 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4385 setPreferenceProperty( quadraticmode, "indexes", indices );
4387 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4388 "SMESH", "max_angle" );
4389 setPreferenceProperty( maxAngle, "min", 1 );
4390 setPreferenceProperty( maxAngle, "max", 90 );
4394 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4395 setPreferenceProperty( exportgroup, "columns", 2 );
4396 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4397 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4399 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4400 setPreferenceProperty( computeGroup, "columns", 2 );
4401 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4403 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4404 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4405 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4407 indices.append( 0 );
4408 indices.append( 1 );
4409 indices.append( 2 );
4410 setPreferenceProperty( notifyMode, "strings", modes );
4411 setPreferenceProperty( notifyMode, "indexes", indices );
4413 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4414 setPreferenceProperty( computeGroup, "columns", 2 );
4415 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4417 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4418 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4420 indices.append( 0 );
4421 indices.append( 1 );
4422 setPreferenceProperty( elemInfo, "strings", modes );
4423 setPreferenceProperty( elemInfo, "indexes", indices );
4425 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4426 setPreferenceProperty( segGroup, "columns", 2 );
4427 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4428 "SMESH", "segmentation" );
4429 setPreferenceProperty( segLen, "min", 1 );
4430 setPreferenceProperty( segLen, "max", 10000000 );
4431 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4432 "SMESH", "nb_segments_per_edge" );
4433 setPreferenceProperty( nbSeg, "min", 1 );
4434 setPreferenceProperty( nbSeg, "max", 10000000 );
4436 // Quantities with individual precision settings
4437 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4438 setPreferenceProperty( precGroup, "columns", 2 );
4440 const int nbQuantities = 6;
4441 int precs[nbQuantities], ii = 0;
4442 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4443 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4444 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4445 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4446 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4447 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4448 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4449 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4450 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4451 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4452 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4453 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4455 // Set property for precision value for spinboxes
4456 for ( ii = 0; ii < nbQuantities; ii++ ){
4457 setPreferenceProperty( precs[ii], "min", -14 );
4458 setPreferenceProperty( precs[ii], "max", 14 );
4459 setPreferenceProperty( precs[ii], "precision", 2 );
4462 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4463 setPreferenceProperty( previewGroup, "columns", 2 );
4464 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4465 setPreferenceProperty( chunkSize, "min", 0 );
4466 setPreferenceProperty( chunkSize, "max", 1000 );
4467 setPreferenceProperty( chunkSize, "step", 50 );
4469 // Mesh tab ------------------------------------------------------------------------
4470 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4471 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4472 setPreferenceProperty( nodeGroup, "columns", 3 );
4474 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4476 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4478 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4479 QList<QVariant> aMarkerTypeIndicesList;
4480 QList<QVariant> aMarkerTypeIconsList;
4481 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4482 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4483 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4484 aMarkerTypeIndicesList << i;
4485 aMarkerTypeIconsList << pixmap;
4487 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4488 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4490 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4492 QList<QVariant> aMarkerScaleIndicesList;
4493 QStringList aMarkerScaleValuesList;
4494 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4495 aMarkerScaleIndicesList << i;
4496 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4498 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4499 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4501 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4502 setPreferenceProperty( elemGroup, "columns", 2 );
4504 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4505 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4506 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4509 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4511 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4512 setPreferenceProperty( grpGroup, "columns", 2 );
4514 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4516 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4517 //setPreferenceProperty( sp, "hstretch", 0 );
4518 //setPreferenceProperty( sp, "vstretch", 0 );
4520 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4521 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4522 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4523 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4524 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4525 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4526 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4528 setPreferenceProperty( size0d, "min", 1 );
4529 setPreferenceProperty( size0d, "max", 10 );
4531 setPreferenceProperty( sp, "hstretch", 0 );
4532 setPreferenceProperty( sp, "vstretch", 0 );
4534 setPreferenceProperty( elemW, "min", 1 );
4535 setPreferenceProperty( elemW, "max", 5 );
4537 setPreferenceProperty( shrink, "min", 0 );
4538 setPreferenceProperty( shrink, "max", 100 );
4540 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4541 setPreferenceProperty( orientGroup, "columns", 1 );
4543 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4544 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4546 setPreferenceProperty( orientScale, "min", 0.05 );
4547 setPreferenceProperty( orientScale, "max", 0.5 );
4548 setPreferenceProperty( orientScale, "step", 0.05 );
4550 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4552 // Selection tab ------------------------------------------------------------------------
4553 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4555 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4556 setPreferenceProperty( selGroup, "columns", 2 );
4558 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4559 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4560 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4562 setPreferenceProperty( selW, "min", 1 );
4563 setPreferenceProperty( selW, "max", 5 );
4565 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4566 setPreferenceProperty( preGroup, "columns", 2 );
4568 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4569 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4571 setPreferenceProperty( preW, "min", 1 );
4572 setPreferenceProperty( preW, "max", 5 );
4574 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4575 setPreferenceProperty( precSelGroup, "columns", 2 );
4577 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4578 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4579 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4581 // Scalar Bar tab ------------------------------------------------------------------------
4582 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4583 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4584 setPreferenceProperty( fontGr, "columns", 2 );
4586 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4587 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4589 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4590 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4592 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4593 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4595 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4596 setPreferenceProperty( numcol, "min", 2 );
4597 setPreferenceProperty( numcol, "max", 256 );
4599 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4600 setPreferenceProperty( numlab, "min", 2 );
4601 setPreferenceProperty( numlab, "max", 65 );
4603 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4604 setPreferenceProperty( orientGr, "columns", 2 );
4605 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4606 QStringList orients;
4607 orients.append( tr( "SMESH_VERTICAL" ) );
4608 orients.append( tr( "SMESH_HORIZONTAL" ) );
4609 indices.clear(); indices.append( 0 ); indices.append( 1 );
4610 setPreferenceProperty( orient, "strings", orients );
4611 setPreferenceProperty( orient, "indexes", indices );
4613 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4614 setPreferenceProperty( posVSizeGr, "columns", 2 );
4615 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4616 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4617 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4618 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4619 setPreferenceProperty( xv, "step", 0.1 );
4620 setPreferenceProperty( xv, "min", 0.0 );
4621 setPreferenceProperty( xv, "max", 1.0 );
4622 setPreferenceProperty( yv, "step", 0.1 );
4623 setPreferenceProperty( yv, "min", 0.0 );
4624 setPreferenceProperty( yv, "max", 1.0 );
4625 setPreferenceProperty( wv, "step", 0.1 );
4626 setPreferenceProperty( wv, "min", 0.0 );
4627 setPreferenceProperty( wv, "max", 1.0 );
4628 setPreferenceProperty( hv, "min", 0.0 );
4629 setPreferenceProperty( hv, "max", 1.0 );
4630 setPreferenceProperty( hv, "step", 0.1 );
4632 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4633 setPreferenceProperty( posHSizeGr, "columns", 2 );
4634 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4635 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4636 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4637 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4638 setPreferenceProperty( xv, "min", 0.0 );
4639 setPreferenceProperty( xv, "max", 1.0 );
4640 setPreferenceProperty( xv, "step", 0.1 );
4641 setPreferenceProperty( xh, "min", 0.0 );
4642 setPreferenceProperty( xh, "max", 1.0 );
4643 setPreferenceProperty( xh, "step", 0.1 );
4644 setPreferenceProperty( yh, "min", 0.0 );
4645 setPreferenceProperty( yh, "max", 1.0 );
4646 setPreferenceProperty( yh, "step", 0.1 );
4647 setPreferenceProperty( wh, "min", 0.0 );
4648 setPreferenceProperty( wh, "max", 1.0 );
4649 setPreferenceProperty( wh, "step", 0.1 );
4650 setPreferenceProperty( hh, "min", 0.0 );
4651 setPreferenceProperty( hh, "max", 1.0 );
4652 setPreferenceProperty( hh, "step", 0.1 );
4654 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4655 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4656 setPreferenceProperty( distributionGr, "columns", 3 );
4658 types.append( tr( "SMESH_MONOCOLOR" ) );
4659 types.append( tr( "SMESH_MULTICOLOR" ) );
4660 indices.clear(); indices.append( 0 ); indices.append( 1 );
4661 setPreferenceProperty( coloringType, "strings", types );
4662 setPreferenceProperty( coloringType, "indexes", indices );
4663 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4667 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4669 if( sect=="SMESH" ) {
4670 float sbX1,sbY1,sbW,sbH;
4671 float aTol = 1.00000009999999;
4672 std::string aWarning;
4673 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4674 if( name=="selection_object_color" || name=="selection_element_color" ||
4675 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4676 name=="selection_precision_node" || name=="selection_precision_element" ||
4677 name=="selection_precision_object")
4678 SMESH::UpdateSelectionProp( this );
4679 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4680 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4681 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4682 if(sbX1+sbW > aTol){
4683 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4686 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4687 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4690 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4691 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4692 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4693 if(sbY1+sbH > aTol){
4694 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4695 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4696 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4699 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4700 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4701 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4702 if(sbX1+sbW > aTol){
4703 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4706 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4707 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4710 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4711 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4712 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4713 if(sbY1+sbH > aTol){
4714 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4717 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4718 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4721 else if ( name == "segmentation" ) {
4722 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4723 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4725 else if ( name == "nb_segments_per_edge" ) {
4726 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4727 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4730 if(aWarning.size() != 0){
4731 aWarning += "The default values are applied instead.";
4732 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4733 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4734 QObject::tr(aWarning.c_str()));
4739 //================================================================================
4741 * \brief Update something in accordance with update flags
4742 * \param theFlags - update flags
4744 * Update viewer or/and object browser etc. in accordance with update flags ( see
4745 * LightApp_UpdateFlags enumeration ).
4747 //================================================================================
4748 void SMESHGUI::update( const int flags )
4750 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4751 SMESH::UpdateView();
4753 SalomeApp_Module::update( flags );
4756 //================================================================================
4758 * \brief Set default selection mode
4760 * SLOT called when operation commited. Sets default selection mode
4762 //================================================================================
4763 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4765 SVTK_ViewWindow* vtkWnd =
4766 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4768 vtkWnd->SetSelectionMode( ActorSelection );
4771 //================================================================================
4773 * \brief Set default selection mode
4775 * SLOT called when operation aborted. Sets default selection mode
4777 //================================================================================
4778 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4780 SVTK_ViewWindow* vtkWnd =
4781 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4783 vtkWnd->SetSelectionMode( ActorSelection );
4786 //================================================================================
4788 * \brief Creates operation with given identifier
4789 * \param id - identifier of operation to be started
4790 * \return Pointer on created operation or NULL if operation is not created
4792 * Virtual method redefined from the base class creates operation with given id.
4793 * It is called called automatically from startOperation method of base class.
4795 //================================================================================
4796 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4798 LightApp_Operation* op = 0;
4799 // to do : create operation here
4802 case 417: //convert to quadratic
4803 op = new SMESHGUI_ConvToQuadOp();
4805 case 418: // create 2D mesh as boundary on 3D
4806 op = new SMESHGUI_Make2DFrom3DOp();
4808 case 701: // Compute mesh
4809 op = new SMESHGUI_ComputeOp();
4811 case 702: // Create mesh
4812 op = new SMESHGUI_MeshOp( true, true );
4814 case 703: // Create sub-mesh
4815 op = new SMESHGUI_MeshOp( true, false );
4817 case 704: // Edit mesh/sub-mesh
4818 op = new SMESHGUI_MeshOp( false );
4820 case 711: // Precompute mesh
4821 op = new SMESHGUI_PrecomputeOp();
4823 case 712: // Evaluate mesh
4824 op = new SMESHGUI_EvaluateOp();
4826 case 713: // Evaluate mesh
4827 op = new SMESHGUI_MeshOrderOp();
4829 case 806: // Create group on geom
4830 op = new SMESHGUI_GroupOnShapeOp();
4832 case 904: // Find element
4833 op = new SMESHGUI_FindElemByPointOp();
4835 case 4067: // make mesh pass through point
4836 op = new SMESHGUI_MakeNodeAtPointOp();
4843 op = SalomeApp_Module::createOperation( id );
4847 //================================================================================
4849 * \brief Stops current operations and starts a given one
4850 * \param id - The id of the operation to start
4852 //================================================================================
4854 void SMESHGUI::switchToOperation(int id)
4856 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4857 activeStudy()->abortAllOperations();
4858 startOperation( id );
4861 LightApp_Displayer* SMESHGUI::displayer()
4864 myDisplayer = new SMESHGUI_Displayer( getApp() );
4868 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4871 int aTolerance = 64;
4872 int anIterations = 0;
4878 if( anIterations % aPeriod == 0 )
4881 if( aTolerance < 1 )
4885 aHue = (int)( 360.0 * rand() / RAND_MAX );
4888 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4889 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4890 for( ; it != itEnd; ++it )
4892 SALOMEDS::Color anAutoColor = *it;
4893 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4896 aQColor.getHsv( &h, &s, &v );
4897 if( abs( h - aHue ) < aTolerance )
4909 aColor.setHsv( aHue, 255, 255 );
4911 SALOMEDS::Color aSColor;
4912 aSColor.R = (double)aColor.red() / 255.0;
4913 aSColor.G = (double)aColor.green() / 255.0;
4914 aSColor.B = (double)aColor.blue() / 255.0;
4919 const char gSeparator = '_'; // character used to separate parameter names
4920 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4921 const char gPathSep = '|'; // character used to separate paths
4924 * \brief Store visual parameters
4926 * This method is called just before the study document is saved.
4927 * Store visual parameters in AttributeParameter attribue(s)
4929 void SMESHGUI::storeVisualParameters (int savePoint)
4931 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4932 if (!appStudy || !appStudy->studyDS())
4934 _PTR(Study) studyDS = appStudy->studyDS();
4936 // componentName is used for encoding of entries when storing them in IParameters
4937 std::string componentName = myComponentSMESH->ComponentDataType();
4938 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4939 //if (!aSComponent) return;
4942 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4943 componentName.c_str(),
4945 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4947 // store map of custom markers
4948 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4949 if( !aMarkerMap.empty() )
4951 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4952 for( ; anIter != aMarkerMap.end(); anIter++ )
4954 int anId = anIter->first;
4955 VTK::MarkerData aMarkerData = anIter->second;
4956 std::string aMarkerFileName = aMarkerData.first;
4957 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4958 if( aMarkerTexture.size() < 3 )
4959 continue; // should contain at least width, height and the first value
4961 QString aPropertyName( "texture" );
4962 aPropertyName += gSeparator;
4963 aPropertyName += QString::number( anId );
4965 QString aPropertyValue = aMarkerFileName.c_str();
4966 aPropertyValue += gPathSep;
4968 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4969 ushort aWidth = *aTextureIter++;
4970 ushort aHeight = *aTextureIter++;
4971 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4972 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4973 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4974 aPropertyValue += QString::number( *aTextureIter );
4976 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4980 // viewers counters are used for storing view_numbers in IParameters
4983 // main cycle to store parameters of displayed objects
4984 QList<SUIT_ViewManager*> lst;
4985 QList<SUIT_ViewManager*>::Iterator it;
4986 getApp()->viewManagers(lst);
4987 for (it = lst.begin(); it != lst.end(); it++)
4989 SUIT_ViewManager* vman = *it;
4990 QString vType = vman->getType();
4992 // saving VTK actors properties
4993 if (vType == SVTK_Viewer::Type())
4995 // store the clipping planes attached to the view manager
4996 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4997 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
4998 if( anIter != myClippingPlaneInfoMap.end() )
4999 aClippingPlaneInfoList = anIter->second;
5001 if( !aClippingPlaneInfoList.empty() ) {
5002 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5003 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5005 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5006 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5008 QString aPropertyName( "ClippingPlane" );
5009 aPropertyName += gSeparator;
5010 aPropertyName += QString::number( vtkViewers );
5011 aPropertyName += gSeparator;
5012 aPropertyName += QString::number( anId );
5014 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5015 aPropertyValue += gDigitsSep;
5016 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5017 aPropertyValue += gDigitsSep;
5018 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5019 aPropertyValue += gDigitsSep;
5020 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5022 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5026 QVector<SUIT_ViewWindow*> views = vman->getViews();
5027 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5029 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5031 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5032 vtkActorCollection* allActors = aCopy.GetActors();
5033 allActors->InitTraversal();
5034 while (vtkActor* actor = allActors->GetNextActor())
5036 if (actor->GetVisibility()) // store only visible actors
5038 SMESH_Actor* aSmeshActor = 0;
5039 if (actor->IsA("SMESH_Actor"))
5040 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5041 if (aSmeshActor && aSmeshActor->hasIO())
5043 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5046 // entry is "encoded" = it does NOT contain component adress,
5047 // since it is a subject to change on next component loading
5048 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5050 std::string param, vtkParam = vType.toLatin1().data();
5051 vtkParam += gSeparator;
5052 vtkParam += QString::number(vtkViewers).toLatin1().data();
5053 vtkParam += gSeparator;
5056 param = vtkParam + "Visibility";
5057 ip->setParameter(entry, param, "On");
5060 param = vtkParam + "Representation";
5061 ip->setParameter(entry, param, QString::number
5062 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5065 param = vtkParam + "IsShrunk";
5066 ip->setParameter(entry, param, QString::number
5067 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5069 // Displayed entities
5070 unsigned int aMode = aSmeshActor->GetEntityMode();
5071 bool isE = aMode & SMESH_Actor::eEdges;
5072 bool isF = aMode & SMESH_Actor::eFaces;
5073 bool isV = aMode & SMESH_Actor::eVolumes;
5075 QString modeStr ("e");
5076 modeStr += gDigitsSep; modeStr += QString::number(isE);
5077 modeStr += gDigitsSep; modeStr += "f";
5078 modeStr += gDigitsSep; modeStr += QString::number(isF);
5079 modeStr += gDigitsSep; modeStr += "v";
5080 modeStr += gDigitsSep; modeStr += QString::number(isV);
5082 param = vtkParam + "Entities";
5083 ip->setParameter(entry, param, modeStr.toLatin1().data());
5085 // Colors (surface:edge:)
5086 vtkFloatingPointType r, g, b;
5089 aSmeshActor->GetSufaceColor(r, g, b, delta);
5090 QString colorStr ("surface");
5091 colorStr += gDigitsSep; colorStr += QString::number(r);
5092 colorStr += gDigitsSep; colorStr += QString::number(g);
5093 colorStr += gDigitsSep; colorStr += QString::number(b);
5095 colorStr += gDigitsSep; colorStr += "backsurface";
5096 colorStr += gDigitsSep; colorStr += QString::number(delta);
5099 aSmeshActor->GetEdgeColor(r, g, b);
5100 colorStr += gDigitsSep; colorStr += "edge";
5101 colorStr += gDigitsSep; colorStr += QString::number(r);
5102 colorStr += gDigitsSep; colorStr += QString::number(g);
5103 colorStr += gDigitsSep; colorStr += QString::number(b);
5105 aSmeshActor->GetNodeColor(r, g, b);
5106 colorStr += gDigitsSep; colorStr += "node";
5107 colorStr += gDigitsSep; colorStr += QString::number(r);
5108 colorStr += gDigitsSep; colorStr += QString::number(g);
5109 colorStr += gDigitsSep; colorStr += QString::number(b);
5111 param = vtkParam + "Colors";
5112 ip->setParameter(entry, param, colorStr.toLatin1().data());
5114 // Sizes of lines and points
5115 QString sizeStr ("line");
5116 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5117 sizeStr += gDigitsSep; sizeStr += "shrink";
5118 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5120 param = vtkParam + "Sizes";
5121 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5126 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5127 if( aMarkerType == VTK::MT_USER ) {
5128 markerStr += "custom";
5129 markerStr += gDigitsSep;
5130 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5134 markerStr += gDigitsSep;
5135 markerStr += QString::number( (int)aMarkerType );
5136 markerStr += gDigitsSep;
5137 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5140 param = vtkParam + "PointMarker";
5141 ip->setParameter(entry, param, markerStr.toLatin1().data());
5144 param = vtkParam + "Opacity";
5145 ip->setParameter(entry, param,
5146 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5149 param = vtkParam + "ClippingPlane";
5151 if( !aClippingPlaneInfoList.empty() ) {
5152 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5153 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5155 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5156 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5157 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5158 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5159 if( aSmeshActor == *anIter2 ) {
5160 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5161 QString::number( anId ).toLatin1().constData() );
5168 ip->setParameter( entry, param, "Off" );
5169 } // if (io->hasEntry())
5170 } // SMESH_Actor && hasIO
5172 } // while.. actors traversal
5176 } // if (SVTK view model)
5177 } // for (viewManagers)
5180 // data structures for clipping planes processing
5183 vtkIdType Orientation;
5184 vtkFloatingPointType Distance;
5185 vtkFloatingPointType Angle[2];
5187 typedef std::list<TPlaneData> TPlaneDataList;
5188 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5190 typedef std::list<vtkActor*> TActorList;
5193 TActorList ActorList;
5194 SUIT_ViewManager* ViewManager;
5196 typedef std::list<TPlaneInfo> TPlaneInfoList;
5197 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5200 * \brief Restore visual parameters
5202 * This method is called after the study document is opened.
5203 * Restore visual parameters from AttributeParameter attribue(s)
5205 void SMESHGUI::restoreVisualParameters (int savePoint)
5207 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5208 if (!appStudy || !appStudy->studyDS())
5210 _PTR(Study) studyDS = appStudy->studyDS();
5212 // componentName is used for encoding of entries when storing them in IParameters
5213 std::string componentName = myComponentSMESH->ComponentDataType();
5214 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5215 //if (!aSComponent) return;
5218 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5219 componentName.c_str(),
5221 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5223 // restore map of custom markers and map of clipping planes
5224 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5225 TPlaneDataMap aPlaneDataMap;
5227 std::vector<std::string> properties = ip->getProperties();
5228 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5230 std::string property = *propIt;
5231 QString aPropertyName( property.c_str() );
5232 QString aPropertyValue( ip->getProperty( property ).c_str() );
5234 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5235 if( aPropertyNameList.isEmpty() )
5238 QString aPropertyType = aPropertyNameList[0];
5239 if( aPropertyType == "texture" )
5241 if( aPropertyNameList.size() != 2 )
5245 int anId = aPropertyNameList[1].toInt( &ok );
5246 if( !ok || anId < 1 )
5249 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5250 if( aPropertyValueList.size() != 2 )
5253 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5254 QString aMarkerTextureString = aPropertyValueList[1];
5255 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5256 if( aMarkerTextureStringList.size() != 3 )
5260 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5265 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5269 VTK::MarkerTexture aMarkerTexture;
5270 aMarkerTexture.push_back( aWidth );
5271 aMarkerTexture.push_back( aHeight );
5273 QString aMarkerTextureData = aMarkerTextureStringList[2];
5274 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5276 QChar aChar = aMarkerTextureData.at( i );
5277 if( aChar.isDigit() )
5278 aMarkerTexture.push_back( aChar.digitValue() );
5281 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5283 else if( aPropertyType == "ClippingPlane" )
5285 if( aPropertyNameList.size() != 3 )
5289 int aViewId = aPropertyNameList[1].toInt( &ok );
5290 if( !ok || aViewId < 0 )
5294 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5295 if( !ok || aClippingPlaneId < 0 )
5298 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5299 if( aPropertyValueList.size() != 4 )
5302 TPlaneData aPlaneData;
5303 aPlaneData.Id = aClippingPlaneId;
5306 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5311 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5316 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5321 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5325 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5326 aPlaneDataList.push_back( aPlaneData );
5330 TPlaneInfoMap aPlaneInfoMap;
5332 std::vector<std::string> entries = ip->getEntries();
5334 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5336 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5337 QString entry (ip->decodeEntry(*entIt).c_str());
5339 // Check that the entry corresponds to a real object in the Study
5340 // as the object may be deleted or modified after the visual state is saved.
5341 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5342 if (!so) continue; //Skip the not existent entry
5344 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5345 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5347 std::vector<std::string>::iterator namesIt = paramNames.begin();
5348 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5350 // actors are stored in a map after displaying of them for
5351 // quicker access in the future: map < viewID to actor >
5352 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5354 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5356 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5357 // '_' is used as separator and should not be used in viewer type or parameter names.
5358 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5359 if (lst.size() != 3)
5362 QString viewerTypStr = lst[0];
5363 QString viewIndexStr = lst[1];
5364 QString paramNameStr = lst[2];
5367 int viewIndex = viewIndexStr.toUInt(&ok);
5368 if (!ok) // bad conversion of view index to integer
5372 if (viewerTypStr == SVTK_Viewer::Type())
5374 SMESH_Actor* aSmeshActor = 0;
5375 if (vtkActors.IsBound(viewIndex))
5376 aSmeshActor = vtkActors.Find(viewIndex);
5378 QList<SUIT_ViewManager*> lst;
5379 getApp()->viewManagers(viewerTypStr, lst);
5381 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5382 SUIT_ViewManager* vman = NULL;
5383 if (viewIndex >= 0 && viewIndex < lst.count())
5384 vman = lst.at(viewIndex);
5386 if (paramNameStr == "Visibility")
5388 if (!aSmeshActor && displayer() && vman)
5390 SUIT_ViewModel* vmodel = vman->getViewModel();
5391 // SVTK view model can be casted to SALOME_View
5392 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5394 // store displayed actor in a temporary map for quicker
5395 // access later when restoring other parameters
5396 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5397 vtkRenderer* Renderer = vtkView->getRenderer();
5398 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5399 vtkActorCollection* theActors = aCopy.GetActors();
5400 theActors->InitTraversal();
5401 bool isFound = false;
5402 vtkActor *ac = theActors->GetNextActor();
5403 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5404 if (ac->IsA("SMESH_Actor")) {
5405 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5406 if (aGeomAc->hasIO()) {
5407 Handle(SALOME_InteractiveObject) io =
5408 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5409 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5411 vtkActors.Bind(viewIndex, aGeomAc);
5417 } // if (paramNameStr == "Visibility")
5420 // the rest properties "work" with SMESH_Actor
5423 QString val ((*valuesIt).c_str());
5426 if (paramNameStr == "Representation") {
5427 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5430 else if (paramNameStr == "IsShrunk") {
5432 if (!aSmeshActor->IsShrunk())
5433 aSmeshActor->SetShrink();
5436 if (aSmeshActor->IsShrunk())
5437 aSmeshActor->UnShrink();
5440 // Displayed entities
5441 else if (paramNameStr == "Entities") {
5442 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5443 if (mode.count() == 6) {
5444 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5445 MESSAGE("Invalid order of data in Entities, must be: "
5446 "e:0/1:f:0/1:v:0/1");
5449 unsigned int aMode = aSmeshActor->GetEntityMode();
5450 unsigned int aNewMode =
5451 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5452 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5453 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5454 if (aNewMode != aMode)
5455 aSmeshActor->SetEntityMode(aNewMode);
5460 else if (paramNameStr == "Colors") {
5461 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5462 if (colors.count() == 16 || colors.count() == 14 ) {
5463 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5464 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node")) {
5465 MESSAGE("Invalid order of data in Colors, must be: "
5466 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b or surface:r:g:b:backsurface:delta:edge:r:g:b:node:r:g:b");
5472 //Old case backsurface color is independent
5473 if( colors.count() == 16 ) {
5475 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5476 er = colors[9].toFloat();
5477 eg = colors[10].toFloat();
5478 eb = colors[11].toFloat();
5480 nr = colors[13].toFloat();
5481 ng = colors[14].toFloat();
5482 nb = colors[15].toFloat();
5484 //New case backsurface color depends on surface color
5485 delta = colors[5].toInt();
5487 er = colors[7].toFloat();
5488 eg = colors[8].toFloat();
5489 eb = colors[9].toFloat();
5491 nr = colors[11].toFloat();
5492 ng = colors[12].toFloat();
5493 nb = colors[13].toFloat();
5495 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5496 aSmeshActor->SetEdgeColor(er,eg,eb);
5497 aSmeshActor->SetNodeColor(nr,ng,nb);
5501 // Sizes of lines and points
5502 else if (paramNameStr == "Sizes") {
5503 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5504 if (sizes.count() == 4) {
5505 if (sizes[0] != "line" || sizes[2] != "shrink") {
5506 MESSAGE("Invalid order of data in Sizes, must be: "
5507 "line:int:shrink:float");
5510 aSmeshActor->SetLineWidth(sizes[1].toInt());
5511 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5514 else if (sizes.count() == 6) { // just to support old format
5515 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5516 MESSAGE("Invalid order of data in Sizes, must be: "
5517 "line:int:node:int:shrink:float");
5520 aSmeshActor->SetLineWidth(sizes[1].toInt());
5521 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5522 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5527 else if (paramNameStr == "PointMarker") {
5528 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5529 if( data.count() >= 2 ) {
5531 int aParam1 = data[1].toInt( &ok );
5533 if( data[0] == "std" && data.count() == 3 ) {
5534 int aParam2 = data[2].toInt( &ok );
5535 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5537 else if( data[0] == "custom" ) {
5538 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5539 if( markerIt != aMarkerMap.end() ) {
5540 VTK::MarkerData aMarkerData = markerIt->second;
5541 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5548 else if (paramNameStr == "Opacity") {
5549 aSmeshActor->SetOpacity(val.toFloat());
5552 else if (paramNameStr.startsWith("ClippingPlane")) {
5553 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5554 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5555 // new format - val looks like "Off" or "0" (plane id)
5556 // (note: in new format "Off" value is used only for consistency,
5557 // so it is processed together with values in old format)
5558 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5559 if( anIsOldFormat ) {
5560 if (paramNameStr == "ClippingPlane1" || val == "Off")
5561 aSmeshActor->RemoveAllClippingPlanes();
5563 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5564 double aDistance = vals[1].toFloat();
5565 vtkFloatingPointType anAngle[2];
5566 anAngle[0] = vals[2].toFloat();
5567 anAngle[1] = vals[3].toFloat();
5569 QList<SUIT_ViewManager*> lst;
5570 getApp()->viewManagers(viewerTypStr, lst);
5571 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5572 if (viewIndex >= 0 && viewIndex < lst.count()) {
5573 SUIT_ViewManager* vman = lst.at(viewIndex);
5574 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5576 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5578 SMESH::TActorList anActorList;
5579 anActorList.push_back( aSmeshActor );
5580 SMESH::OrientedPlane* aPlane =
5581 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5583 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5584 aClippingPlaneInfo.Plane = aPlane;
5585 aClippingPlaneInfo.ActorList = anActorList;
5586 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5593 int aPlaneId = val.toInt( &ok );
5594 if( ok && aPlaneId >= 0 ) {
5595 bool anIsDefinedPlane = false;
5596 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5597 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5598 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5599 TPlaneInfo& aPlaneInfo = *anIter;
5600 if( aPlaneInfo.PlaneId == aPlaneId ) {
5601 aPlaneInfo.ActorList.push_back( aSmeshActor );
5602 anIsDefinedPlane = true;
5606 if( !anIsDefinedPlane ) {
5607 TPlaneInfo aPlaneInfo;
5608 aPlaneInfo.PlaneId = aPlaneId;
5609 aPlaneInfo.ActorList.push_back( aSmeshActor );
5610 aPlaneInfo.ViewManager = vman;
5612 // to make the list sorted by plane id
5613 anIter = aPlaneInfoList.begin();
5614 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5615 const TPlaneInfo& aPlaneInfoRef = *anIter;
5616 if( aPlaneInfoRef.PlaneId > aPlaneId )
5619 aPlaneInfoList.insert( anIter, aPlaneInfo );
5624 } // if (aSmeshActor)
5625 } // other parameters than Visibility
5627 } // for names/parameters iterator
5628 } // for entries iterator
5630 // take into account planes with empty list of actors referred to them
5631 QList<SUIT_ViewManager*> aVMList;
5632 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5634 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5635 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5636 int aViewId = aPlaneDataIter->first;
5637 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5638 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5640 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5642 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5643 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5644 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5645 const TPlaneData& aPlaneData = *anIter2;
5646 int aPlaneId = aPlaneData.Id;
5648 bool anIsFound = false;
5649 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5650 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5651 const TPlaneInfo& aPlaneInfo = *anIter3;
5652 if( aPlaneInfo.PlaneId == aPlaneId ) {
5659 TPlaneInfo aPlaneInfo; // ActorList field is empty
5660 aPlaneInfo.PlaneId = aPlaneId;
5661 aPlaneInfo.ViewManager = aViewManager;
5663 // to make the list sorted by plane id
5664 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5665 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5666 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5667 if( aPlaneInfoRef.PlaneId > aPlaneId )
5670 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5676 // add clipping planes to actors according to the restored parameters
5677 // and update the clipping plane map
5678 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5679 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5680 int aViewId = anIter1->first;
5681 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5683 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5684 if( anIter2 == aPlaneDataMap.end() )
5686 const TPlaneDataList& aPlaneDataList = anIter2->second;
5688 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5689 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5690 const TPlaneInfo& aPlaneInfo = *anIter3;
5691 int aPlaneId = aPlaneInfo.PlaneId;
5692 const TActorList& anActorList = aPlaneInfo.ActorList;
5693 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5697 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5701 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5703 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5704 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5705 const TPlaneData& aPlaneData = *anIter4;
5706 if( aPlaneData.Id == aPlaneId ) {
5707 SMESH::OrientedPlane* aPlane =
5708 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5710 (SMESH::Orientation)aPlaneData.Orientation,
5711 aPlaneData.Distance,
5714 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5715 aClippingPlaneInfo.Plane = aPlane;
5716 aClippingPlaneInfo.ActorList = anActorList;
5717 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5725 // update all VTK views
5726 QList<SUIT_ViewManager*> lst;
5727 getApp()->viewManagers(lst);
5728 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5729 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5730 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5731 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5732 vtkView->getRenderer()->ResetCameraClippingRange();
5739 \brief Adds preferences for dfont of VTK viewer
5741 \param pIf group identifier
5742 \param param parameter
5743 \return identifier of preferences
5745 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5747 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5749 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5752 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5753 fam.append( tr( "SMESH_FONT_COURIER" ) );
5754 fam.append( tr( "SMESH_FONT_TIMES" ) );
5756 setPreferenceProperty( tfont, "fonts", fam );
5758 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5759 setPreferenceProperty( tfont, "features", f );
5765 \brief Actions after hypothesis edition
5766 Updates object browser after hypothesis edition
5768 void SMESHGUI::onHypothesisEdit( int result )
5771 SMESHGUI::Modified();
5772 updateObjBrowser( true );
5777 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5778 \param pview view being closed
5780 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5781 #ifndef DISABLE_PLOT2DVIEWER
5782 //Crear all Plot2d Viewers if need.
5783 SMESH::ClearPlot2Viewers(pview);
5788 \brief Connects or disconnects signals about activating and cloning view on the module slots
5789 \param pview view which is connected/disconnected
5791 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5795 SUIT_ViewManager* viewMgr = pview->getViewManager();
5797 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5798 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5800 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5801 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5806 \brief Return \c true if object can be renamed
5808 bool SMESHGUI::renameAllowed( const QString& entry) const {
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::renameAllowed(entry);
5821 // check type to prevent renaming of inappropriate objects
5822 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5823 if (aType == MESH || aType == GROUP ||
5824 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5825 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5826 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5827 aType == HYPOTHESIS || aType == ALGORITHM)
5834 Rename object by entry.
5835 \param entry entry of the object
5836 \param name new name of the object
5837 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5839 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5841 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5845 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5849 bool appRes = SalomeApp_Module::renameObject(entry,name);
5853 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5854 _PTR(GenericAttribute) anAttr;
5855 _PTR(AttributeName) aName;
5857 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5859 // check type to prevent renaming of inappropriate objects
5860 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5861 if (aType == MESH || aType == GROUP ||
5862 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5863 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5864 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5865 aType == HYPOTHESIS || aType == ALGORITHM) {
5866 if ( !name.isEmpty() ) {
5867 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5869 // update name of group object and its actor
5870 Handle(SALOME_InteractiveObject) IObject =
5871 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5873 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5874 if( !aGroupObject->_is_nil() ) {
5875 aGroupObject->SetName( qPrintable(name) );
5876 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5877 anActor->setName( qPrintable(name) );