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 );
791 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B );
796 SMESH::RepaintCurrentView();
799 QString functorToString( SMESH::Controls::FunctorPtr f )
801 QString type = QObject::tr( "UNKNOWN_CONTROL" );
802 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
803 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
804 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
805 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
806 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
807 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
808 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
809 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
810 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
811 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
812 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
813 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
814 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
815 type = QObject::tr( "WARP_ELEMENTS" );
816 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
817 type = QObject::tr( "TAPER_ELEMENTS" );
818 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
819 type = QObject::tr( "SKEW_ELEMENTS" );
820 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
821 type = QObject::tr( "AREA_ELEMENTS" );
822 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
823 type = QObject::tr( "LENGTH_EDGES" );
824 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
825 type = QObject::tr( "LENGTH2D_EDGES" );
826 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
827 type = QObject::tr( "MULTI_BORDERS" );
828 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
829 type = QObject::tr( "MULTI2D_BORDERS" );
830 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
831 type = QObject::tr( "FREE_NODES" );
832 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
833 type = QObject::tr( "FREE_EDGES" );
834 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
835 type = QObject::tr( "FREE_BORDERS" );
836 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
837 type = QObject::tr( "FREE_FACES" );
838 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
839 type = QObject::tr( "BARE_BORDER_VOLUME" );
840 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
841 type = QObject::tr( "BARE_BORDER_FACE" );
842 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
843 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
844 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
845 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
849 void SaveDistribution()
851 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
852 SALOME_ListIO selected;
854 aSel->selectedObjects( selected );
856 if ( selected.Extent() == 1 ) {
857 Handle(SALOME_InteractiveObject) anIO = selected.First();
858 if ( anIO->hasEntry() ) {
859 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
860 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
861 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
862 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
863 if ( aScalarBarActor && aFunctor ) {
864 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
866 std::vector<int> elements;
867 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
868 if ( mesh->_is_nil() ) {
869 SMESH::SMESH_IDSource_var idSource =
870 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
871 if ( !idSource->_is_nil() )
873 SMESH::long_array_var ids = idSource->GetIDs();
874 elements.resize( ids->length() );
875 for ( unsigned i = 0; i < elements.size(); ++i )
876 elements[i] = ids[i];
879 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
880 vtkLookupTable* lookupTable =
881 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
882 double * minmax = lookupTable->GetRange();
883 std::vector<int> nbEvents;
884 std::vector<double> funValues;
885 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
886 QString anInitialPath = "";
887 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
888 anInitialPath = QDir::currentPath();
889 QString aMeshName = anIO->getName();
891 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
892 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
893 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
894 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
895 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
898 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
900 if ( !aFilename.isEmpty() ) {
901 QFile f( aFilename );
902 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
903 QTextStream out( &f );
904 out << "# Mesh: " << aMeshName << endl;
905 out << "# Control: " << functorToString( aFunctor ) << endl;
907 out.setFieldWidth( 10 );
908 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
909 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
920 void ShowDistribution() {
921 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
922 SALOME_ListIO selected;
924 aSel->selectedObjects( selected );
926 if ( selected.Extent() == 1 ) {
927 Handle(SALOME_InteractiveObject) anIO = selected.First();
928 if ( anIO->hasEntry() ) {
929 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
930 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
931 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
932 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
938 #ifndef DISABLE_PLOT2DVIEWER
939 void PlotDistribution() {
940 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
944 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
945 SALOME_ListIO selected;
947 aSel->selectedObjects( selected );
949 if ( selected.Extent() == 1 ) {
950 Handle(SALOME_InteractiveObject) anIO = selected.First();
951 if ( anIO->hasEntry() ) {
952 //Find Actor by entry before getting Plot2d viewer,
953 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
954 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
956 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
961 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
965 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
969 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
970 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
971 QString functorName = functorToString( anActor->GetFunctor());
972 QString aHistogramName("%1 : %2");
973 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
974 aHistogram->setName(aHistogramName);
975 aHistogram->setHorTitle(functorName);
976 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
977 aPlot->displayObject(aHistogram, true);
982 #endif //DISABLE_PLOT2DVIEWER
984 void DisableAutoColor(){
985 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
986 SALOME_ListIO selected;
988 aSel->selectedObjects( selected );
990 if(selected.Extent()){
991 Handle(SALOME_InteractiveObject) anIObject = selected.First();
992 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
993 if ( !aMesh->_is_nil() ) {
994 aMesh->SetAutoColor( false );
999 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1000 SALOME_ListIO selected;
1001 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1005 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1006 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1007 if( !aSel || !appStudy )
1010 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1011 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1012 aModule->EmitSignalDeactivateDialog();
1013 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1014 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1019 _PTR(Study) aStudy = appStudy->studyDS();
1021 aSel->selectedObjects( selected );
1023 if(selected.Extent() >= 1){
1024 switch(theCommandID){
1026 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1027 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1031 QColor c, e, b, n, c0D, o;
1034 vtkFloatingPointType Shrink = 0.0;
1035 vtkFloatingPointType faces_orientation_scale = 0.0;
1036 bool faces_orientation_3dvectors = false;
1038 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1039 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1040 int aMarkerTextureCurrent = 0;
1042 SALOME_ListIteratorOfListIO It( selected );
1043 for( ; It.More(); It.Next()){
1044 Handle(SALOME_InteractiveObject) IObject = It.Value();
1045 if(IObject->hasEntry()){
1046 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1047 vtkFloatingPointType color[3];
1048 anActor->GetSufaceColor(color[0], color[1], color[2]);
1049 int c0 = int (color[0] * 255);
1050 int c1 = int (color[1] * 255);
1051 int c2 = int (color[2] * 255);
1052 c.setRgb(c0, c1, c2);
1054 vtkFloatingPointType edgecolor[3];
1055 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1056 c0 = int (edgecolor[0] * 255);
1057 c1 = int (edgecolor[1] * 255);
1058 c2 = int (edgecolor[2] * 255);
1059 e.setRgb(c0, c1, c2);
1061 vtkFloatingPointType backfacecolor[3];
1062 anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
1063 c0 = int (backfacecolor[0] * 255);
1064 c1 = int (backfacecolor[1] * 255);
1065 c2 = int (backfacecolor[2] * 255);
1066 b.setRgb(c0, c1, c2);
1068 vtkFloatingPointType nodecolor[3];
1069 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1070 c0 = int (nodecolor[0] * 255);
1071 c1 = int (nodecolor[1] * 255);
1072 c2 = int (nodecolor[2] * 255);
1073 n.setRgb(c0, c1, c2);
1075 vtkFloatingPointType color0D[3];
1076 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1077 c0 = int (color0D[0] * 255);
1078 c1 = int (color0D[1] * 255);
1079 c2 = int (color0D[2] * 255);
1080 c0D.setRgb(c0, c1, c2);
1082 size0D = (int)anActor->Get0DSize();
1085 Edgewidth = (int)anActor->GetLineWidth();
1088 Shrink = anActor->GetShrinkFactor();
1090 vtkFloatingPointType faces_orientation_color[3];
1091 anActor->GetFacesOrientationColor(faces_orientation_color);
1092 c0 = int (faces_orientation_color[0] * 255);
1093 c1 = int (faces_orientation_color[1] * 255);
1094 c2 = int (faces_orientation_color[2] * 255);
1095 o.setRgb(c0, c1, c2);
1097 faces_orientation_scale = anActor->GetFacesOrientationScale();
1098 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1100 aMarkerTypeCurrent = anActor->GetMarkerType();
1101 aMarkerScaleCurrent = anActor->GetMarkerScale();
1102 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1104 // even if there are multiple objects in the selection,
1105 // we need only the first one to get values for the dialog
1111 SMESHGUI_Preferences_ColorDlg *aDlg =
1112 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1113 aDlg->SetColor(1, c);
1114 aDlg->SetColor(2, e);
1115 aDlg->SetColor(3, n);
1116 aDlg->SetColor(4, b);
1117 aDlg->SetColor(5, c0D);
1118 aDlg->SetColor(6, o);
1119 aDlg->SetIntValue(1, Edgewidth);
1120 aDlg->SetIntValue(2, int(Shrink*100.));
1121 aDlg->SetIntValue(3, size0D);
1122 aDlg->SetDoubleValue(1, faces_orientation_scale);
1123 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1125 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1127 if( aMarkerTypeCurrent != VTK::MT_USER )
1128 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1130 aDlg->setCustomMarker( aMarkerTextureCurrent );
1133 QColor color = aDlg->GetColor(1);
1134 QColor edgecolor = aDlg->GetColor(2);
1135 QColor nodecolor = aDlg->GetColor(3);
1136 QColor backfacecolor = aDlg->GetColor(4);
1137 QColor color0D = aDlg->GetColor(5);
1138 QColor faces_orientation_color = aDlg->GetColor(6);
1141 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1143 SALOME_ListIteratorOfListIO It( selected );
1144 for( ; It.More(); It.Next()){
1145 Handle(SALOME_InteractiveObject) IObject = It.Value();
1146 if(IObject->hasEntry()){
1147 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1148 /* actor color and backface color */
1149 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1150 vtkFloatingPointType (color.green()) / 255.,
1151 vtkFloatingPointType (color.blue()) / 255.);
1152 anActor->SetBackSufaceColor(vtkFloatingPointType (backfacecolor.red()) / 255.,
1153 vtkFloatingPointType (backfacecolor.green()) / 255.,
1154 vtkFloatingPointType (backfacecolor.blue()) / 255.);
1157 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1158 vtkFloatingPointType (edgecolor.green()) / 255.,
1159 vtkFloatingPointType (edgecolor.blue()) / 255.);
1161 /* Shrink factor and size edges */
1162 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1163 anActor->SetLineWidth(aDlg->GetIntValue(1));
1165 /* Nodes color and size */
1166 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1167 vtkFloatingPointType (nodecolor.green()) / 255.,
1168 vtkFloatingPointType (nodecolor.blue()) / 255.);
1171 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1172 vtkFloatingPointType (color0D.green()) / 255.,
1173 vtkFloatingPointType (color0D.blue()) / 255.);
1174 anActor->Set0DSize(aDlg->GetIntValue(3));
1176 /* Faces orientation */
1177 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1178 vtkFloatingPointType(faces_orientation_color.greenF()),
1179 vtkFloatingPointType(faces_orientation_color.blueF())};
1180 anActor->SetFacesOrientationColor(c);
1181 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1182 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1184 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1185 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1186 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1187 if( aMarkerTypeNew != VTK::MT_USER )
1188 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1190 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1191 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1192 if( anIter != aMarkerMap.end() )
1193 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1196 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1197 if( !aGroupObject->_is_nil() )
1199 SMESH::ElementType anElementType = aGroupObject->GetType();
1201 switch( anElementType )
1203 case SMESH::NODE: aColor = nodecolor; break;
1204 case SMESH::EDGE: aColor = edgecolor; break;
1205 default: aColor = color; break;
1208 SALOMEDS::Color aGroupColor;
1209 aGroupColor.R = (float)aColor.red() / 255.0;
1210 aGroupColor.G = (float)aColor.green() / 255.0;
1211 aGroupColor.B = (float)aColor.blue() / 255.0;
1212 aGroupObject->SetColor( aGroupColor );
1217 SMESH::RepaintCurrentView();
1223 SALOME_ListIteratorOfListIO It( selected );
1224 for( ; It.More(); It.Next()){
1225 Handle(SALOME_InteractiveObject) IObject = It.Value();
1226 if(IObject->hasEntry()){
1227 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1228 switch(theCommandID){
1230 anActor->SetRepresentation(SMESH_Actor::eEdge);
1233 anActor->SetRepresentation(SMESH_Actor::eSurface);
1236 if(anActor->IsShrunk())
1237 anActor->UnShrink();
1239 anActor->SetShrink();
1242 anActor->SetRepresentation(SMESH_Actor::ePoint);
1245 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1246 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1249 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1250 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1256 SMESH::RepaintCurrentView();
1260 void Control( int theCommandID )
1262 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1263 SALOME_ListIO selected;
1265 aSel->selectedObjects( selected );
1267 if( !selected.IsEmpty() ){
1268 Handle(SALOME_InteractiveObject) anIO = selected.First();
1270 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1271 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1272 switch ( theCommandID ){
1274 aControl = SMESH_Actor::eLength;
1277 aControl = SMESH_Actor::eLength2D;
1280 aControl = SMESH_Actor::eFreeEdges;
1283 aControl = SMESH_Actor::eFreeBorders;
1286 aControl = SMESH_Actor::eMultiConnection;
1289 aControl = SMESH_Actor::eFreeNodes;
1292 aControl = SMESH_Actor::eMultiConnection2D;
1295 aControl = SMESH_Actor::eArea;
1298 aControl = SMESH_Actor::eTaper;
1301 aControl = SMESH_Actor::eAspectRatio;
1304 aControl = SMESH_Actor::eAspectRatio3D;
1307 aControl = SMESH_Actor::eMinimumAngle;
1310 aControl = SMESH_Actor::eWarping;
1313 aControl = SMESH_Actor::eSkew;
1316 aControl = SMESH_Actor::eVolume3D;
1319 aControl = SMESH_Actor::eFreeFaces;
1322 aControl = SMESH_Actor::eMaxElementLength2D;
1325 aControl = SMESH_Actor::eMaxElementLength3D;
1328 aControl = SMESH_Actor::eBareBorderVolume;
1331 aControl = SMESH_Actor::eBareBorderFace;
1334 aControl = SMESH_Actor::eOverConstrainedVolume;
1337 aControl = SMESH_Actor::eOverConstrainedFace;
1340 anActor->SetControlMode(aControl);
1341 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1342 SMESH::RepaintCurrentView();
1343 #ifndef DISABLE_PLOT2DVIEWER
1344 if(anActor->GetPlot2Histogram()) {
1345 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1346 QString functorName = functorToString( anActor->GetFunctor());
1347 QString aHistogramName("%1 : %2");
1348 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1349 aHistogram->setName(aHistogramName);
1350 aHistogram->setHorTitle(functorName);
1351 SMESH::ProcessIn2DViewers(anActor);
1360 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1361 MeshObjectType theType,
1362 const QString theInTypeName,
1363 QString & theOutTypeName)
1365 SMESH_TypeFilter aTypeFilter( theType );
1367 if( !theIO.IsNull() )
1369 entry = theIO->getEntry();
1370 LightApp_DataOwner owner( entry );
1371 if ( aTypeFilter.isOk( &owner )) {
1372 theOutTypeName = theInTypeName;
1380 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1382 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1383 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1385 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1386 CORBA::String_var anID = aSComp->GetID().c_str();
1387 if (!strcmp(anID.in(),theIO->getEntry()))
1393 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1394 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1395 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1396 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1397 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1405 QString CheckHomogeneousSelection()
1407 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1408 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1409 SALOME_ListIO selected;
1411 aSel->selectedObjects( selected );
1413 QString RefType = CheckTypeObject(selected.First());
1414 SALOME_ListIteratorOfListIO It(selected);
1415 for ( ; It.More(); It.Next())
1417 Handle(SALOME_InteractiveObject) IObject = It.Value();
1418 QString Type = CheckTypeObject(IObject);
1419 if (Type.compare(RefType) != 0)
1420 return "Heterogeneous Selection";
1427 void SMESHGUI::OnEditDelete()
1429 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1430 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1431 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1433 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1434 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1435 _PTR(GenericAttribute) anAttr;
1436 _PTR(AttributeIOR) anIOR;
1438 int objectCount = 0;
1440 QString aParentComponent = QString::null;
1441 Handle(SALOME_InteractiveObject) anIO;
1442 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1444 anIO = anIt.Value();
1445 QString cur = anIO->getComponentDataType();
1446 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1448 // check if object is reference
1449 _PTR(SObject) aRefSObj;
1450 aNameList.append("\n - ");
1451 if ( aSO->ReferencedObject( aRefSObj ) ) {
1452 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1453 aNameList.append( aRefName );
1454 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1457 aNameList.append(anIO->getName());
1461 if( aParentComponent.isNull() )
1462 aParentComponent = cur;
1463 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1464 aParentComponent = "";
1467 if ( objectCount == 0 )
1468 return; // No Valid Objects Selected
1470 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1471 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1472 QObject::tr("ERR_ERROR"),
1473 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1476 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1477 if (SUIT_MessageBox::warning
1478 (SMESHGUI::desktop(),
1479 QObject::tr("SMESH_WRN_WARNING"),
1480 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1481 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1482 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1485 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1487 SALOME_ListIteratorOfListIO It(selected);
1489 aStudyBuilder->NewCommand(); // There is a transaction
1490 for( ; It.More(); It.Next()){ // loop on selected IO's
1491 Handle(SALOME_InteractiveObject) IObject = It.Value();
1492 if(IObject->hasEntry()) {
1493 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1495 // disable removal of "SMESH" component object
1496 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1498 if ( engineIOR() == anIOR->Value().c_str() )
1501 //Check the referenced object
1502 _PTR(SObject) aRefSObject;
1503 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1504 aSO = aRefSObject; // Delete main Object instead of reference
1506 // put the whole hierarchy of sub-objects of the selected SO into a list and
1507 // then treat them all starting from the deepest objects (at list back)
1509 std::list< _PTR(SObject) > listSO;
1510 listSO.push_back( aSO );
1511 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1512 for ( ; itSO != listSO.end(); ++itSO ) {
1513 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1514 for (it->InitEx(false); it->More(); it->Next())
1515 listSO.push_back( it->Value() );
1518 // treat SO's in the list starting from the back
1520 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1521 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1522 _PTR(SObject) SO = *ritSO;
1523 if ( !SO ) continue;
1524 std::string anEntry = SO->GetID();
1526 /** Erase graphical object **/
1527 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1528 ViewManagerList aViewMenegers = anApp->viewManagers();
1529 ViewManagerList::const_iterator it = aViewMenegers.begin();
1530 for( ; it != aViewMenegers.end(); it++) {
1531 SUIT_ViewManager* vm = *it;
1532 int nbSf = vm ? vm->getViewsCount() : 0;
1534 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1535 for(int i = 0; i < nbSf; i++){
1536 SUIT_ViewWindow *sf = aViews[i];
1537 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1538 SMESH::RemoveActor(sf,anActor);
1544 /** Remove an object from data structures **/
1545 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1546 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1547 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1548 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1549 aMesh->RemoveGroup( aGroup );
1551 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1552 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1553 aMesh->RemoveSubMesh( aSubMesh );
1555 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1557 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1560 IObject = new SALOME_InteractiveObject
1561 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1562 QString objType = CheckTypeObject(IObject);
1563 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1564 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1565 aStudyBuilder->RemoveObjectWithChildren( SO );
1567 else {// default action: remove SObject from the study
1568 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1569 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1571 aStudyBuilder->RemoveObjectWithChildren( SO );
1575 } /* listSO back loop */
1576 } /* IObject->hasEntry() */
1579 aStudyBuilder->CommitCommand();
1581 /* Clear any previous selection */
1583 aSel->setSelectedObjects( l1 );
1585 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1590 SMESHGUI_EXPORT CAM_Module* createModule()
1592 return new SMESHGUI();
1595 SMESHGUI_EXPORT char* getModuleVersion() {
1596 return (char*)SMESH_VERSION_STR;
1600 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1602 //=============================================================================
1606 //=============================================================================
1607 SMESHGUI::SMESHGUI() :
1608 SalomeApp_Module( "SMESH" ),
1609 LightApp_Module( "SMESH" )
1611 if ( CORBA::is_nil( myComponentSMESH ) )
1613 CORBA::Boolean anIsEmbeddedMode;
1614 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1615 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1617 // 0019923: EDF 765 SMESH : default values of hypothesis
1618 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1619 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1620 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1621 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1622 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1625 myActiveDialogBox = 0;
1626 myFilterLibraryDlg = 0;
1630 myEventCallbackCommand = vtkCallbackCommand::New();
1631 myEventCallbackCommand->Delete();
1632 myEventCallbackCommand->SetClientData( this );
1633 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1636 SMESH::GetFilterManager();
1637 SMESH::GetPattern();
1638 SMESH::GetMeasurements();
1640 /* load resources for all available meshers */
1641 SMESH::InitAvailableHypotheses();
1644 //=============================================================================
1648 //=============================================================================
1649 SMESHGUI::~SMESHGUI()
1651 #ifdef WITHGENERICOBJ
1652 SMESH::GetFilterManager()->UnRegister();
1653 SMESH::GetMeasurements()->UnRegister();
1655 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1656 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1659 //=============================================================================
1663 //=============================================================================
1664 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1666 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1668 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1673 //=============================================================================
1677 //=============================================================================
1678 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1680 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1684 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1685 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1686 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1687 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1688 return autoUpdate && !exceeded;
1691 //=============================================================================
1695 //=============================================================================
1696 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1698 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1701 //=============================================================================
1705 //=============================================================================
1706 SMESHGUI* SMESHGUI::GetSMESHGUI()
1708 SMESHGUI* smeshMod = 0;
1709 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1712 CAM_Module* module = app->module( "Mesh" );
1713 smeshMod = dynamic_cast<SMESHGUI*>( module );
1716 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1718 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1721 _PTR(Study) aStudy = study->studyDS();
1723 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1732 Standard_EXPORT SMESHGUI* GetComponentGUI()
1734 return SMESHGUI::GetSMESHGUI();
1738 //=============================================================================
1742 //=============================================================================
1743 void SMESHGUI::SetState(int aState)
1748 //=============================================================================
1752 //=============================================================================
1753 void SMESHGUI::ResetState()
1758 //=============================================================================
1762 //=============================================================================
1763 void SMESHGUI::EmitSignalDeactivateDialog()
1765 emit SignalDeactivateActiveDialog();
1768 //=============================================================================
1772 //=============================================================================
1773 void SMESHGUI::EmitSignalStudyFrameChanged()
1775 emit SignalStudyFrameChanged();
1778 //=============================================================================
1782 //=============================================================================
1783 void SMESHGUI::EmitSignalCloseAllDialogs()
1785 emit SignalCloseAllDialogs();
1788 //=============================================================================
1792 //=============================================================================
1793 void SMESHGUI::EmitSignalVisibilityChanged()
1795 emit SignalVisibilityChanged();
1798 //=============================================================================
1802 //=============================================================================
1803 QDialog *SMESHGUI::GetActiveDialogBox()
1805 return myActiveDialogBox;
1808 //=============================================================================
1812 //=============================================================================
1813 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1815 myActiveDialogBox = (QDialog *) aDlg;
1819 //=============================================================================
1823 //=============================================================================
1824 SUIT_Desktop* SMESHGUI::desktop()
1826 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1828 return app->desktop();
1833 //=============================================================================
1837 //=============================================================================
1838 SalomeApp_Study* SMESHGUI::activeStudy()
1840 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1842 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1847 //=============================================================================
1851 //=============================================================================
1852 void SMESHGUI::Modified( bool theIsUpdateActions )
1854 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1855 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1856 appStudy->Modified();
1857 if( theIsUpdateActions )
1858 app->updateActions();
1863 //=============================================================================
1867 //=============================================================================
1868 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1870 /* Here the position is on the bottom right corner - 10 */
1871 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1873 SUIT_Desktop *PP = desktop();
1874 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1875 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1879 //=============================================================================
1883 //=============================================================================
1884 static int isStudyLocked(_PTR(Study) theStudy){
1885 return theStudy->GetProperties()->IsLocked();
1888 static bool checkLock(_PTR(Study) theStudy) {
1889 if (isStudyLocked(theStudy)) {
1890 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1891 QObject::tr("WRN_WARNING"),
1892 QObject::tr("WRN_STUDY_LOCKED") );
1898 //=======================================================================
1899 //function : CheckActiveStudyLocked
1901 //=======================================================================
1903 bool SMESHGUI::isActiveStudyLocked()
1905 _PTR(Study) aStudy = activeStudy()->studyDS();
1906 return checkLock( aStudy );
1909 //=============================================================================
1913 //=============================================================================
1914 bool SMESHGUI::OnGUIEvent( int theCommandID )
1916 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1920 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1921 SUIT_ResourceMgr* mgr = resourceMgr();
1925 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1926 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1929 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1930 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
1932 //QAction* act = action( theCommandID );
1934 switch (theCommandID) {
1936 if(checkLock(aStudy)) break;
1946 if(checkLock(aStudy)) break;
1947 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
1951 case 150: //MED FILE INFORMATION
1953 SALOME_ListIO selected;
1954 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1956 aSel->selectedObjects( selected );
1957 if( selected.Extent() )
1959 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1960 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1961 if ( !aMesh->_is_nil() )
1963 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
1970 case 122: // EXPORT MED
1981 ::ExportMeshToFile(theCommandID);
1985 case 200: // SCALAR BAR
1987 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1988 SALOME_ListIO selected;
1990 aSel->selectedObjects( selected );
1992 if( selected.Extent() ) {
1993 Handle(SALOME_InteractiveObject) anIO = selected.First();
1994 if( anIO->hasEntry() ) {
1995 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
1996 anActor->SetControlMode( SMESH_Actor::eNone );
1997 #ifndef DISABLE_PLOT2DVIEWER
1998 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2007 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2012 // dump control distribution data to the text file
2013 ::SaveDistribution();
2019 // show/ distribution
2020 ::ShowDistribution();
2024 #ifndef DISABLE_PLOT2DVIEWER
2027 // plot distribution
2028 ::PlotDistribution();
2039 ::DisableAutoColor();
2042 case 1134: // Clipping
2043 case 1133: // Tranparency
2044 case 1132: // Colors / Size
2051 ::SetDisplayMode(theCommandID, myMarkerMap);
2054 //2D quadratic representation
2057 ::SetDisplayMode(theCommandID, myMarkerMap);
2061 case 216: // 0D elements
2064 case 219: // Volumes
2065 case 220: // All Entity
2066 ::SetDisplayEntity(theCommandID);
2069 case 221: // Orientation of faces
2071 LightApp_SelectionMgr* mgr = selectionMgr();
2072 SALOME_ListIO selected; mgr->selectedObjects( selected );
2074 SALOME_ListIteratorOfListIO it(selected);
2075 for( ; it.More(); it.Next()) {
2076 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2077 if(anIObject->hasEntry()) {
2078 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2079 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2088 if(checkLock(aStudy)) break;
2090 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2093 SMESH::UpdateView();
2095 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2096 SMESH::OnVisuException();
2098 catch (...) { // PAL16774 (Crash after display of many groups)
2099 SMESH::OnVisuException();
2103 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2104 aSel->selectedObjects( l );
2105 aSel->setSelectedObjects( l );
2110 case 301: // DISPLAY
2111 case 302: // DISPLAY ONLY
2113 SMESH::EDisplaing anAction;
2114 switch (theCommandID) {
2115 case 300: anAction = SMESH::eErase; break;
2116 case 301: anAction = SMESH::eDisplay; break;
2117 case 302: anAction = SMESH::eDisplayOnly; break;
2120 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2121 SALOME_ListIO sel_objects, to_process;
2123 aSel->selectedObjects( sel_objects );
2125 if( theCommandID==302 )
2127 MESSAGE("anAction = SMESH::eDisplayOnly");
2128 startOperation( myEraseAll );
2131 extractContainers( sel_objects, to_process );
2134 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2138 SALOME_ListIteratorOfListIO It( to_process );
2139 for ( ; It.More(); It.Next()) {
2141 Handle(SALOME_InteractiveObject) IOS = It.Value();
2142 if (IOS->hasEntry()) {
2144 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2145 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2146 break; // PAL16774 (Crash after display of many groups)
2148 if (anAction == SMESH::eDisplayOnly)
2150 MESSAGE("anAction = SMESH::eDisplayOnly");
2151 anAction = SMESH::eDisplay;
2157 // PAL13338 + PAL15161 -->
2158 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2159 MESSAGE("anAction = SMESH::eDisplayOnly");
2160 SMESH::UpdateView();
2161 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2163 // PAL13338 + PAL15161 <--
2165 catch (...) { // PAL16774 (Crash after display of many groups)
2166 SMESH::OnVisuException();
2169 if (anAction == SMESH::eErase) {
2170 MESSAGE("anAction == SMESH::eErase");
2172 aSel->setSelectedObjects( l1 );
2175 aSel->setSelectedObjects( to_process );
2182 if(checkLock(aStudy)) break;
2185 EmitSignalDeactivateDialog();
2187 ( new SMESHGUI_NodesDlg( this ) )->show();
2190 SUIT_MessageBox::warning(desktop(),
2191 tr("SMESH_WRN_WARNING"),
2192 tr("SMESH_WRN_VIEWER_VTK"));
2197 case 2151: // FILTER
2201 EmitSignalDeactivateDialog();
2202 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2207 case 701: // COMPUTE MESH
2208 case 711: // PRECOMPUTE MESH
2209 case 712: // EVALUATE MESH
2210 case 713: // MESH ORDER
2212 if (checkLock(aStudy)) break;
2213 startOperation( theCommandID );
2217 case 702: // Create mesh
2218 case 703: // Create sub-mesh
2219 case 704: // Edit mesh/sub-mesh
2220 startOperation( theCommandID );
2222 case 705: // copy mesh
2224 if (checkLock(aStudy)) break;
2225 EmitSignalDeactivateDialog();
2226 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2229 case 710: // Build compound mesh
2231 if (checkLock(aStudy)) break;
2232 EmitSignalDeactivateDialog();
2233 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2237 case 407: // DIAGONAL INVERSION
2238 case 408: // Delete diagonal
2242 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2243 tr( "NOT_A_VTK_VIEWER" ) );
2247 if ( checkLock( aStudy ) )
2250 /*Standard_Boolean aRes;
2251 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2252 if ( aMesh->_is_nil() )
2254 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2255 tr( "SMESH_BAD_SELECTION" ) );
2259 EmitSignalDeactivateDialog();
2260 if ( theCommandID == 407 )
2261 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2263 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2266 case 409: // Change orientation
2267 case 410: // Union of triangles
2268 case 411: // Cutting of quadrangles
2269 case 419: // Splitting volumes into tetrahedra
2273 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2274 tr( "NOT_A_VTK_VIEWER" ) );
2278 if ( checkLock( aStudy ) )
2281 EmitSignalDeactivateDialog();
2282 SMESHGUI_MultiEditDlg* aDlg = NULL;
2283 if ( theCommandID == 409 )
2284 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2285 else if ( theCommandID == 410 )
2286 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2287 else if ( theCommandID == 419 )
2288 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2290 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2295 case 412: // Smoothing
2297 if(checkLock(aStudy)) break;
2299 EmitSignalDeactivateDialog();
2300 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2303 SUIT_MessageBox::warning(desktop(),
2304 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2308 case 413: // Extrusion
2310 if (checkLock(aStudy)) break;
2312 EmitSignalDeactivateDialog();
2313 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2315 SUIT_MessageBox::warning(desktop(),
2316 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2320 case 414: // Revolution
2322 if(checkLock(aStudy)) break;
2324 EmitSignalDeactivateDialog();
2325 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2328 SUIT_MessageBox::warning(desktop(),
2329 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2333 case 415: // Pattern mapping
2335 if ( checkLock( aStudy ) )
2339 EmitSignalDeactivateDialog();
2340 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2343 SUIT_MessageBox::warning(desktop(),
2344 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2348 case 416: // Extrusion along a path
2350 if (checkLock(aStudy)) break;
2352 EmitSignalDeactivateDialog();
2353 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2355 SUIT_MessageBox::warning(desktop(),
2356 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2360 case 417: // Convert mesh to quadratic
2362 startOperation( 417 );
2363 /* if (checkLock(aStudy)) break;
2365 EmitSignalDeactivateDialog();
2366 new SMESHGUI_ConvToQuadDlg();
2368 SUIT_MessageBox::warning(desktop(),
2369 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2373 case 418: // create 2D mesh from 3D
2375 startOperation( 418 );
2378 case 806: // CREATE GEO GROUP
2380 startOperation( 806 );
2383 case 801: // CREATE GROUP
2387 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2388 tr( "NOT_A_VTK_VIEWER" ) );
2392 if(checkLock(aStudy)) break;
2393 EmitSignalDeactivateDialog();
2394 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2396 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2397 SALOME_ListIO selected;
2399 aSel->selectedObjects( selected );
2401 int nbSel = selected.Extent();
2403 // check if mesh is selected
2404 aMesh = SMESH::GetMeshByIO( selected.First() );
2406 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2411 case 802: // CONSTRUCT GROUP
2415 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2416 tr( "NOT_A_VTK_VIEWER" ) );
2420 if(checkLock(aStudy)) break;
2421 EmitSignalDeactivateDialog();
2423 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2424 SALOME_ListIO selected;
2426 aSel->selectedObjects( selected );
2428 int nbSel = selected.Extent();
2430 // check if submesh is selected
2431 Handle(SALOME_InteractiveObject) IObject = selected.First();
2432 if (IObject->hasEntry()) {
2433 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2435 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2436 if (!aSubMesh->_is_nil()) {
2438 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2439 // get submesh elements list by types
2440 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2441 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2442 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2443 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2444 // create group for each type o elements
2445 QString aName = IObject->getName();
2446 QStringList anEntryList;
2447 if (aNodes->length() > 0) {
2448 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2449 aGroup->Add(aNodes.inout());
2450 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2451 anEntryList.append( aSObject->GetID().c_str() );
2453 if (aEdges->length() > 0) {
2454 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2455 aGroup->Add(aEdges.inout());
2456 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2457 anEntryList.append( aSObject->GetID().c_str() );
2459 if (aFaces->length() > 0) {
2460 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2461 aGroup->Add(aFaces.inout());
2462 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2463 anEntryList.append( aSObject->GetID().c_str() );
2465 if (aVolumes->length() > 0) {
2466 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2467 aGroup->Add(aVolumes.inout());
2468 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2469 anEntryList.append( aSObject->GetID().c_str() );
2472 anApp->browseObjects( anEntryList );
2474 catch(const SALOME::SALOME_Exception & S_ex){
2475 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2482 SUIT_MessageBox::warning(desktop(),
2483 tr("SMESH_WRN_WARNING"),
2484 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2489 case 803: // EDIT GROUP
2493 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2494 tr( "NOT_A_VTK_VIEWER" ) );
2498 if(checkLock(aStudy)) break;
2499 EmitSignalDeactivateDialog();
2501 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2502 SALOME_ListIO selected;
2504 aSel->selectedObjects( selected );
2506 SALOME_ListIteratorOfListIO It (selected);
2507 int nbSelectedGroups = 0;
2508 for ( ; It.More(); It.Next() )
2510 SMESH::SMESH_GroupBase_var aGroup =
2511 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2512 if (!aGroup->_is_nil()) {
2514 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2518 if (nbSelectedGroups == 0)
2520 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2526 case 804: // Add elements to group
2528 if(checkLock(aStudy)) break;
2529 if (myState == 800) {
2530 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2531 if (aDlg) aDlg->onAdd();
2536 case 805: // Remove elements from group
2538 if(checkLock(aStudy)) break;
2539 if (myState == 800) {
2540 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2541 if (aDlg) aDlg->onRemove();
2546 case 815: // Edit GEOM GROUP as standalone
2550 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2551 tr( "NOT_A_VTK_VIEWER" ) );
2555 if(checkLock(aStudy)) break;
2556 EmitSignalDeactivateDialog();
2558 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2559 SALOME_ListIO selected;
2561 aSel->selectedObjects( selected );
2563 SALOME_ListIteratorOfListIO It (selected);
2564 for ( ; It.More(); It.Next() )
2566 SMESH::SMESH_GroupOnGeom_var aGroup =
2567 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2568 if (!aGroup->_is_nil()) {
2569 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2574 SMESH::SMESH_GroupOnFilter_var aGroup =
2575 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2576 if (!aGroup->_is_nil()) {
2577 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2585 case 810: // Union Groups
2586 case 811: // Intersect groups
2587 case 812: // Cut groups
2591 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2592 tr( "NOT_A_VTK_VIEWER" ) );
2596 if ( checkLock( aStudy ) )
2599 EmitSignalDeactivateDialog();
2601 SMESHGUI_GroupOpDlg* aDlg = 0;
2602 if ( theCommandID == 810 )
2603 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2604 else if ( theCommandID == 811 )
2605 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2607 aDlg = new SMESHGUI_CutGroupsDlg( this );
2614 case 814: // Create groups of entities from existing groups of superior dimensions
2616 if ( checkLock( aStudy ) )
2619 EmitSignalDeactivateDialog();
2620 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2626 case 813: // Delete groups with their contents
2630 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2631 tr( "NOT_A_VTK_VIEWER" ) );
2635 if ( checkLock( aStudy ) )
2638 EmitSignalDeactivateDialog();
2640 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2644 case 900: // MESH INFOS
2645 case 903: // WHAT IS
2647 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2648 EmitSignalDeactivateDialog();
2649 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2650 SALOME_ListIO selected;
2652 aSel->selectedObjects( selected );
2654 if ( selected.Extent() > 1 ) { // a dlg for each IO
2655 SALOME_ListIteratorOfListIO It( selected );
2656 for ( ; It.More(); It.Next() ) {
2657 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2658 dlg->showInfo( It.Value() );
2663 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2669 case 902: // STANDARD MESH INFOS
2671 EmitSignalDeactivateDialog();
2672 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2673 SALOME_ListIO selected;
2675 aSel->selectedObjects( selected );
2677 if ( selected.Extent() > 1 ) { // a dlg for each IO
2679 SALOME_ListIteratorOfListIO It (selected);
2680 for ( ; It.More(); It.Next() ) {
2682 IOs.Append( It.Value() );
2683 aSel->setSelectedObjects( IOs );
2684 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2686 // restore selection
2687 aSel->setSelectedObjects( selected );
2690 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2693 case 903: // WHAT IS
2695 EmitSignalDeactivateDialog();
2696 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2701 case 904: // FIND ELEM
2703 startOperation( theCommandID );
2707 case 1100: // EDIT HYPOTHESIS
2709 if(checkLock(aStudy)) break;
2711 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2712 SALOME_ListIO selected;
2714 aSel->selectedObjects( selected );
2716 int nbSel = selected.Extent();
2719 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2720 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2722 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2723 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2724 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2725 if ( !aHypothesis->_is_nil() )
2728 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2729 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2731 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2741 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2743 if(checkLock(aStudy)) break;
2744 SUIT_OverrideCursor wc;
2746 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2747 SALOME_ListIO selected;
2749 aSel->selectedObjects( selected, QString::null, false );
2751 SALOME_ListIteratorOfListIO It(selected);
2752 for (int i = 0; It.More(); It.Next(), i++) {
2753 Handle(SALOME_InteractiveObject) IObject = It.Value();
2754 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2757 aSel->setSelectedObjects( l1 );
2762 case 4009: // ELEM0D
2763 case 4010: // GEOM::EDGE
2764 case 4021: // TRIANGLE
2766 case 4023: // POLYGON
2770 if(checkLock(aStudy)) break;
2772 EmitSignalDeactivateDialog();
2773 SMDSAbs_ElementType type = SMDSAbs_Edge;
2775 switch (theCommandID) {
2776 case 4009: // ELEM0D
2777 type = SMDSAbs_0DElement; nbNodes = 1; break;
2778 case 4021: // TRIANGLE
2779 type = SMDSAbs_Face; nbNodes = 3; break;
2781 type = SMDSAbs_Face; nbNodes = 4; break;
2783 type = SMDSAbs_Volume; nbNodes = 4; break;
2784 case 4023: // POLYGON
2785 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2787 type = SMDSAbs_Volume; nbNodes = 8; break;
2788 case 4033: // POLYHEDRE
2789 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2792 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2795 SUIT_MessageBox::warning(desktop(),
2796 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2800 case 4033: // POLYHEDRON
2802 if(checkLock(aStudy)) break;
2804 EmitSignalDeactivateDialog();
2805 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2808 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2809 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2813 case 4034: // QUADRATIC EDGE
2814 case 4035: // QUADRATIC TRIANGLE
2815 case 4036: // QUADRATIC QUADRANGLE
2816 case 4037: // QUADRATIC TETRAHEDRON
2817 case 4038: // QUADRATIC PYRAMID
2818 case 4039: // QUADRATIC PENTAHEDRON
2819 case 4040: // QUADRATIC HEXAHEDRON
2821 if(checkLock(aStudy)) break;
2823 EmitSignalDeactivateDialog();
2826 switch (theCommandID) {
2828 type = QUAD_EDGE; break;
2830 type = QUAD_TRIANGLE; break;
2832 type = QUAD_QUADRANGLE; break;
2834 type = QUAD_TETRAHEDRON; break;
2836 type = QUAD_PYRAMID; break;
2838 type = QUAD_PENTAHEDRON; break;
2840 type = QUAD_HEXAHEDRON;
2844 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2847 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2848 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2852 case 4041: // REMOVES NODES
2854 if(checkLock(aStudy)) break;
2856 EmitSignalDeactivateDialog();
2857 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2860 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2861 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2865 case 4042: // REMOVES ELEMENTS
2867 if(checkLock(aStudy)) break;
2869 EmitSignalDeactivateDialog();
2870 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2874 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2875 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2879 case 4043: { // CLEAR_MESH
2881 if(checkLock(aStudy)) break;
2883 SALOME_ListIO selected;
2884 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2885 aSel->selectedObjects( selected );
2887 SUIT_OverrideCursor wc;
2888 SALOME_ListIteratorOfListIO It (selected);
2889 for ( ; It.More(); It.Next() )
2891 Handle(SALOME_InteractiveObject) IOS = It.Value();
2892 SMESH::SMESH_Mesh_var aMesh =
2893 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2894 if ( aMesh->_is_nil()) continue;
2896 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2898 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2899 SMESH::ModifiedMesh( aMeshSObj, false, true);
2900 // hide groups and submeshes
2901 _PTR(ChildIterator) anIter =
2902 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2903 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2905 _PTR(SObject) so = anIter->Value();
2906 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2909 catch (const SALOME::SALOME_Exception& S_ex){
2911 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2915 SMESH::UpdateView();
2919 case 4044: // REMOVE ORPHAN NODES
2921 if(checkLock(aStudy)) break;
2922 SALOME_ListIO selected;
2923 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2924 aSel->selectedObjects( selected );
2925 if ( selected.Extent() == 1 ) {
2926 Handle(SALOME_InteractiveObject) anIO = selected.First();
2927 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2928 if ( !aMesh->_is_nil() ) {
2929 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2930 tr( "SMESH_WARNING" ),
2931 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2932 SUIT_MessageBox::Yes |
2933 SUIT_MessageBox::No,
2934 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2937 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2938 int removed = aMeshEditor->RemoveOrphanNodes();
2939 SUIT_MessageBox::information(SMESHGUI::desktop(),
2940 tr("SMESH_INFORMATION"),
2941 tr("NB_NODES_REMOVED").arg(removed));
2942 if ( removed > 0 ) {
2943 SMESH::UpdateView();
2944 SMESHGUI::Modified();
2947 catch (const SALOME::SALOME_Exception& S_ex) {
2948 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2957 case 4051: // RENUMBERING NODES
2959 if(checkLock(aStudy)) break;
2961 EmitSignalDeactivateDialog();
2962 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
2966 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2967 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2971 case 4052: // RENUMBERING ELEMENTS
2973 if(checkLock(aStudy)) break;
2975 EmitSignalDeactivateDialog();
2976 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
2980 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2981 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2985 case 4061: // TRANSLATION
2987 if(checkLock(aStudy)) break;
2989 EmitSignalDeactivateDialog();
2990 ( new SMESHGUI_TranslationDlg( this ) )->show();
2993 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2994 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2998 case 4062: // ROTATION
3000 if(checkLock(aStudy)) break;
3002 EmitSignalDeactivateDialog();
3003 ( new SMESHGUI_RotationDlg( this ) )->show();
3006 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3007 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3011 case 4063: // SYMMETRY
3013 if(checkLock(aStudy)) break;
3015 EmitSignalDeactivateDialog();
3016 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3019 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3020 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3024 case 4064: // SEWING
3026 if(checkLock(aStudy)) break;
3028 EmitSignalDeactivateDialog();
3029 ( new SMESHGUI_SewingDlg( this ) )->show();
3032 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3033 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3037 case 4065: // MERGE NODES
3039 if(checkLock(aStudy)) break;
3041 EmitSignalDeactivateDialog();
3042 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3045 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3046 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3050 case 4066: // MERGE EQUAL ELEMENTS
3052 if (checkLock(aStudy)) break;
3054 EmitSignalDeactivateDialog();
3055 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3057 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3058 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3063 case 4067: // MAKE MESH PASS THROUGH POINT
3064 startOperation( 4067 );
3069 if(checkLock(aStudy)) break;
3071 EmitSignalDeactivateDialog();
3072 ( new SMESHGUI_ScaleDlg( this ) )->show();
3075 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3076 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3081 case 4069: // DUPLICATE NODES
3083 if(checkLock(aStudy)) break;
3085 EmitSignalDeactivateDialog();
3086 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3089 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3090 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3095 case 5105: // Library of selection filters
3097 static QList<int> aTypes;
3098 if ( aTypes.isEmpty() )
3100 aTypes.append( SMESH::NODE );
3101 aTypes.append( SMESH::EDGE );
3102 aTypes.append( SMESH::FACE );
3103 aTypes.append( SMESH::VOLUME );
3105 if (!myFilterLibraryDlg)
3106 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3107 else if (myFilterLibraryDlg->isHidden())
3108 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3109 myFilterLibraryDlg->raise();
3113 case 6017: // CONTROLS
3137 LightApp_SelectionMgr* mgr = selectionMgr();
3138 SALOME_ListIO selected; mgr->selectedObjects( selected );
3140 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3141 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3143 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3144 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3145 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3146 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3147 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3148 ::Control( theCommandID );
3153 SUIT_MessageBox::warning(desktop(),
3154 tr( "SMESH_WRN_WARNING" ),
3155 tr( "SMESH_BAD_SELECTION" ) );
3159 SUIT_MessageBox::warning(desktop(),
3160 tr( "SMESH_WRN_WARNING" ),
3161 tr( "NOT_A_VTK_VIEWER" ) );
3166 LightApp_SelectionMgr* mgr = selectionMgr();
3167 SALOME_ListIO selected; mgr->selectedObjects( selected );
3169 SALOME_ListIteratorOfListIO it(selected);
3170 for( ; it.More(); it.Next()) {
3171 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3172 if(anIObject->hasEntry()) {
3173 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3174 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3182 LightApp_SelectionMgr* mgr = selectionMgr();
3183 SALOME_ListIO selected; mgr->selectedObjects( selected );
3185 SALOME_ListIteratorOfListIO it(selected);
3186 for( ; it.More(); it.Next()) {
3187 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3188 if(anIObject->hasEntry())
3189 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3190 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3198 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3199 EmitSignalDeactivateDialog();
3200 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3206 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3207 //updateObjBrowser();
3211 //=============================================================================
3215 //=============================================================================
3216 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3221 //=============================================================================
3225 //=============================================================================
3226 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3231 //=============================================================================
3235 //=============================================================================
3236 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3241 //=============================================================================
3242 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3243 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3245 //=============================================================================
3246 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3247 SUIT_ViewWindow* wnd )
3249 if(theIO->hasEntry()){
3250 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3251 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3255 //=======================================================================
3256 // function : createSMESHAction
3258 //=======================================================================
3259 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3260 const int key, const bool toggle, const QString& shortcutAction )
3263 QWidget* parent = application()->desktop();
3264 SUIT_ResourceMgr* resMgr = resourceMgr();
3266 if ( !icon_id.isEmpty() )
3267 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3269 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3270 if ( !pix.isNull() )
3271 icon = QIcon( pix );
3273 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3274 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3275 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3277 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3278 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3281 //=======================================================================
3282 // function : createPopupItem
3284 //=======================================================================
3285 void SMESHGUI::createPopupItem( const int id,
3286 const QString& clients,
3287 const QString& types,
3288 const QString& theRule,
3293 parentId = popupMgr()->actionId( action( pId ) );
3295 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3296 popupMgr()->insert( action( id ), parentId, 0 );
3298 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3299 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3300 QString rule = "(%1) and (%2) and (%3)";
3301 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3302 if( clients.isEmpty() )
3303 rule = rule.arg( QString( "true" ) );
3305 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3306 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3309 bool cont = myRules.contains( id );
3311 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3313 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3314 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3317 //=======================================================================
3318 // function : initialize
3320 //=======================================================================
3321 void SMESHGUI::initialize( CAM_Application* app )
3323 SalomeApp_Module::initialize( app );
3325 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3327 /* Automatic Update flag */
3328 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3330 // ----- create actions --------------
3332 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3333 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3334 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3335 createSMESHAction( 114, "NUM" );
3336 createSMESHAction( 115, "STL" );
3337 createSMESHAction( 116, "CGNS" );
3338 createSMESHAction( 121, "DAT" );
3339 createSMESHAction( 122, "MED" );
3340 createSMESHAction( 123, "UNV" );
3341 createSMESHAction( 140, "STL" );
3342 createSMESHAction( 142, "CGNS" );
3343 createSMESHAction( 124, "EXPORT_DAT" );
3344 createSMESHAction( 125, "EXPORT_MED" );
3345 createSMESHAction( 126, "EXPORT_UNV" );
3346 createSMESHAction( 141, "EXPORT_STL" );
3347 createSMESHAction( 143, "EXPORT_CGNS" );
3348 createSMESHAction( 150, "FILE_INFO" );
3349 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3350 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3351 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3352 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3353 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3354 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3355 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3356 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3357 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3358 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3359 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3360 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3361 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3362 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3363 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3364 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3365 createSMESHAction( 804, "ADD" );
3366 createSMESHAction( 805, "REMOVE" );
3367 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3368 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3369 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3370 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3371 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3372 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3373 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3374 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3375 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3376 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3377 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3378 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3379 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3380 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3381 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3382 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3383 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3384 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3385 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3386 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3387 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3388 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3389 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3390 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3391 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3392 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3393 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3394 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3395 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3396 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3397 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3398 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3399 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3400 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3401 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3402 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3403 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3404 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3405 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3406 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3407 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3408 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3409 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3410 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3411 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3412 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3413 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3414 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3415 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3416 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3417 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3418 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3419 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3420 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3421 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3422 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3423 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3424 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3425 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3426 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3427 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3428 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3429 createSMESHAction( 415, "MAP", "ICON_MAP" );
3430 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3431 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3432 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3433 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3434 createSMESHAction( 200, "RESET" );
3435 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3436 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3437 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3438 #ifndef DISABLE_PLOT2DVIEWER
3439 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3441 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3442 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3443 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3444 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3445 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3446 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3447 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3448 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3449 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3450 createSMESHAction( 220, "ALL" );
3451 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3453 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3454 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3456 createSMESHAction( 1100, "EDIT_HYPO" );
3457 createSMESHAction( 1102, "UNASSIGN" );
3458 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3459 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3460 createSMESHAction( 1131, "DISPMODE" );
3461 createSMESHAction( 1132, "COLORS" );
3462 createSMESHAction( 1133, "TRANSP" );
3463 createSMESHAction( 1134, "CLIP" );
3464 createSMESHAction( 1135, "DISP_ENT" );
3465 createSMESHAction( 1136, "AUTO_COLOR" );
3466 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3467 createSMESHAction( 2000, "CTRL" );
3469 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3470 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3472 createSMESHAction( 300, "ERASE" );
3473 createSMESHAction( 301, "DISPLAY" );
3474 createSMESHAction( 302, "DISPLAY_ONLY" );
3475 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3476 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3477 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3478 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3479 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3480 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3481 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3482 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3484 // ----- create menu --------------
3485 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3486 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3487 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3488 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3489 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3490 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3491 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3492 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3494 createMenu( separator(), fileId );
3496 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3497 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3498 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3499 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3500 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3501 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3502 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3503 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3504 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3505 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3507 createMenu( 111, importId, -1 );
3508 createMenu( 112, importId, -1 );
3509 createMenu( 113, importId, -1 );
3510 createMenu( 115, importId, -1 );
3512 createMenu( 116, importId, -1 );
3514 createMenu( 121, exportId, -1 );
3515 createMenu( 122, exportId, -1 );
3516 createMenu( 123, exportId, -1 );
3517 createMenu( 140, exportId, -1 ); // export to STL
3519 createMenu( 142, exportId, -1 ); // export to CGNS
3521 createMenu( separator(), fileId, 10 );
3523 createMenu( 33, editId, -1 );
3525 createMenu( 5105, toolsId, -1 );
3527 createMenu( 702, meshId, -1 ); // "Mesh" menu
3528 createMenu( 703, meshId, -1 );
3529 createMenu( 704, meshId, -1 );
3530 createMenu( 710, meshId, -1 );
3531 createMenu( 705, meshId, -1 );
3532 createMenu( separator(), meshId, -1 );
3533 createMenu( 701, meshId, -1 );
3534 createMenu( 711, meshId, -1 );
3535 createMenu( 712, meshId, -1 );
3536 createMenu( 713, meshId, -1 );
3537 createMenu( separator(), meshId, -1 );
3538 createMenu( 801, meshId, -1 );
3539 createMenu( 806, meshId, -1 );
3540 createMenu( 802, meshId, -1 );
3541 createMenu( 803, meshId, -1 );
3542 createMenu( 815, meshId, -1 );
3543 createMenu( separator(), meshId, -1 );
3544 createMenu( 810, meshId, -1 );
3545 createMenu( 811, meshId, -1 );
3546 createMenu( 812, meshId, -1 );
3547 createMenu( separator(), meshId, -1 );
3548 createMenu( 814, meshId, -1 );
3549 createMenu( separator(), meshId, -1 );
3550 createMenu( 900, meshId, -1 );
3551 //createMenu( 902, meshId, -1 );
3552 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3553 createMenu( 904, meshId, -1 );
3554 createMenu( separator(), meshId, -1 );
3556 createMenu( 6005, nodeId, -1 );
3557 createMenu( 6002, edgeId, -1 );
3558 createMenu( 6003, edgeId, -1 );
3559 createMenu( 6001, edgeId, -1 );
3560 createMenu( 6004, edgeId, -1 );
3561 createMenu( 6021, faceId, -1 );
3562 createMenu( 6025, faceId, -1 );
3563 createMenu( 6027, faceId, -1 );
3564 createMenu( 6018, faceId, -1 );
3565 createMenu( 6019, faceId, -1 );
3566 createMenu( 6011, faceId, -1 );
3567 createMenu( 6012, faceId, -1 );
3568 createMenu( 6013, faceId, -1 );
3569 createMenu( 6014, faceId, -1 );
3570 createMenu( 6015, faceId, -1 );
3571 createMenu( 6016, faceId, -1 );
3572 createMenu( 6022, faceId, -1 );
3573 createMenu( 6017, volumeId, -1 );
3574 createMenu( 6009, volumeId, -1 );
3575 createMenu( 6023, volumeId, -1 );
3576 createMenu( 6024, volumeId, -1 );
3577 createMenu( 6026, volumeId, -1 );
3579 createMenu( 4000, addId, -1 );
3580 createMenu( 4009, addId, -1 );
3581 createMenu( 4010, addId, -1 );
3582 createMenu( 4021, addId, -1 );
3583 createMenu( 4022, addId, -1 );
3584 createMenu( 4023, addId, -1 );
3585 createMenu( 4031, addId, -1 );
3586 createMenu( 4032, addId, -1 );
3587 createMenu( 4033, addId, -1 );
3588 createMenu( separator(), addId, -1 );
3589 createMenu( 4034, addId, -1 );
3590 createMenu( 4035, addId, -1 );
3591 createMenu( 4036, addId, -1 );
3592 createMenu( 4037, addId, -1 );
3593 createMenu( 4038, addId, -1 );
3594 createMenu( 4039, addId, -1 );
3595 createMenu( 4040, addId, -1 );
3597 createMenu( 4041, removeId, -1 );
3598 createMenu( 4042, removeId, -1 );
3599 createMenu( 4044, removeId, -1 );
3600 createMenu( separator(), removeId, -1 );
3601 createMenu( 813, removeId, -1 );
3602 createMenu( separator(), removeId, -1 );
3603 createMenu( 4043, removeId, -1 );
3605 createMenu( 4051, renumId, -1 );
3606 createMenu( 4052, renumId, -1 );
3608 createMenu( 4061, transfId, -1 );
3609 createMenu( 4062, transfId, -1 );
3610 createMenu( 4063, transfId, -1 );
3611 createMenu( 4068, transfId, -1 );
3612 createMenu( 4064, transfId, -1 );
3613 createMenu( 4065, transfId, -1 );
3614 createMenu( 4066, transfId, -1 );
3615 createMenu( 4069, transfId, -1 );
3617 createMenu( 4067,modifyId, -1 );
3618 createMenu( 407, modifyId, -1 );
3619 createMenu( 408, modifyId, -1 );
3620 createMenu( 409, modifyId, -1 );
3621 createMenu( 410, modifyId, -1 );
3622 createMenu( 411, modifyId, -1 );
3623 createMenu( 419, modifyId, -1 );
3624 createMenu( 412, modifyId, -1 );
3625 createMenu( 413, modifyId, -1 );
3626 createMenu( 416, modifyId, -1 );
3627 createMenu( 414, modifyId, -1 );
3628 createMenu( 415, modifyId, -1 );
3629 createMenu( 417, modifyId, -1 );
3630 createMenu( 418, modifyId, -1 );
3632 createMenu( 501, measureId, -1 );
3633 createMenu( 502, measureId, -1 );
3634 createMenu( 214, viewId, -1 );
3636 // ----- create toolbars --------------
3637 int meshTb = createTool( tr( "TB_MESH" ) ),
3638 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3639 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3640 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3641 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3643 createTool( 702, meshTb );
3644 createTool( 703, meshTb );
3645 createTool( 704, meshTb );
3646 createTool( 710, meshTb );
3647 createTool( 705, meshTb );
3648 createTool( separator(), meshTb );
3649 createTool( 701, meshTb );
3650 createTool( 711, meshTb );
3651 createTool( 712, meshTb );
3652 createTool( 713, meshTb );
3653 createTool( separator(), meshTb );
3654 createTool( 801, meshTb );
3655 createTool( 806, meshTb );
3656 createTool( 802, meshTb );
3657 createTool( 803, meshTb );
3658 //createTool( 815, meshTb );
3659 createTool( separator(), meshTb );
3660 createTool( 900, meshTb );
3661 //createTool( 902, meshTb );
3662 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3663 createTool( 904, meshTb );
3664 createTool( separator(), meshTb );
3666 createTool( 6005, ctrlTb );
3667 createTool( separator(), ctrlTb );
3668 createTool( 6002, ctrlTb );
3669 createTool( 6003, ctrlTb );
3670 createTool( 6001, ctrlTb );
3671 createTool( 6004, ctrlTb );
3672 createTool( separator(), ctrlTb );
3673 createTool( 6021, ctrlTb );
3674 createTool( 6025, ctrlTb );
3675 createTool( 6027, ctrlTb );
3676 createTool( 6018, ctrlTb );
3677 createTool( 6019, ctrlTb );
3678 createTool( 6011, ctrlTb );
3679 createTool( 6012, ctrlTb );
3680 createTool( 6013, ctrlTb );
3681 createTool( 6014, ctrlTb );
3682 createTool( 6015, ctrlTb );
3683 createTool( 6016, ctrlTb );
3684 createTool( 6022, ctrlTb );
3685 createTool( separator(), ctrlTb );
3686 createTool( 6017, ctrlTb );
3687 createTool( 6009, ctrlTb );
3688 createTool( 6023, ctrlTb );
3689 createTool( 6024, ctrlTb );
3690 createTool( 6026, ctrlTb );
3691 createTool( separator(), ctrlTb );
3693 createTool( 4000, addRemTb );
3694 createTool( 4009, addRemTb );
3695 createTool( 4010, addRemTb );
3696 createTool( 4021, addRemTb );
3697 createTool( 4022, addRemTb );
3698 createTool( 4023, addRemTb );
3699 createTool( 4031, addRemTb );
3700 createTool( 4032, addRemTb );
3701 createTool( 4033, addRemTb );
3702 createTool( separator(), addRemTb );
3703 createTool( 4034, addRemTb );
3704 createTool( 4035, addRemTb );
3705 createTool( 4036, addRemTb );
3706 createTool( 4037, addRemTb );
3707 createTool( 4038, addRemTb );
3708 createTool( 4039, addRemTb );
3709 createTool( 4040, addRemTb );
3710 createTool( separator(), addRemTb );
3711 createTool( 4041, addRemTb );
3712 createTool( 4042, addRemTb );
3713 createTool( 4044, addRemTb );
3714 createTool( 4043, addRemTb );
3715 createTool( separator(), addRemTb );
3716 createTool( 4051, addRemTb );
3717 createTool( 4052, addRemTb );
3718 createTool( separator(), addRemTb );
3719 createTool( 4061, addRemTb );
3720 createTool( 4062, addRemTb );
3721 createTool( 4063, addRemTb );
3722 createTool( 4068, addRemTb );
3723 createTool( 4064, addRemTb );
3724 createTool( 4065, addRemTb );
3725 createTool( 4066, addRemTb );
3726 createTool( 4069, addRemTb );
3727 createTool( separator(), addRemTb );
3729 createTool( 4067,modifyTb );
3730 createTool( 407, modifyTb );
3731 createTool( 408, modifyTb );
3732 createTool( 409, modifyTb );
3733 createTool( 410, modifyTb );
3734 createTool( 411, modifyTb );
3735 createTool( 419, modifyTb );
3736 createTool( 412, modifyTb );
3737 createTool( 413, modifyTb );
3738 createTool( 416, modifyTb );
3739 createTool( 414, modifyTb );
3740 createTool( 415, modifyTb );
3741 createTool( 417, modifyTb );
3742 createTool( 418, modifyTb );
3744 createTool( 214, dispModeTb );
3746 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3747 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3750 QString OB = "'ObjectBrowser'",
3751 View = "'" + SVTK_Viewer::Type() + "'",
3753 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3754 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3755 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3756 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3757 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3758 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3759 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3760 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3761 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3762 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3763 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3765 mesh_part = mesh + " " + subMesh + " " + group,
3766 mesh_group = mesh + " " + group,
3767 hyp_alg = hypo + " " + algo;
3769 // popup for object browser
3771 isInvisible("not( isVisible )"),
3772 isEmpty("numberOfNodes = 0"),
3773 isNotEmpty("numberOfNodes <> 0"),
3775 // has nodes, edges, etc in VISIBLE! actor
3776 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3777 hasElems("(count( elemTypes ) > 0)"),
3778 hasDifferentElems("(count( elemTypes ) > 1)"),
3779 hasElems0d("({'Elem0d'} in elemTypes)"),
3780 hasEdges("({'Edge'} in elemTypes)"),
3781 hasFaces("({'Face'} in elemTypes)"),
3782 hasVolumes("({'Volume'} in elemTypes)");
3784 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3785 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3786 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3787 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3788 createPopupItem( 803, OB, group ); // EDIT_GROUP
3789 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3791 popupMgr()->insert( separator(), -1, 0 );
3792 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3793 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3794 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3795 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3796 createPopupItem( 214, OB, mesh_part ); // UPDATE
3797 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3798 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3799 popupMgr()->insert( separator(), -1, 0 );
3800 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3801 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3802 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3803 popupMgr()->insert( separator(), -1, 0 );
3804 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3805 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3806 popupMgr()->insert( separator(), -1, 0 );
3807 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3808 popupMgr()->insert( separator(), -1, 0 );
3809 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3810 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3812 popupMgr()->insert( separator(), -1, 0 );
3814 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3815 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3816 QString only_one_2D = only_one_non_empty + " && dim>1";
3818 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3819 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3820 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3822 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3824 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3825 popupMgr()->insert( separator(), -1, 0 );
3828 createPopupItem( 803, View, group ); // EDIT_GROUP
3829 createPopupItem( 804, View, elems ); // ADD
3830 createPopupItem( 805, View, elems ); // REMOVE
3832 popupMgr()->insert( separator(), -1, 0 );
3833 createPopupItem( 214, View, mesh_part ); // UPDATE
3834 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3835 createPopupItem( 904, View, mesh ); // FIND_ELEM
3836 popupMgr()->insert( separator(), -1, 0 );
3838 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3839 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3840 popupMgr()->insert( separator(), -1, 0 );
3843 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3844 QString aType = QString( "%1type in {%2}" ).arg( lc );
3845 aType = aType.arg( mesh_part );
3846 QString aMeshInVTK = aClient + "&&" + aType;
3848 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3849 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3850 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3852 //-------------------------------------------------
3854 //-------------------------------------------------
3855 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3857 popupMgr()->insert( action( 9010 ), anId, -1 );
3858 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3859 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3861 popupMgr()->insert( action( 9011 ), anId, -1 );
3862 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3863 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3865 popupMgr()->insert( separator(), -1, -1 );
3867 //-------------------------------------------------
3869 //-------------------------------------------------
3870 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3872 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3873 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3874 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3876 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3877 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3878 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3880 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3881 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3882 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3884 popupMgr()->insert( separator(), anId, -1 );
3886 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3887 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3888 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3890 //-------------------------------------------------
3892 //-------------------------------------------------
3893 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3895 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3897 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3898 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3899 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3901 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3902 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3903 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3905 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3906 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3907 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3909 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3910 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3911 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3913 popupMgr()->insert( separator(), anId, -1 );
3915 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3916 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3919 //-------------------------------------------------
3920 // Representation of the 2D Quadratic elements
3921 //-------------------------------------------------
3922 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3923 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3924 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3925 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3927 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3928 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3929 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3931 //-------------------------------------------------
3932 // Orientation of faces
3933 //-------------------------------------------------
3934 popupMgr()->insert( action( 221 ), -1, -1 );
3935 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3936 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3938 //-------------------------------------------------
3940 //-------------------------------------------------
3941 popupMgr()->insert( action( 1132 ), -1, -1 );
3942 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3944 //-------------------------------------------------
3946 //-------------------------------------------------
3947 popupMgr()->insert( action( 1133 ), -1, -1 );
3948 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3950 //-------------------------------------------------
3952 //-------------------------------------------------
3954 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
3955 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
3956 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
3957 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
3959 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
3961 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
3962 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
3964 popupMgr()->insert( separator(), anId, -1 );
3966 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
3968 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
3969 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
3970 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
3972 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
3974 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
3975 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3976 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
3978 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
3979 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3980 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
3982 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
3983 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3984 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
3986 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
3987 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
3988 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
3990 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
3992 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
3993 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
3994 QtxPopupMgr::VisibleRule );
3995 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
3997 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
3998 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
3999 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4001 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4002 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4003 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4005 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4006 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4007 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4009 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4010 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4011 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4013 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4014 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4015 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4017 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4018 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4019 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4021 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4022 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4023 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4025 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4026 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4027 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4029 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4030 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4031 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4033 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4034 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4035 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4037 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4038 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4039 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4041 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4043 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4044 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4045 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4047 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4048 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4049 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4051 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4052 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4053 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4055 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4056 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4057 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4059 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4060 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4061 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4063 popupMgr()->insert( separator(), anId, -1 );
4065 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4066 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4068 popupMgr()->insert( separator(), anId, -1 );
4070 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4072 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4073 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4075 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4076 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4077 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4079 #ifndef DISABLE_PLOT2DVIEWER
4080 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4081 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4084 //-------------------------------------------------
4086 //-------------------------------------------------
4087 popupMgr()->insert( separator(), -1, -1 );
4088 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4089 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4090 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4091 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4093 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4094 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4096 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4097 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4099 popupMgr()->insert( separator(), -1, -1 );
4101 //-------------------------------------------------
4103 //-------------------------------------------------
4104 popupMgr()->insert( action( 1134 ), -1, -1 );
4105 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4107 popupMgr()->insert( separator(), -1, -1 );
4109 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4110 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4112 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4113 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4116 //================================================================================
4118 * \brief Return true if SMESH or GEOM objects are selected.
4119 * Is called form LightApp_Module::activateModule() which clear selection if
4120 * not isSelectionCompatible()
4122 //================================================================================
4124 bool SMESHGUI::isSelectionCompatible()
4126 bool isCompatible = true;
4127 SALOME_ListIO selected;
4128 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4129 Sel->selectedObjects( selected );
4131 SALOME_ListIteratorOfListIO It( selected );
4132 for ( ; isCompatible && It.More(); It.Next())
4134 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4135 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4137 return isCompatible;
4141 bool SMESHGUI::reusableOperation( const int id )
4143 // compute, evaluate and precompute are not reusable operations
4144 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4147 bool SMESHGUI::activateModule( SUIT_Study* study )
4149 bool res = SalomeApp_Module::activateModule( study );
4151 setMenuShown( true );
4152 setToolShown( true );
4154 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4155 PyGILState_STATE gstate = PyGILState_Ensure();
4156 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4157 if(pluginsmanager==NULL)
4161 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4166 PyGILState_Release(gstate);
4167 // end of GEOM plugins loading
4169 // Reset actions accelerator keys
4170 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4171 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4172 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4174 action( 33)->setEnabled(true); // Delete: Key_Delete
4176 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4177 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4178 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4179 if ( _PTR(Study) aStudy = s->studyDS()) {
4180 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4181 updateObjBrowser(); // objects can be removed
4184 // get all view currently opened in the study and connect their signals to
4185 // the corresponding slots of the class.
4186 SUIT_Desktop* aDesk = study->application()->desktop();
4188 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4189 SUIT_ViewWindow* wnd;
4190 foreach ( wnd, wndList )
4197 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4199 setMenuShown( false );
4200 setToolShown( false );
4202 EmitSignalCloseAllDialogs();
4204 // Unset actions accelerator keys
4205 action(111)->setShortcut(QKeySequence()); // Import DAT
4206 action(112)->setShortcut(QKeySequence()); // Import UNV
4207 action(113)->setShortcut(QKeySequence()); // Import MED
4209 action( 33)->setEnabled(false); // Delete: Key_Delete
4211 return SalomeApp_Module::deactivateModule( study );
4214 void SMESHGUI::studyClosed( SUIT_Study* s )
4216 SMESH::RemoveVisuData( s->id() );
4217 SalomeApp_Module::studyClosed( s );
4220 void SMESHGUI::OnGUIEvent()
4222 const QObject* obj = sender();
4223 if ( !obj || !obj->inherits( "QAction" ) )
4225 int id = actionId((QAction*)obj);
4230 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4232 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4233 if ( CORBA::is_nil( myComponentSMESH ) )
4235 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4237 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4238 return aGUI.myComponentSMESH;
4241 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4242 return myComponentSMESH;
4245 QString SMESHGUI::engineIOR() const
4247 CORBA::ORB_var anORB = getApp()->orb();
4248 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4249 return QString( anIOR.in() );
4252 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4254 SalomeApp_Module::contextMenuPopup( client, menu, title );
4256 selectionMgr()->selectedObjects( lst );
4257 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4258 Handle(SALOME_InteractiveObject) io = lst.First();
4259 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4260 _PTR(Study) study = appStudy->studyDS();
4261 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4263 QString aName = QString( obj->GetName().c_str() );
4264 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4265 aName.remove( (aName.length() - 1), 1 );
4271 LightApp_Selection* SMESHGUI::createSelection() const
4273 return new SMESHGUI_Selection();
4276 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4278 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4279 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4282 void SMESHGUI::viewManagers( QStringList& list ) const
4284 list.append( SVTK_Viewer::Type() );
4287 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4289 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4290 SMESH::UpdateSelectionProp( this );
4292 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4293 for(int i = 0; i < aViews.count() ; i++){
4294 SUIT_ViewWindow *sf = aViews[i];
4300 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4302 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4303 myClippingPlaneInfoMap.erase( theViewManager );
4306 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4308 theActor->AddObserver( SMESH::DeleteActorEvent,
4309 myEventCallbackCommand.GetPointer(),
4313 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4314 unsigned long theEvent,
4315 void* theClientData,
4318 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4319 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4320 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4321 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4322 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4323 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4324 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4325 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4326 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4327 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4328 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4329 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4330 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4331 if( anActor == *anIter3 ) {
4332 anActorList.erase( anIter3 );
4343 void SMESHGUI::createPreferences()
4345 // General tab ------------------------------------------------------------------------
4346 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4348 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4349 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4350 setPreferenceProperty( lim, "min", 0 );
4351 setPreferenceProperty( lim, "max", 100000000 );
4352 setPreferenceProperty( lim, "step", 1000 );
4353 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4355 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4356 setPreferenceProperty( qaGroup, "columns", 2 );
4357 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4358 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4359 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4360 setPreferenceProperty( prec, "min", 0 );
4361 setPreferenceProperty( prec, "max", 16 );
4363 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4364 setPreferenceProperty( dispgroup, "columns", 2 );
4365 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4367 modes.append( tr("MEN_WIRE") );
4368 modes.append( tr("MEN_SHADE") );
4369 modes.append( tr("MEN_NODES") );
4370 modes.append( tr("MEN_SHRINK") );
4371 QList<QVariant> indices;
4372 indices.append( 0 );
4373 indices.append( 1 );
4374 indices.append( 2 );
4375 indices.append( 3 );
4376 setPreferenceProperty( dispmode, "strings", modes );
4377 setPreferenceProperty( dispmode, "indexes", indices );
4379 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4380 setPreferenceProperty( arcgroup, "columns", 2 );
4381 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4382 QStringList quadraticModes;
4383 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4384 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4386 indices.append( 0 );
4387 indices.append( 1 );
4388 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4389 setPreferenceProperty( quadraticmode, "indexes", indices );
4391 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4392 "SMESH", "max_angle" );
4393 setPreferenceProperty( maxAngle, "min", 1 );
4394 setPreferenceProperty( maxAngle, "max", 90 );
4398 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4399 setPreferenceProperty( exportgroup, "columns", 2 );
4400 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4401 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4403 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4404 setPreferenceProperty( computeGroup, "columns", 2 );
4405 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4407 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4408 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4409 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4411 indices.append( 0 );
4412 indices.append( 1 );
4413 indices.append( 2 );
4414 setPreferenceProperty( notifyMode, "strings", modes );
4415 setPreferenceProperty( notifyMode, "indexes", indices );
4417 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4418 setPreferenceProperty( computeGroup, "columns", 2 );
4419 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4421 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4422 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4424 indices.append( 0 );
4425 indices.append( 1 );
4426 setPreferenceProperty( elemInfo, "strings", modes );
4427 setPreferenceProperty( elemInfo, "indexes", indices );
4429 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4430 setPreferenceProperty( segGroup, "columns", 2 );
4431 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4432 "SMESH", "segmentation" );
4433 setPreferenceProperty( segLen, "min", 1 );
4434 setPreferenceProperty( segLen, "max", 10000000 );
4435 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4436 "SMESH", "nb_segments_per_edge" );
4437 setPreferenceProperty( nbSeg, "min", 1 );
4438 setPreferenceProperty( nbSeg, "max", 10000000 );
4440 // Quantities with individual precision settings
4441 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4442 setPreferenceProperty( precGroup, "columns", 2 );
4444 const int nbQuantities = 6;
4445 int precs[nbQuantities], ii = 0;
4446 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4447 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4448 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4449 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4450 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4451 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4452 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4453 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4454 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4455 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4456 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4457 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4459 // Set property for precision value for spinboxes
4460 for ( ii = 0; ii < nbQuantities; ii++ ){
4461 setPreferenceProperty( precs[ii], "min", -14 );
4462 setPreferenceProperty( precs[ii], "max", 14 );
4463 setPreferenceProperty( precs[ii], "precision", 2 );
4466 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4467 setPreferenceProperty( previewGroup, "columns", 2 );
4468 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4469 setPreferenceProperty( chunkSize, "min", 0 );
4470 setPreferenceProperty( chunkSize, "max", 1000 );
4471 setPreferenceProperty( chunkSize, "step", 50 );
4473 // Mesh tab ------------------------------------------------------------------------
4474 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4475 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4476 setPreferenceProperty( nodeGroup, "columns", 3 );
4478 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4480 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4482 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4483 QList<QVariant> aMarkerTypeIndicesList;
4484 QList<QVariant> aMarkerTypeIconsList;
4485 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4486 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4487 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4488 aMarkerTypeIndicesList << i;
4489 aMarkerTypeIconsList << pixmap;
4491 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4492 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4494 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4496 QList<QVariant> aMarkerScaleIndicesList;
4497 QStringList aMarkerScaleValuesList;
4498 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4499 aMarkerScaleIndicesList << i;
4500 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4502 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4503 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4505 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4506 setPreferenceProperty( elemGroup, "columns", 2 );
4508 addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::Color, "SMESH", "fill_color" );
4509 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4510 addPreference( tr( "PREF_BACKFACE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "backface_color" );
4511 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4513 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4514 setPreferenceProperty( grpGroup, "columns", 2 );
4516 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4518 //int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4519 //setPreferenceProperty( sp, "hstretch", 0 );
4520 //setPreferenceProperty( sp, "vstretch", 0 );
4522 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4523 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4524 int sp = addPreference( "", elemGroup, LightApp_Preferences::Space );
4525 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4526 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4527 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4528 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4530 setPreferenceProperty( size0d, "min", 1 );
4531 setPreferenceProperty( size0d, "max", 10 );
4533 setPreferenceProperty( sp, "hstretch", 0 );
4534 setPreferenceProperty( sp, "vstretch", 0 );
4536 setPreferenceProperty( elemW, "min", 1 );
4537 setPreferenceProperty( elemW, "max", 5 );
4539 setPreferenceProperty( shrink, "min", 0 );
4540 setPreferenceProperty( shrink, "max", 100 );
4542 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4543 setPreferenceProperty( orientGroup, "columns", 1 );
4545 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4546 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4548 setPreferenceProperty( orientScale, "min", 0.05 );
4549 setPreferenceProperty( orientScale, "max", 0.5 );
4550 setPreferenceProperty( orientScale, "step", 0.05 );
4552 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4554 // Selection tab ------------------------------------------------------------------------
4555 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4557 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4558 setPreferenceProperty( selGroup, "columns", 2 );
4560 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4561 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4562 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4564 setPreferenceProperty( selW, "min", 1 );
4565 setPreferenceProperty( selW, "max", 5 );
4567 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4568 setPreferenceProperty( preGroup, "columns", 2 );
4570 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4571 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4573 setPreferenceProperty( preW, "min", 1 );
4574 setPreferenceProperty( preW, "max", 5 );
4576 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4577 setPreferenceProperty( precSelGroup, "columns", 2 );
4579 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4580 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4581 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4583 // Scalar Bar tab ------------------------------------------------------------------------
4584 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4585 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4586 setPreferenceProperty( fontGr, "columns", 2 );
4588 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4589 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4591 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4592 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4594 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4595 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4597 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4598 setPreferenceProperty( numcol, "min", 2 );
4599 setPreferenceProperty( numcol, "max", 256 );
4601 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4602 setPreferenceProperty( numlab, "min", 2 );
4603 setPreferenceProperty( numlab, "max", 65 );
4605 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4606 setPreferenceProperty( orientGr, "columns", 2 );
4607 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4608 QStringList orients;
4609 orients.append( tr( "SMESH_VERTICAL" ) );
4610 orients.append( tr( "SMESH_HORIZONTAL" ) );
4611 indices.clear(); indices.append( 0 ); indices.append( 1 );
4612 setPreferenceProperty( orient, "strings", orients );
4613 setPreferenceProperty( orient, "indexes", indices );
4615 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4616 setPreferenceProperty( posVSizeGr, "columns", 2 );
4617 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4618 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4619 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4620 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4621 setPreferenceProperty( xv, "step", 0.1 );
4622 setPreferenceProperty( xv, "min", 0.0 );
4623 setPreferenceProperty( xv, "max", 1.0 );
4624 setPreferenceProperty( yv, "step", 0.1 );
4625 setPreferenceProperty( yv, "min", 0.0 );
4626 setPreferenceProperty( yv, "max", 1.0 );
4627 setPreferenceProperty( wv, "step", 0.1 );
4628 setPreferenceProperty( wv, "min", 0.0 );
4629 setPreferenceProperty( wv, "max", 1.0 );
4630 setPreferenceProperty( hv, "min", 0.0 );
4631 setPreferenceProperty( hv, "max", 1.0 );
4632 setPreferenceProperty( hv, "step", 0.1 );
4634 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4635 setPreferenceProperty( posHSizeGr, "columns", 2 );
4636 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4637 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4638 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4639 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4640 setPreferenceProperty( xv, "min", 0.0 );
4641 setPreferenceProperty( xv, "max", 1.0 );
4642 setPreferenceProperty( xv, "step", 0.1 );
4643 setPreferenceProperty( xh, "min", 0.0 );
4644 setPreferenceProperty( xh, "max", 1.0 );
4645 setPreferenceProperty( xh, "step", 0.1 );
4646 setPreferenceProperty( yh, "min", 0.0 );
4647 setPreferenceProperty( yh, "max", 1.0 );
4648 setPreferenceProperty( yh, "step", 0.1 );
4649 setPreferenceProperty( wh, "min", 0.0 );
4650 setPreferenceProperty( wh, "max", 1.0 );
4651 setPreferenceProperty( wh, "step", 0.1 );
4652 setPreferenceProperty( hh, "min", 0.0 );
4653 setPreferenceProperty( hh, "max", 1.0 );
4654 setPreferenceProperty( hh, "step", 0.1 );
4656 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4657 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4658 setPreferenceProperty( distributionGr, "columns", 3 );
4660 types.append( tr( "SMESH_MONOCOLOR" ) );
4661 types.append( tr( "SMESH_MULTICOLOR" ) );
4662 indices.clear(); indices.append( 0 ); indices.append( 1 );
4663 setPreferenceProperty( coloringType, "strings", types );
4664 setPreferenceProperty( coloringType, "indexes", indices );
4665 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4669 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4671 if( sect=="SMESH" ) {
4672 float sbX1,sbY1,sbW,sbH;
4673 float aTol = 1.00000009999999;
4674 std::string aWarning;
4675 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4676 if( name=="selection_object_color" || name=="selection_element_color" ||
4677 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4678 name=="selection_precision_node" || name=="selection_precision_element" ||
4679 name=="selection_precision_object")
4680 SMESH::UpdateSelectionProp( this );
4681 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4682 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4683 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4684 if(sbX1+sbW > aTol){
4685 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4688 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4689 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4692 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4693 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4694 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4695 if(sbY1+sbH > aTol){
4696 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4697 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4698 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4701 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4702 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4703 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4704 if(sbX1+sbW > aTol){
4705 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4708 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4709 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4712 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4713 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4714 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4715 if(sbY1+sbH > aTol){
4716 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4719 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4720 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4723 else if ( name == "segmentation" ) {
4724 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4725 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4727 else if ( name == "nb_segments_per_edge" ) {
4728 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4729 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4732 if(aWarning.size() != 0){
4733 aWarning += "The default values are applied instead.";
4734 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4735 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4736 QObject::tr(aWarning.c_str()));
4741 //================================================================================
4743 * \brief Update something in accordance with update flags
4744 * \param theFlags - update flags
4746 * Update viewer or/and object browser etc. in accordance with update flags ( see
4747 * LightApp_UpdateFlags enumeration ).
4749 //================================================================================
4750 void SMESHGUI::update( const int flags )
4752 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4753 SMESH::UpdateView();
4755 SalomeApp_Module::update( flags );
4758 //================================================================================
4760 * \brief Set default selection mode
4762 * SLOT called when operation commited. Sets default selection mode
4764 //================================================================================
4765 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4767 SVTK_ViewWindow* vtkWnd =
4768 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4770 vtkWnd->SetSelectionMode( ActorSelection );
4773 //================================================================================
4775 * \brief Set default selection mode
4777 * SLOT called when operation aborted. Sets default selection mode
4779 //================================================================================
4780 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4782 SVTK_ViewWindow* vtkWnd =
4783 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4785 vtkWnd->SetSelectionMode( ActorSelection );
4788 //================================================================================
4790 * \brief Creates operation with given identifier
4791 * \param id - identifier of operation to be started
4792 * \return Pointer on created operation or NULL if operation is not created
4794 * Virtual method redefined from the base class creates operation with given id.
4795 * It is called called automatically from startOperation method of base class.
4797 //================================================================================
4798 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4800 LightApp_Operation* op = 0;
4801 // to do : create operation here
4804 case 417: //convert to quadratic
4805 op = new SMESHGUI_ConvToQuadOp();
4807 case 418: // create 2D mesh as boundary on 3D
4808 op = new SMESHGUI_Make2DFrom3DOp();
4810 case 701: // Compute mesh
4811 op = new SMESHGUI_ComputeOp();
4813 case 702: // Create mesh
4814 op = new SMESHGUI_MeshOp( true, true );
4816 case 703: // Create sub-mesh
4817 op = new SMESHGUI_MeshOp( true, false );
4819 case 704: // Edit mesh/sub-mesh
4820 op = new SMESHGUI_MeshOp( false );
4822 case 711: // Precompute mesh
4823 op = new SMESHGUI_PrecomputeOp();
4825 case 712: // Evaluate mesh
4826 op = new SMESHGUI_EvaluateOp();
4828 case 713: // Evaluate mesh
4829 op = new SMESHGUI_MeshOrderOp();
4831 case 806: // Create group on geom
4832 op = new SMESHGUI_GroupOnShapeOp();
4834 case 904: // Find element
4835 op = new SMESHGUI_FindElemByPointOp();
4837 case 4067: // make mesh pass through point
4838 op = new SMESHGUI_MakeNodeAtPointOp();
4845 op = SalomeApp_Module::createOperation( id );
4849 //================================================================================
4851 * \brief Stops current operations and starts a given one
4852 * \param id - The id of the operation to start
4854 //================================================================================
4856 void SMESHGUI::switchToOperation(int id)
4858 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4859 activeStudy()->abortAllOperations();
4860 startOperation( id );
4863 LightApp_Displayer* SMESHGUI::displayer()
4866 myDisplayer = new SMESHGUI_Displayer( getApp() );
4870 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4873 int aTolerance = 64;
4874 int anIterations = 0;
4880 if( anIterations % aPeriod == 0 )
4883 if( aTolerance < 1 )
4887 aHue = (int)( 360.0 * rand() / RAND_MAX );
4890 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4891 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4892 for( ; it != itEnd; ++it )
4894 SALOMEDS::Color anAutoColor = *it;
4895 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4898 aQColor.getHsv( &h, &s, &v );
4899 if( abs( h - aHue ) < aTolerance )
4911 aColor.setHsv( aHue, 255, 255 );
4913 SALOMEDS::Color aSColor;
4914 aSColor.R = (double)aColor.red() / 255.0;
4915 aSColor.G = (double)aColor.green() / 255.0;
4916 aSColor.B = (double)aColor.blue() / 255.0;
4921 const char gSeparator = '_'; // character used to separate parameter names
4922 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4923 const char gPathSep = '|'; // character used to separate paths
4926 * \brief Store visual parameters
4928 * This method is called just before the study document is saved.
4929 * Store visual parameters in AttributeParameter attribue(s)
4931 void SMESHGUI::storeVisualParameters (int savePoint)
4933 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4934 if (!appStudy || !appStudy->studyDS())
4936 _PTR(Study) studyDS = appStudy->studyDS();
4938 // componentName is used for encoding of entries when storing them in IParameters
4939 std::string componentName = myComponentSMESH->ComponentDataType();
4940 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4941 //if (!aSComponent) return;
4944 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4945 componentName.c_str(),
4947 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4949 // store map of custom markers
4950 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4951 if( !aMarkerMap.empty() )
4953 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
4954 for( ; anIter != aMarkerMap.end(); anIter++ )
4956 int anId = anIter->first;
4957 VTK::MarkerData aMarkerData = anIter->second;
4958 std::string aMarkerFileName = aMarkerData.first;
4959 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
4960 if( aMarkerTexture.size() < 3 )
4961 continue; // should contain at least width, height and the first value
4963 QString aPropertyName( "texture" );
4964 aPropertyName += gSeparator;
4965 aPropertyName += QString::number( anId );
4967 QString aPropertyValue = aMarkerFileName.c_str();
4968 aPropertyValue += gPathSep;
4970 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
4971 ushort aWidth = *aTextureIter++;
4972 ushort aHeight = *aTextureIter++;
4973 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
4974 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
4975 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
4976 aPropertyValue += QString::number( *aTextureIter );
4978 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
4982 // viewers counters are used for storing view_numbers in IParameters
4985 // main cycle to store parameters of displayed objects
4986 QList<SUIT_ViewManager*> lst;
4987 QList<SUIT_ViewManager*>::Iterator it;
4988 getApp()->viewManagers(lst);
4989 for (it = lst.begin(); it != lst.end(); it++)
4991 SUIT_ViewManager* vman = *it;
4992 QString vType = vman->getType();
4994 // saving VTK actors properties
4995 if (vType == SVTK_Viewer::Type())
4997 // store the clipping planes attached to the view manager
4998 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
4999 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5000 if( anIter != myClippingPlaneInfoMap.end() )
5001 aClippingPlaneInfoList = anIter->second;
5003 if( !aClippingPlaneInfoList.empty() ) {
5004 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5005 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5007 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5008 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5010 QString aPropertyName( "ClippingPlane" );
5011 aPropertyName += gSeparator;
5012 aPropertyName += QString::number( vtkViewers );
5013 aPropertyName += gSeparator;
5014 aPropertyName += QString::number( anId );
5016 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5017 aPropertyValue += gDigitsSep;
5018 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5019 aPropertyValue += gDigitsSep;
5020 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5021 aPropertyValue += gDigitsSep;
5022 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5024 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5028 QVector<SUIT_ViewWindow*> views = vman->getViews();
5029 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5031 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5033 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5034 vtkActorCollection* allActors = aCopy.GetActors();
5035 allActors->InitTraversal();
5036 while (vtkActor* actor = allActors->GetNextActor())
5038 if (actor->GetVisibility()) // store only visible actors
5040 SMESH_Actor* aSmeshActor = 0;
5041 if (actor->IsA("SMESH_Actor"))
5042 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5043 if (aSmeshActor && aSmeshActor->hasIO())
5045 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5048 // entry is "encoded" = it does NOT contain component adress,
5049 // since it is a subject to change on next component loading
5050 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5052 std::string param, vtkParam = vType.toLatin1().data();
5053 vtkParam += gSeparator;
5054 vtkParam += QString::number(vtkViewers).toLatin1().data();
5055 vtkParam += gSeparator;
5058 param = vtkParam + "Visibility";
5059 ip->setParameter(entry, param, "On");
5062 param = vtkParam + "Representation";
5063 ip->setParameter(entry, param, QString::number
5064 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5067 param = vtkParam + "IsShrunk";
5068 ip->setParameter(entry, param, QString::number
5069 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5071 // Displayed entities
5072 unsigned int aMode = aSmeshActor->GetEntityMode();
5073 bool isE = aMode & SMESH_Actor::eEdges;
5074 bool isF = aMode & SMESH_Actor::eFaces;
5075 bool isV = aMode & SMESH_Actor::eVolumes;
5077 QString modeStr ("e");
5078 modeStr += gDigitsSep; modeStr += QString::number(isE);
5079 modeStr += gDigitsSep; modeStr += "f";
5080 modeStr += gDigitsSep; modeStr += QString::number(isF);
5081 modeStr += gDigitsSep; modeStr += "v";
5082 modeStr += gDigitsSep; modeStr += QString::number(isV);
5084 param = vtkParam + "Entities";
5085 ip->setParameter(entry, param, modeStr.toLatin1().data());
5087 // Colors (surface:edge:)
5088 vtkFloatingPointType r, g, b;
5090 aSmeshActor->GetSufaceColor(r, g, b);
5091 QString colorStr ("surface");
5092 colorStr += gDigitsSep; colorStr += QString::number(r);
5093 colorStr += gDigitsSep; colorStr += QString::number(g);
5094 colorStr += gDigitsSep; colorStr += QString::number(b);
5096 aSmeshActor->GetBackSufaceColor(r, g, b);
5097 colorStr += gDigitsSep; colorStr += "backsurface";
5098 colorStr += gDigitsSep; colorStr += QString::number(r);
5099 colorStr += gDigitsSep; colorStr += QString::number(g);
5100 colorStr += gDigitsSep; colorStr += QString::number(b);
5102 aSmeshActor->GetEdgeColor(r, g, b);
5103 colorStr += gDigitsSep; colorStr += "edge";
5104 colorStr += gDigitsSep; colorStr += QString::number(r);
5105 colorStr += gDigitsSep; colorStr += QString::number(g);
5106 colorStr += gDigitsSep; colorStr += QString::number(b);
5108 aSmeshActor->GetNodeColor(r, g, b);
5109 colorStr += gDigitsSep; colorStr += "node";
5110 colorStr += gDigitsSep; colorStr += QString::number(r);
5111 colorStr += gDigitsSep; colorStr += QString::number(g);
5112 colorStr += gDigitsSep; colorStr += QString::number(b);
5114 param = vtkParam + "Colors";
5115 ip->setParameter(entry, param, colorStr.toLatin1().data());
5117 // Sizes of lines and points
5118 QString sizeStr ("line");
5119 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5120 sizeStr += gDigitsSep; sizeStr += "shrink";
5121 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5123 param = vtkParam + "Sizes";
5124 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5129 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5130 if( aMarkerType == VTK::MT_USER ) {
5131 markerStr += "custom";
5132 markerStr += gDigitsSep;
5133 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5137 markerStr += gDigitsSep;
5138 markerStr += QString::number( (int)aMarkerType );
5139 markerStr += gDigitsSep;
5140 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5143 param = vtkParam + "PointMarker";
5144 ip->setParameter(entry, param, markerStr.toLatin1().data());
5147 param = vtkParam + "Opacity";
5148 ip->setParameter(entry, param,
5149 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5152 param = vtkParam + "ClippingPlane";
5154 if( !aClippingPlaneInfoList.empty() ) {
5155 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5156 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5158 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5159 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5160 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5161 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5162 if( aSmeshActor == *anIter2 ) {
5163 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5164 QString::number( anId ).toLatin1().constData() );
5171 ip->setParameter( entry, param, "Off" );
5172 } // if (io->hasEntry())
5173 } // SMESH_Actor && hasIO
5175 } // while.. actors traversal
5179 } // if (SVTK view model)
5180 } // for (viewManagers)
5183 // data structures for clipping planes processing
5186 vtkIdType Orientation;
5187 vtkFloatingPointType Distance;
5188 vtkFloatingPointType Angle[2];
5190 typedef std::list<TPlaneData> TPlaneDataList;
5191 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5193 typedef std::list<vtkActor*> TActorList;
5196 TActorList ActorList;
5197 SUIT_ViewManager* ViewManager;
5199 typedef std::list<TPlaneInfo> TPlaneInfoList;
5200 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5203 * \brief Restore visual parameters
5205 * This method is called after the study document is opened.
5206 * Restore visual parameters from AttributeParameter attribue(s)
5208 void SMESHGUI::restoreVisualParameters (int savePoint)
5210 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5211 if (!appStudy || !appStudy->studyDS())
5213 _PTR(Study) studyDS = appStudy->studyDS();
5215 // componentName is used for encoding of entries when storing them in IParameters
5216 std::string componentName = myComponentSMESH->ComponentDataType();
5217 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5218 //if (!aSComponent) return;
5221 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5222 componentName.c_str(),
5224 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5226 // restore map of custom markers and map of clipping planes
5227 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5228 TPlaneDataMap aPlaneDataMap;
5230 std::vector<std::string> properties = ip->getProperties();
5231 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5233 std::string property = *propIt;
5234 QString aPropertyName( property.c_str() );
5235 QString aPropertyValue( ip->getProperty( property ).c_str() );
5237 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5238 if( aPropertyNameList.isEmpty() )
5241 QString aPropertyType = aPropertyNameList[0];
5242 if( aPropertyType == "texture" )
5244 if( aPropertyNameList.size() != 2 )
5248 int anId = aPropertyNameList[1].toInt( &ok );
5249 if( !ok || anId < 1 )
5252 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5253 if( aPropertyValueList.size() != 2 )
5256 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5257 QString aMarkerTextureString = aPropertyValueList[1];
5258 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5259 if( aMarkerTextureStringList.size() != 3 )
5263 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5268 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5272 VTK::MarkerTexture aMarkerTexture;
5273 aMarkerTexture.push_back( aWidth );
5274 aMarkerTexture.push_back( aHeight );
5276 QString aMarkerTextureData = aMarkerTextureStringList[2];
5277 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5279 QChar aChar = aMarkerTextureData.at( i );
5280 if( aChar.isDigit() )
5281 aMarkerTexture.push_back( aChar.digitValue() );
5284 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5286 else if( aPropertyType == "ClippingPlane" )
5288 if( aPropertyNameList.size() != 3 )
5292 int aViewId = aPropertyNameList[1].toInt( &ok );
5293 if( !ok || aViewId < 0 )
5297 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5298 if( !ok || aClippingPlaneId < 0 )
5301 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5302 if( aPropertyValueList.size() != 4 )
5305 TPlaneData aPlaneData;
5306 aPlaneData.Id = aClippingPlaneId;
5309 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5314 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5319 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5324 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5328 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5329 aPlaneDataList.push_back( aPlaneData );
5333 TPlaneInfoMap aPlaneInfoMap;
5335 std::vector<std::string> entries = ip->getEntries();
5337 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5339 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5340 QString entry (ip->decodeEntry(*entIt).c_str());
5342 // Check that the entry corresponds to a real object in the Study
5343 // as the object may be deleted or modified after the visual state is saved.
5344 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5345 if (!so) continue; //Skip the not existent entry
5347 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5348 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5350 std::vector<std::string>::iterator namesIt = paramNames.begin();
5351 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5353 // actors are stored in a map after displaying of them for
5354 // quicker access in the future: map < viewID to actor >
5355 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5357 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5359 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5360 // '_' is used as separator and should not be used in viewer type or parameter names.
5361 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5362 if (lst.size() != 3)
5365 QString viewerTypStr = lst[0];
5366 QString viewIndexStr = lst[1];
5367 QString paramNameStr = lst[2];
5370 int viewIndex = viewIndexStr.toUInt(&ok);
5371 if (!ok) // bad conversion of view index to integer
5375 if (viewerTypStr == SVTK_Viewer::Type())
5377 SMESH_Actor* aSmeshActor = 0;
5378 if (vtkActors.IsBound(viewIndex))
5379 aSmeshActor = vtkActors.Find(viewIndex);
5381 QList<SUIT_ViewManager*> lst;
5382 getApp()->viewManagers(viewerTypStr, lst);
5384 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5385 SUIT_ViewManager* vman = NULL;
5386 if (viewIndex >= 0 && viewIndex < lst.count())
5387 vman = lst.at(viewIndex);
5389 if (paramNameStr == "Visibility")
5391 if (!aSmeshActor && displayer() && vman)
5393 SUIT_ViewModel* vmodel = vman->getViewModel();
5394 // SVTK view model can be casted to SALOME_View
5395 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5397 // store displayed actor in a temporary map for quicker
5398 // access later when restoring other parameters
5399 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5400 vtkRenderer* Renderer = vtkView->getRenderer();
5401 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5402 vtkActorCollection* theActors = aCopy.GetActors();
5403 theActors->InitTraversal();
5404 bool isFound = false;
5405 vtkActor *ac = theActors->GetNextActor();
5406 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5407 if (ac->IsA("SMESH_Actor")) {
5408 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5409 if (aGeomAc->hasIO()) {
5410 Handle(SALOME_InteractiveObject) io =
5411 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5412 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5414 vtkActors.Bind(viewIndex, aGeomAc);
5420 } // if (paramNameStr == "Visibility")
5423 // the rest properties "work" with SMESH_Actor
5426 QString val ((*valuesIt).c_str());
5429 if (paramNameStr == "Representation") {
5430 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5433 else if (paramNameStr == "IsShrunk") {
5435 if (!aSmeshActor->IsShrunk())
5436 aSmeshActor->SetShrink();
5439 if (aSmeshActor->IsShrunk())
5440 aSmeshActor->UnShrink();
5443 // Displayed entities
5444 else if (paramNameStr == "Entities") {
5445 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5446 if (mode.count() == 6) {
5447 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5448 MESSAGE("Invalid order of data in Entities, must be: "
5449 "e:0/1:f:0/1:v:0/1");
5452 unsigned int aMode = aSmeshActor->GetEntityMode();
5453 unsigned int aNewMode =
5454 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5455 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5456 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5457 if (aNewMode != aMode)
5458 aSmeshActor->SetEntityMode(aNewMode);
5463 else if (paramNameStr == "Colors") {
5464 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5465 if (colors.count() == 16) {
5466 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5467 colors[8] != "edge" || colors[12] != "node") {
5468 MESSAGE("Invalid order of data in Colors, must be: "
5469 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b");
5472 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat());
5473 aSmeshActor->SetBackSufaceColor(colors[5].toFloat(), colors[6].toFloat(), colors[7].toFloat());
5474 aSmeshActor->SetEdgeColor(colors[9].toFloat(), colors[10].toFloat(), colors[11].toFloat());
5475 aSmeshActor->SetNodeColor(colors[13].toFloat(), colors[14].toFloat(), colors[15].toFloat());
5479 // Sizes of lines and points
5480 else if (paramNameStr == "Sizes") {
5481 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5482 if (sizes.count() == 4) {
5483 if (sizes[0] != "line" || sizes[2] != "shrink") {
5484 MESSAGE("Invalid order of data in Sizes, must be: "
5485 "line:int:shrink:float");
5488 aSmeshActor->SetLineWidth(sizes[1].toInt());
5489 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5492 else if (sizes.count() == 6) { // just to support old format
5493 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5494 MESSAGE("Invalid order of data in Sizes, must be: "
5495 "line:int:node:int:shrink:float");
5498 aSmeshActor->SetLineWidth(sizes[1].toInt());
5499 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5500 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5505 else if (paramNameStr == "PointMarker") {
5506 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5507 if( data.count() >= 2 ) {
5509 int aParam1 = data[1].toInt( &ok );
5511 if( data[0] == "std" && data.count() == 3 ) {
5512 int aParam2 = data[2].toInt( &ok );
5513 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5515 else if( data[0] == "custom" ) {
5516 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5517 if( markerIt != aMarkerMap.end() ) {
5518 VTK::MarkerData aMarkerData = markerIt->second;
5519 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5526 else if (paramNameStr == "Opacity") {
5527 aSmeshActor->SetOpacity(val.toFloat());
5530 else if (paramNameStr.startsWith("ClippingPlane")) {
5531 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5532 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5533 // new format - val looks like "Off" or "0" (plane id)
5534 // (note: in new format "Off" value is used only for consistency,
5535 // so it is processed together with values in old format)
5536 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5537 if( anIsOldFormat ) {
5538 if (paramNameStr == "ClippingPlane1" || val == "Off")
5539 aSmeshActor->RemoveAllClippingPlanes();
5541 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5542 double aDistance = vals[1].toFloat();
5543 vtkFloatingPointType anAngle[2];
5544 anAngle[0] = vals[2].toFloat();
5545 anAngle[1] = vals[3].toFloat();
5547 QList<SUIT_ViewManager*> lst;
5548 getApp()->viewManagers(viewerTypStr, lst);
5549 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5550 if (viewIndex >= 0 && viewIndex < lst.count()) {
5551 SUIT_ViewManager* vman = lst.at(viewIndex);
5552 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5554 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5556 SMESH::TActorList anActorList;
5557 anActorList.push_back( aSmeshActor );
5558 SMESH::OrientedPlane* aPlane =
5559 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5561 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5562 aClippingPlaneInfo.Plane = aPlane;
5563 aClippingPlaneInfo.ActorList = anActorList;
5564 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5571 int aPlaneId = val.toInt( &ok );
5572 if( ok && aPlaneId >= 0 ) {
5573 bool anIsDefinedPlane = false;
5574 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5575 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5576 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5577 TPlaneInfo& aPlaneInfo = *anIter;
5578 if( aPlaneInfo.PlaneId == aPlaneId ) {
5579 aPlaneInfo.ActorList.push_back( aSmeshActor );
5580 anIsDefinedPlane = true;
5584 if( !anIsDefinedPlane ) {
5585 TPlaneInfo aPlaneInfo;
5586 aPlaneInfo.PlaneId = aPlaneId;
5587 aPlaneInfo.ActorList.push_back( aSmeshActor );
5588 aPlaneInfo.ViewManager = vman;
5590 // to make the list sorted by plane id
5591 anIter = aPlaneInfoList.begin();
5592 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5593 const TPlaneInfo& aPlaneInfoRef = *anIter;
5594 if( aPlaneInfoRef.PlaneId > aPlaneId )
5597 aPlaneInfoList.insert( anIter, aPlaneInfo );
5602 } // if (aSmeshActor)
5603 } // other parameters than Visibility
5605 } // for names/parameters iterator
5606 } // for entries iterator
5608 // take into account planes with empty list of actors referred to them
5609 QList<SUIT_ViewManager*> aVMList;
5610 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5612 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5613 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5614 int aViewId = aPlaneDataIter->first;
5615 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5616 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5618 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5620 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5621 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5622 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5623 const TPlaneData& aPlaneData = *anIter2;
5624 int aPlaneId = aPlaneData.Id;
5626 bool anIsFound = false;
5627 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5628 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5629 const TPlaneInfo& aPlaneInfo = *anIter3;
5630 if( aPlaneInfo.PlaneId == aPlaneId ) {
5637 TPlaneInfo aPlaneInfo; // ActorList field is empty
5638 aPlaneInfo.PlaneId = aPlaneId;
5639 aPlaneInfo.ViewManager = aViewManager;
5641 // to make the list sorted by plane id
5642 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5643 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5644 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5645 if( aPlaneInfoRef.PlaneId > aPlaneId )
5648 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5654 // add clipping planes to actors according to the restored parameters
5655 // and update the clipping plane map
5656 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5657 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5658 int aViewId = anIter1->first;
5659 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5661 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5662 if( anIter2 == aPlaneDataMap.end() )
5664 const TPlaneDataList& aPlaneDataList = anIter2->second;
5666 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5667 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5668 const TPlaneInfo& aPlaneInfo = *anIter3;
5669 int aPlaneId = aPlaneInfo.PlaneId;
5670 const TActorList& anActorList = aPlaneInfo.ActorList;
5671 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5675 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5679 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5681 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5682 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5683 const TPlaneData& aPlaneData = *anIter4;
5684 if( aPlaneData.Id == aPlaneId ) {
5685 SMESH::OrientedPlane* aPlane =
5686 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5688 (SMESH::Orientation)aPlaneData.Orientation,
5689 aPlaneData.Distance,
5692 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5693 aClippingPlaneInfo.Plane = aPlane;
5694 aClippingPlaneInfo.ActorList = anActorList;
5695 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5703 // update all VTK views
5704 QList<SUIT_ViewManager*> lst;
5705 getApp()->viewManagers(lst);
5706 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5707 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5708 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5709 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5710 vtkView->getRenderer()->ResetCameraClippingRange();
5717 \brief Adds preferences for dfont of VTK viewer
5719 \param pIf group identifier
5720 \param param parameter
5721 \return identifier of preferences
5723 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5725 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5727 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5730 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5731 fam.append( tr( "SMESH_FONT_COURIER" ) );
5732 fam.append( tr( "SMESH_FONT_TIMES" ) );
5734 setPreferenceProperty( tfont, "fonts", fam );
5736 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5737 setPreferenceProperty( tfont, "features", f );
5743 \brief Actions after hypothesis edition
5744 Updates object browser after hypothesis edition
5746 void SMESHGUI::onHypothesisEdit( int result )
5749 SMESHGUI::Modified();
5750 updateObjBrowser( true );
5755 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5756 \param pview view being closed
5758 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5759 #ifndef DISABLE_PLOT2DVIEWER
5760 //Crear all Plot2d Viewers if need.
5761 SMESH::ClearPlot2Viewers(pview);
5766 \brief Connects or disconnects signals about activating and cloning view on the module slots
5767 \param pview view which is connected/disconnected
5769 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5773 SUIT_ViewManager* viewMgr = pview->getViewManager();
5775 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5776 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5778 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5779 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5784 \brief Return \c true if object can be renamed
5786 bool SMESHGUI::renameAllowed( const QString& entry) const {
5787 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5791 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5795 bool appRes = SalomeApp_Module::renameAllowed(entry);
5799 // check type to prevent renaming of inappropriate objects
5800 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5801 if (aType == MESH || aType == GROUP ||
5802 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5803 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5804 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5805 aType == HYPOTHESIS || aType == ALGORITHM)
5812 Rename object by entry.
5813 \param entry entry of the object
5814 \param name new name of the object
5815 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5817 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5819 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5823 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5827 bool appRes = SalomeApp_Module::renameObject(entry,name);
5831 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5832 _PTR(GenericAttribute) anAttr;
5833 _PTR(AttributeName) aName;
5835 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5837 // check type to prevent renaming of inappropriate objects
5838 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5839 if (aType == MESH || aType == GROUP ||
5840 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5841 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5842 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5843 aType == HYPOTHESIS || aType == ALGORITHM) {
5844 if ( !name.isEmpty() ) {
5845 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5847 // update name of group object and its actor
5848 Handle(SALOME_InteractiveObject) IObject =
5849 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5851 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5852 if( !aGroupObject->_is_nil() ) {
5853 aGroupObject->SetName( qPrintable(name) );
5854 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5855 anActor->setName( qPrintable(name) );