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
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
32 #include "SMESHGUI_AddMeshElementDlg.h"
33 #include "SMESHGUI_AddQuadraticElementDlg.h"
34 #include "SMESHGUI_BuildCompoundDlg.h"
35 #include "SMESHGUI_ClippingDlg.h"
36 #include "SMESHGUI_ComputeDlg.h"
37 #include "SMESHGUI_ConvToQuadOp.h"
38 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
39 #include "SMESHGUI_DeleteGroupDlg.h"
40 #include "SMESHGUI_Displayer.h"
41 #include "SMESHGUI_MergeDlg.h"
42 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
43 #include "SMESHGUI_ExtrusionDlg.h"
44 #include "SMESHGUI_FileInfoDlg.h"
45 #include "SMESHGUI_FileValidator.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_FindElemByPointDlg.h"
49 #include "SMESHGUI_GroupDlg.h"
50 #include "SMESHGUI_GroupOnShapeDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_Hypotheses.h"
53 #include "SMESHGUI_Make2DFrom3DOp.h"
54 #include "SMESHGUI_MakeNodeAtPointDlg.h"
55 #include "SMESHGUI_Measurements.h"
56 #include "SMESHGUI_MeshInfo.h"
57 #include "SMESHGUI_MeshOp.h"
58 #include "SMESHGUI_MeshOrderOp.h"
59 #include "SMESHGUI_MeshPatternDlg.h"
60 #include "SMESHGUI_MultiEditDlg.h"
61 #include "SMESHGUI_NodesDlg.h"
62 #include "SMESHGUI_Preferences_ColorDlg.h"
63 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
64 #include "SMESHGUI_RemoveElementsDlg.h"
65 #include "SMESHGUI_RemoveNodesDlg.h"
66 #include "SMESHGUI_RenumberingDlg.h"
67 #include "SMESHGUI_RevolutionDlg.h"
68 #include "SMESHGUI_RotationDlg.h"
69 #include "SMESHGUI_Selection.h"
70 #include "SMESHGUI_SewingDlg.h"
71 #include "SMESHGUI_SingleEditDlg.h"
72 #include "SMESHGUI_SmoothingDlg.h"
73 #include "SMESHGUI_SymmetryDlg.h"
74 #include "SMESHGUI_TranslationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_TransparencyDlg.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)" );
208 else if ( theCommandID == 117 ) {
209 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
210 filter.append( QObject::tr( "All files (*)" ) );
213 QString anInitialPath = "";
214 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
215 anInitialPath = QDir::currentPath();
217 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
220 QObject::tr( "SMESH_IMPORT_MESH" ) );
221 if ( filenames.count() > 0 ) {
222 SUIT_OverrideCursor wc;
223 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
226 QStringList anEntryList;
227 bool isEmpty = false;
228 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
229 QString filename = *it;
230 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
232 switch ( theCommandID ) {
235 // DAT format (currently unsupported)
236 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
237 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
243 aMeshes->length( 1 );
244 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
245 if ( aMeshes[0]->_is_nil() )
246 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
247 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
253 SMESH::DriverMED_ReadStatus res;
254 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
255 if ( res != SMESH::DRS_OK ) {
256 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
257 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
264 aMeshes->length( 1 );
265 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
266 if ( aMeshes[0]->_is_nil() ) {
267 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
268 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
275 SMESH::DriverMED_ReadStatus res;
276 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
277 if ( res != SMESH::DRS_OK ) {
278 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
279 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
286 SMESH::DriverMED_ReadStatus res;
287 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
288 if ( res != SMESH::DRS_OK ) {
289 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
290 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
296 catch ( const SALOME::SALOME_Exception& S_ex ) {
297 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
298 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
301 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
302 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
304 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
305 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
306 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
307 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
308 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
310 anEntryList.append( aMeshSO->GetID().c_str() );
312 #ifdef WITHGENERICOBJ
313 // obj has been published in study. Its refcount has been incremented.
314 // It is safe to decrement its refcount
315 // so that it will be destroyed when the entry in study will be removed
316 aMeshes[i]->UnRegister();
325 // update Object browser
326 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
328 // browse to the published meshes
329 if( LightApp_Application* anApp =
330 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
331 anApp->browseObjects( anEntryList );
333 // show Error message box if there were errors
334 if ( errors.count() > 0 ) {
335 SUIT_MessageBox::critical( SMESHGUI::desktop(),
336 QObject::tr( "SMESH_ERROR" ),
337 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
340 // show warning message box, if some imported mesh is empty
342 SUIT_MessageBox::warning( SMESHGUI::desktop(),
343 QObject::tr( "SMESH_WRN_WARNING" ),
344 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
349 //================================================================================
351 * \brief Export selected meshes or groups into a file
353 //================================================================================
355 void ExportMeshToFile( int theCommandID )
357 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
358 SALOME_ListIO selected;
360 aSel->selectedObjects( selected );
362 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
363 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
364 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
365 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
366 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
367 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
369 // actually, the following condition can't be met (added for insurance)
370 if( selected.Extent() == 0 ||
371 ( selected.Extent() > 1 && !isMED && !isSTL ))
374 // get mesh object from selection and check duplication of their names
375 bool hasDuplicatedMeshNames = false;
376 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
377 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
378 SALOME_ListIteratorOfListIO It( selected );
379 for( ; It.More(); It.Next() )
381 Handle(SALOME_InteractiveObject) anIObject = It.Value();
382 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
383 if ( aMeshItem->_is_nil() ) {
384 SUIT_MessageBox::warning( SMESHGUI::desktop(),
385 QObject::tr( "SMESH_WRN_WARNING" ),
386 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
390 QString aMeshName = anIObject->getName();
392 // check for name duplications
393 if ( !hasDuplicatedMeshNames )
394 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
395 if( aMeshName == (*aMeshIter).second ) {
396 hasDuplicatedMeshNames = true;
401 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
404 if( hasDuplicatedMeshNames && isMED ) {
405 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
406 QObject::tr("SMESH_WRN_WARNING"),
407 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
408 QObject::tr("SMESH_BUT_YES"),
409 QObject::tr("SMESH_BUT_NO"), 0, 1);
414 aMeshIter = aMeshList.begin();
415 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
416 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
417 QString aMeshName = (*aMeshIter).second;
419 if ( isMED || isCGNS || isSAUV )
421 // check for equal group names within each mesh
422 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
423 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
424 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
425 int aRet = SUIT_MessageBox::warning
426 (SMESHGUI::desktop(),
427 QObject::tr("SMESH_WRN_WARNING"),
428 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
429 QObject::tr("SMESH_BUT_YES"),
430 QObject::tr("SMESH_BUT_NO"), 0, 1);
438 // warn the user about presence of not supported elements
439 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
440 int nbNotSupported = ( nbElems[ SMESH::Entity_Pyramid ] +
441 nbElems[ SMESH::Entity_Quad_Pyramid ] +
442 nbElems[ SMESH::Entity_Hexagonal_Prism ] +
443 nbElems[ SMESH::Entity_Polygon ] +
444 nbElems[ SMESH::Entity_Polyhedra ] );
445 if ( nbNotSupported > 0 ) {
446 int aRet = SUIT_MessageBox::warning
447 (SMESHGUI::desktop(),
448 QObject::tr("SMESH_WRN_WARNING"),
449 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
450 QObject::tr("SMESH_BUT_YES"),
451 QObject::tr("SMESH_BUT_NO"), 0, 1);
457 // Get parameters of export operation
460 SMESH::MED_VERSION aFormat;
461 // Init the parameters with the default values
462 bool aIsASCII_STL = true;
463 bool toCreateGroups = false;
464 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
466 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
467 bool toOverwrite = true;
469 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
470 QString anInitialPath = "";
471 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
472 anInitialPath = QDir::currentPath();
474 if ( isUNV || isDAT )
477 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
479 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
480 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
481 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
482 anInitialPath + QString("/") + aMeshName,
483 aFilter, aTitle, false);
485 else if ( isCGNS )// Export to CGNS
487 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
488 fd->setWindowTitle( aTitle );
489 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
490 if ( !anInitialPath.isEmpty() )
491 fd->setDirectory( anInitialPath );
492 fd->selectFile(aMeshName);
493 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
494 fd->setValidator( fv );
497 aFilename = fd->selectedFile();
498 toOverwrite = fv->isOverwrite();
502 else if ( isSTL ) // Export to STL
504 QMap<QString, int> aFilterMap;
505 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
506 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
509 QMap<QString, int>::const_iterator it = aFilterMap.begin();
510 for ( ; it != aFilterMap.end(); ++it )
511 filters.push_back( it.key() );
513 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
514 fd->setWindowTitle( aTitle );
515 fd->setNameFilters( filters );
516 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
517 if ( !anInitialPath.isEmpty() )
518 fd->setDirectory( anInitialPath );
519 fd->selectFile(aMeshName);
523 aFilename = fd->selectedFile();
524 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
529 else if ( isMED || isSAUV ) // Export to MED or SAUV
531 QMap<QString, SMESH::MED_VERSION> aFilterMap;
532 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
534 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
535 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
536 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
539 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
540 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
541 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
545 QString aDefaultFilter;
546 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
547 for ( ; it != aFilterMap.end(); ++it ) {
548 filters.push_back( it.key() );
549 if (it.value() == SMESH::MED_V2_2)
550 aDefaultFilter = it.key();
553 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
554 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
555 fd->setWindowTitle( aTitle );
556 fd->setNameFilters( filters );
557 fd->selectNameFilter(aDefaultFilter);
558 fd->SetChecked(toCreateGroups);
559 if ( !anInitialPath.isEmpty() )
560 fd->setDirectory( anInitialPath );
561 fd->selectFile(aMeshName);
563 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
564 fd->setValidator( fv );
569 aFilename = fd->selectedFile();
571 aFilename = QString::null;
574 aFormat = aFilterMap[fd->selectedNameFilter()];
575 toOverwrite = fv->isOverwrite();
577 if ( !aFilename.isEmpty() ) {
578 // med-2.1 does not support poly elements
579 if ( aFormat==SMESH::MED_V2_1 )
580 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
581 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
582 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
583 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
584 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
586 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
587 QObject::tr("SMESH_WRN_WARNING"),
588 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
589 QObject::tr("SMESH_BUT_YES"),
590 QObject::tr("SMESH_BUT_NO"), 0, 1);
598 // can't append to an existing using other format
599 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
600 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
601 if( !isVersionOk || aVersion != aFormat ) {
602 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
603 QObject::tr("SMESH_WRN_WARNING"),
604 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
605 QObject::tr("SMESH_BUT_YES"),
606 QObject::tr("SMESH_BUT_NO"), 0, 1);
613 QStringList aMeshNamesCollisionList;
614 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
615 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
616 QString anExistingMeshName( aMeshNames[ i ] );
617 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
618 QString anExportMeshName = (*aMeshIter).second;
619 if( anExportMeshName == anExistingMeshName ) {
620 aMeshNamesCollisionList.append( anExportMeshName );
625 if( !aMeshNamesCollisionList.isEmpty() ) {
626 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
627 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
628 QObject::tr("SMESH_WRN_WARNING"),
629 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
630 QObject::tr("SMESH_BUT_YES"),
631 QObject::tr("SMESH_BUT_NO"),
632 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
641 toCreateGroups = fd->IsChecked();
651 if ( !aFilename.isEmpty() ) {
652 // Check whether the file already exists and delete it if yes
653 QFile aFile( aFilename );
654 if ( aFile.exists() && toOverwrite )
656 SUIT_OverrideCursor wc;
659 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
660 // bool Renumber = false;
661 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
663 // Renumber= resMgr->booleanValue("SMESH","renumbering");
665 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
666 // aMeshEditor->RenumberNodes();
667 // aMeshEditor->RenumberElements();
668 // if ( SMESHGUI::automaticUpdate() )
669 // SMESH::UpdateView();
673 aMeshIter = aMeshList.begin();
674 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
676 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
677 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
678 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
679 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
680 aFormat, toOverwrite && aMeshIndex == 0 );
682 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
683 aFormat, toOverwrite && aMeshIndex == 0 );
688 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
690 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
691 if( !aMeshItem->_is_nil() )
692 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
697 if ( aMeshOrGroup->_is_equivalent( aMesh ))
698 aMesh->ExportDAT( aFilename.toLatin1().data() );
700 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
704 if ( aMeshOrGroup->_is_equivalent( aMesh ))
705 aMesh->ExportUNV( aFilename.toLatin1().data() );
707 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
711 if ( aMeshOrGroup->_is_equivalent( aMesh ))
712 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
714 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
718 aMeshIter = aMeshList.begin();
719 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
721 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
722 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
723 aMeshItem->ExportCGNS( aMeshOrGroup,
724 aFilename.toLatin1().data(),
725 toOverwrite && aMeshIndex == 0 );
729 catch (const SALOME::SALOME_Exception& S_ex){
731 SUIT_MessageBox::warning(SMESHGUI::desktop(),
732 QObject::tr("SMESH_WRN_WARNING"),
733 QObject::tr("SMESH_EXPORT_FAILED"));
739 inline void InverseEntityMode(unsigned int& theOutputMode,
740 unsigned int theMode)
742 bool anIsNotPresent = ~theOutputMode & theMode;
744 theOutputMode |= theMode;
746 theOutputMode &= ~theMode;
749 void SetDisplayEntity(int theCommandID){
750 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
751 SALOME_ListIO selected;
753 aSel->selectedObjects( selected );
755 if(selected.Extent() >= 1){
756 SALOME_ListIteratorOfListIO It( selected );
757 for( ; It.More(); It.Next()){
758 Handle(SALOME_InteractiveObject) IObject = It.Value();
759 if(IObject->hasEntry()){
760 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
761 unsigned int aMode = anActor->GetEntityMode();
762 switch(theCommandID){
764 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
767 InverseEntityMode(aMode,SMESH_Actor::eEdges);
770 InverseEntityMode(aMode,SMESH_Actor::eFaces);
773 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
776 aMode = SMESH_Actor::eAllEntity;
780 anActor->SetEntityMode(aMode);
788 SALOME_ListIO selected;
789 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
793 LightApp_SelectionMgr* aSel = app->selectionMgr();
794 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
795 if( !aSel || !appStudy )
798 aSel->selectedObjects( selected );
799 if( selected.IsEmpty() )
802 Handle(SALOME_InteractiveObject) anIObject = selected.First();
804 _PTR(Study) aStudy = appStudy->studyDS();
805 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
806 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
807 if( aMainObject->_is_nil() )
810 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
812 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
813 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
815 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
816 SALOMEDS::Color aColor = aGroupObject->GetColor();
817 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
819 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
820 if( aGroupObject->GetType() == SMESH::NODE )
821 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
822 else if( aGroupObject->GetType() == SMESH::EDGE )
823 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
824 else if( aGroupObject->GetType() == SMESH::ELEM0D )
825 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
829 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
830 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
836 SMESH::RepaintCurrentView();
839 QString functorToString( SMESH::Controls::FunctorPtr f )
841 QString type = QObject::tr( "UNKNOWN_CONTROL" );
842 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
843 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
844 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
845 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
846 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
847 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
848 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
849 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
850 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
851 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
852 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
853 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
854 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
855 type = QObject::tr( "WARP_ELEMENTS" );
856 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
857 type = QObject::tr( "TAPER_ELEMENTS" );
858 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
859 type = QObject::tr( "SKEW_ELEMENTS" );
860 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
861 type = QObject::tr( "AREA_ELEMENTS" );
862 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
863 type = QObject::tr( "LENGTH_EDGES" );
864 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
865 type = QObject::tr( "LENGTH2D_EDGES" );
866 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
867 type = QObject::tr( "MULTI_BORDERS" );
868 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
869 type = QObject::tr( "MULTI2D_BORDERS" );
870 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
871 type = QObject::tr( "FREE_NODES" );
872 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
873 type = QObject::tr( "FREE_EDGES" );
874 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
875 type = QObject::tr( "FREE_BORDERS" );
876 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
877 type = QObject::tr( "FREE_FACES" );
878 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
879 type = QObject::tr( "BARE_BORDER_VOLUME" );
880 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
881 type = QObject::tr( "BARE_BORDER_FACE" );
882 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
883 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
884 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
885 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
886 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
887 type = QObject::tr( "EQUAL_NODE" );
888 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
889 type = QObject::tr( "EQUAL_EDGE" );
890 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
891 type = QObject::tr( "EQUAL_FACE" );
892 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
893 type = QObject::tr( "EQUAL_VOLUME" );
897 void SaveDistribution()
899 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
900 SALOME_ListIO selected;
902 aSel->selectedObjects( selected );
904 if ( selected.Extent() == 1 ) {
905 Handle(SALOME_InteractiveObject) anIO = selected.First();
906 if ( anIO->hasEntry() ) {
907 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
908 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
909 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
910 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
911 if ( aScalarBarActor && aFunctor ) {
912 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
914 std::vector<int> elements;
915 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
916 if ( mesh->_is_nil() ) {
917 SMESH::SMESH_IDSource_var idSource =
918 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
919 if ( !idSource->_is_nil() )
921 SMESH::long_array_var ids = idSource->GetIDs();
922 elements.resize( ids->length() );
923 for ( unsigned i = 0; i < elements.size(); ++i )
924 elements[i] = ids[i];
927 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
928 vtkLookupTable* lookupTable =
929 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
930 double * minmax = lookupTable->GetRange();
931 std::vector<int> nbEvents;
932 std::vector<double> funValues;
933 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
934 QString anInitialPath = "";
935 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
936 anInitialPath = QDir::currentPath();
937 QString aMeshName = anIO->getName();
939 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
940 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
941 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
942 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
943 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
946 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
948 if ( !aFilename.isEmpty() ) {
949 QFile f( aFilename );
950 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
951 QTextStream out( &f );
952 out << "# Mesh: " << aMeshName << endl;
953 out << "# Control: " << functorToString( aFunctor ) << endl;
955 out.setFieldWidth( 10 );
956 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
957 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
968 void ShowDistribution() {
969 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
970 SALOME_ListIO selected;
972 aSel->selectedObjects( selected );
974 if ( selected.Extent() == 1 ) {
975 Handle(SALOME_InteractiveObject) anIO = selected.First();
976 if ( anIO->hasEntry() ) {
977 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
978 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
979 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
980 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
986 #ifndef DISABLE_PLOT2DVIEWER
987 void PlotDistribution() {
988 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
992 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
993 SALOME_ListIO selected;
995 aSel->selectedObjects( selected );
997 if ( selected.Extent() == 1 ) {
998 Handle(SALOME_InteractiveObject) anIO = selected.First();
999 if ( anIO->hasEntry() ) {
1000 //Find Actor by entry before getting Plot2d viewer,
1001 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1002 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1004 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1009 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1013 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1017 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1018 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1019 QString functorName = functorToString( anActor->GetFunctor());
1020 QString aHistogramName("%1 : %2");
1021 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1022 aHistogram->setName(aHistogramName);
1023 aHistogram->setHorTitle(functorName);
1024 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1025 aPlot->displayObject(aHistogram, true);
1030 #endif //DISABLE_PLOT2DVIEWER
1032 void DisableAutoColor(){
1033 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1034 SALOME_ListIO selected;
1036 aSel->selectedObjects( selected );
1038 if(selected.Extent()){
1039 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1040 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1041 if ( !aMesh->_is_nil() ) {
1042 aMesh->SetAutoColor( false );
1047 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1048 SALOME_ListIO selected;
1049 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1053 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1054 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1055 if( !aSel || !appStudy )
1058 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1059 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1060 aModule->EmitSignalDeactivateDialog();
1061 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1062 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1067 _PTR(Study) aStudy = appStudy->studyDS();
1069 aSel->selectedObjects( selected );
1071 if(selected.Extent() >= 1){
1072 switch(theCommandID){
1074 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1075 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1079 QColor c, e, b, n, c0D, o, outl, selection, preselection;
1083 vtkFloatingPointType Shrink = 0.0;
1084 vtkFloatingPointType faces_orientation_scale = 0.0;
1085 bool faces_orientation_3dvectors = false;
1087 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1088 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1089 int aMarkerTextureCurrent = 0;
1091 SALOME_ListIteratorOfListIO It( selected );
1092 for( ; It.More(); It.Next()){
1093 Handle(SALOME_InteractiveObject) IObject = It.Value();
1094 if(IObject->hasEntry()){
1095 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1096 vtkFloatingPointType color[3];
1097 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1098 int c0 = int (color[0] * 255);
1099 int c1 = int (color[1] * 255);
1100 int c2 = int (color[2] * 255);
1101 c.setRgb(c0, c1, c2);
1103 vtkFloatingPointType edgecolor[3];
1104 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1105 c0 = int (edgecolor[0] * 255);
1106 c1 = int (edgecolor[1] * 255);
1107 c2 = int (edgecolor[2] * 255);
1108 e.setRgb(c0, c1, c2);
1110 vtkFloatingPointType nodecolor[3];
1111 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1112 c0 = int (nodecolor[0] * 255);
1113 c1 = int (nodecolor[1] * 255);
1114 c2 = int (nodecolor[2] * 255);
1115 n.setRgb(c0, c1, c2);
1117 vtkFloatingPointType color0D[3];
1118 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1119 c0 = int (color0D[0] * 255);
1120 c1 = int (color0D[1] * 255);
1121 c2 = int (color0D[2] * 255);
1122 c0D.setRgb(c0, c1, c2);
1124 vtkFloatingPointType outlineColor[3];
1125 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1126 c0 = int (outlineColor[0] * 255);
1127 c1 = int (outlineColor[1] * 255);
1128 c2 = int (outlineColor[2] * 255);
1129 outl.setRgb(c0, c1, c2);
1131 vtkFloatingPointType hColor[3];
1132 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1133 c0 = int (hColor[0] * 255);
1134 c1 = int (hColor[1] * 255);
1135 c2 = int (hColor[2] * 255);
1136 selection.setRgb(c0, c1, c2);
1138 vtkFloatingPointType phColor[3];
1139 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1140 c0 = int (phColor[0] * 255);
1141 c1 = int (phColor[1] * 255);
1142 c2 = int (phColor[2] * 255);
1143 preselection.setRgb(c0, c1, c2);
1145 size0D = (int)anActor->Get0DSize();
1148 Edgewidth = (int)anActor->GetLineWidth();
1151 Shrink = anActor->GetShrinkFactor();
1153 vtkFloatingPointType faces_orientation_color[3];
1154 anActor->GetFacesOrientationColor(faces_orientation_color);
1155 c0 = int (faces_orientation_color[0] * 255);
1156 c1 = int (faces_orientation_color[1] * 255);
1157 c2 = int (faces_orientation_color[2] * 255);
1158 o.setRgb(c0, c1, c2);
1160 faces_orientation_scale = anActor->GetFacesOrientationScale();
1161 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1163 aMarkerTypeCurrent = anActor->GetMarkerType();
1164 aMarkerScaleCurrent = anActor->GetMarkerScale();
1165 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1167 // even if there are multiple objects in the selection,
1168 // we need only the first one to get values for the dialog
1174 SMESHGUI_Preferences_ColorDlg *aDlg =
1175 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1176 aDlg->SetColor(1, c);
1177 aDlg->SetColor(2, e);
1178 aDlg->SetColor(3, n);
1179 aDlg->SetColor(4, outl);
1180 aDlg->SetDeltaBrightness(delta);
1181 aDlg->SetColor(5, c0D);
1182 aDlg->SetColor(6, o);
1183 aDlg->SetIntValue(1, Edgewidth);
1184 aDlg->SetIntValue(2, int(Shrink*100.));
1185 aDlg->SetIntValue(3, size0D);
1186 aDlg->SetDoubleValue(1, faces_orientation_scale);
1187 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1188 aDlg->SetColor(7, selection);
1189 aDlg->SetColor(8, preselection);
1191 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1193 if( aMarkerTypeCurrent != VTK::MT_USER )
1194 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1196 aDlg->setCustomMarker( aMarkerTextureCurrent );
1199 QColor color = aDlg->GetColor(1);
1200 QColor edgecolor = aDlg->GetColor(2);
1201 QColor nodecolor = aDlg->GetColor(3);
1202 QColor outlinecolor = aDlg->GetColor(4);
1203 QColor color0D = aDlg->GetColor(5);
1204 QColor faces_orientation_color = aDlg->GetColor(6);
1205 QColor selectioncolor = aDlg->GetColor(7);
1206 QColor preSelectioncolor = aDlg->GetColor(8);
1207 int delta = aDlg->GetDeltaBrightness();
1210 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1212 SALOME_ListIteratorOfListIO It( selected );
1213 for( ; It.More(); It.Next()){
1214 Handle(SALOME_InteractiveObject) IObject = It.Value();
1215 if(IObject->hasEntry()){
1216 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1217 /* actor color and backface color */
1218 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1219 vtkFloatingPointType (color.green()) / 255.,
1220 vtkFloatingPointType (color.blue()) / 255.,
1223 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1224 vtkFloatingPointType (edgecolor.green()) / 255.,
1225 vtkFloatingPointType (edgecolor.blue()) / 255.);
1227 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1228 vtkFloatingPointType (outlinecolor.green()) / 255.,
1229 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1232 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1233 vtkFloatingPointType (selectioncolor.green()) / 255.,
1234 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1236 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1237 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1238 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1241 /* Shrink factor and size edges */
1242 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1243 anActor->SetLineWidth(aDlg->GetIntValue(1));
1245 /* Nodes color and size */
1246 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1247 vtkFloatingPointType (nodecolor.green()) / 255.,
1248 vtkFloatingPointType (nodecolor.blue()) / 255.);
1251 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1252 vtkFloatingPointType (color0D.green()) / 255.,
1253 vtkFloatingPointType (color0D.blue()) / 255.);
1254 anActor->Set0DSize(aDlg->GetIntValue(3));
1256 /* Faces orientation */
1257 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1258 vtkFloatingPointType(faces_orientation_color.greenF()),
1259 vtkFloatingPointType(faces_orientation_color.blueF())};
1260 anActor->SetFacesOrientationColor(c);
1261 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1262 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1264 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1265 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1266 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1267 if( aMarkerTypeNew != VTK::MT_USER )
1268 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1270 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1271 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1272 if( anIter != aMarkerMap.end() )
1273 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1276 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1277 if( !aGroupObject->_is_nil() )
1279 SMESH::ElementType anElementType = aGroupObject->GetType();
1281 switch( anElementType )
1283 case SMESH::NODE: aColor = nodecolor; break;
1284 case SMESH::EDGE: aColor = edgecolor; break;
1285 default: aColor = color; break;
1288 SALOMEDS::Color aGroupColor;
1289 aGroupColor.R = (float)aColor.red() / 255.0;
1290 aGroupColor.G = (float)aColor.green() / 255.0;
1291 aGroupColor.B = (float)aColor.blue() / 255.0;
1292 aGroupObject->SetColor( aGroupColor );
1297 SMESH::RepaintCurrentView();
1303 SALOME_ListIteratorOfListIO It( selected );
1304 for( ; It.More(); It.Next()){
1305 Handle(SALOME_InteractiveObject) IObject = It.Value();
1306 if(IObject->hasEntry()){
1307 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1308 switch(theCommandID){
1310 anActor->SetRepresentation(SMESH_Actor::eEdge);
1313 anActor->SetRepresentation(SMESH_Actor::eSurface);
1316 if(anActor->IsShrunk())
1317 anActor->UnShrink();
1319 anActor->SetShrink();
1322 anActor->SetRepresentation(SMESH_Actor::ePoint);
1325 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1326 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1329 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1330 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1336 SMESH::RepaintCurrentView();
1340 void Control( int theCommandID )
1342 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1343 SALOME_ListIO selected;
1345 aSel->selectedObjects( selected );
1347 if( !selected.IsEmpty() ){
1348 Handle(SALOME_InteractiveObject) anIO = selected.First();
1350 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1351 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1352 switch ( theCommandID ){
1354 aControl = SMESH_Actor::eLength;
1357 aControl = SMESH_Actor::eLength2D;
1360 aControl = SMESH_Actor::eFreeEdges;
1363 aControl = SMESH_Actor::eFreeBorders;
1366 aControl = SMESH_Actor::eMultiConnection;
1369 aControl = SMESH_Actor::eFreeNodes;
1372 aControl = SMESH_Actor::eMultiConnection2D;
1375 aControl = SMESH_Actor::eArea;
1378 aControl = SMESH_Actor::eTaper;
1381 aControl = SMESH_Actor::eAspectRatio;
1384 aControl = SMESH_Actor::eAspectRatio3D;
1387 aControl = SMESH_Actor::eMinimumAngle;
1390 aControl = SMESH_Actor::eWarping;
1393 aControl = SMESH_Actor::eSkew;
1396 aControl = SMESH_Actor::eVolume3D;
1399 aControl = SMESH_Actor::eFreeFaces;
1402 aControl = SMESH_Actor::eMaxElementLength2D;
1405 aControl = SMESH_Actor::eMaxElementLength3D;
1408 aControl = SMESH_Actor::eBareBorderVolume;
1411 aControl = SMESH_Actor::eBareBorderFace;
1414 aControl = SMESH_Actor::eOverConstrainedVolume;
1417 aControl = SMESH_Actor::eOverConstrainedFace;
1420 aControl = SMESH_Actor::eCoincidentNodes;
1423 aControl = SMESH_Actor::eCoincidentElems1D;
1426 aControl = SMESH_Actor:: eCoincidentElems2D;
1429 aControl = SMESH_Actor::eCoincidentElems3D;
1433 anActor->SetControlMode(aControl);
1434 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1435 SMESH::RepaintCurrentView();
1436 #ifndef DISABLE_PLOT2DVIEWER
1437 if(anActor->GetPlot2Histogram()) {
1438 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1439 QString functorName = functorToString( anActor->GetFunctor());
1440 QString aHistogramName("%1 : %2");
1441 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1442 aHistogram->setName(aHistogramName);
1443 aHistogram->setHorTitle(functorName);
1444 SMESH::ProcessIn2DViewers(anActor);
1453 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1454 MeshObjectType theType,
1455 const QString theInTypeName,
1456 QString & theOutTypeName)
1458 SMESH_TypeFilter aTypeFilter( theType );
1460 if( !theIO.IsNull() )
1462 entry = theIO->getEntry();
1463 LightApp_DataOwner owner( entry );
1464 if ( aTypeFilter.isOk( &owner )) {
1465 theOutTypeName = theInTypeName;
1473 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1475 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1476 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1478 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1479 CORBA::String_var anID = aSComp->GetID().c_str();
1480 if (!strcmp(anID.in(),theIO->getEntry()))
1486 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1487 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1488 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1489 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1490 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1498 QString CheckHomogeneousSelection()
1500 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1501 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1502 SALOME_ListIO selected;
1504 aSel->selectedObjects( selected );
1506 QString RefType = CheckTypeObject(selected.First());
1507 SALOME_ListIteratorOfListIO It(selected);
1508 for ( ; It.More(); It.Next())
1510 Handle(SALOME_InteractiveObject) IObject = It.Value();
1511 QString Type = CheckTypeObject(IObject);
1512 if (Type.compare(RefType) != 0)
1513 return "Heterogeneous Selection";
1520 void SMESHGUI::OnEditDelete()
1522 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1523 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1524 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1526 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1527 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1528 _PTR(GenericAttribute) anAttr;
1529 _PTR(AttributeIOR) anIOR;
1531 int objectCount = 0;
1533 QString aParentComponent = QString::null;
1534 Handle(SALOME_InteractiveObject) anIO;
1535 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1537 anIO = anIt.Value();
1538 QString cur = anIO->getComponentDataType();
1539 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1541 // check if object is reference
1542 _PTR(SObject) aRefSObj;
1543 aNameList.append("\n - ");
1544 if ( aSO->ReferencedObject( aRefSObj ) ) {
1545 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1546 aNameList.append( aRefName );
1547 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1550 aNameList.append(anIO->getName());
1554 if( aParentComponent.isNull() )
1555 aParentComponent = cur;
1556 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1557 aParentComponent = "";
1560 if ( objectCount == 0 )
1561 return; // No Valid Objects Selected
1563 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1564 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1565 QObject::tr("ERR_ERROR"),
1566 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1569 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1570 if (SUIT_MessageBox::warning
1571 (SMESHGUI::desktop(),
1572 QObject::tr("SMESH_WRN_WARNING"),
1573 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1574 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1575 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1578 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1580 SALOME_ListIteratorOfListIO It(selected);
1582 aStudyBuilder->NewCommand(); // There is a transaction
1583 for( ; It.More(); It.Next()){ // loop on selected IO's
1584 Handle(SALOME_InteractiveObject) IObject = It.Value();
1585 if(IObject->hasEntry()) {
1586 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1588 // disable removal of "SMESH" component object
1589 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1591 if ( engineIOR() == anIOR->Value().c_str() )
1594 //Check the referenced object
1595 _PTR(SObject) aRefSObject;
1596 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1597 aSO = aRefSObject; // Delete main Object instead of reference
1599 // put the whole hierarchy of sub-objects of the selected SO into a list and
1600 // then treat them all starting from the deepest objects (at list back)
1602 std::list< _PTR(SObject) > listSO;
1603 listSO.push_back( aSO );
1604 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1605 for ( ; itSO != listSO.end(); ++itSO ) {
1606 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1607 for (it->InitEx(false); it->More(); it->Next())
1608 listSO.push_back( it->Value() );
1611 // treat SO's in the list starting from the back
1613 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1614 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1615 _PTR(SObject) SO = *ritSO;
1616 if ( !SO ) continue;
1617 std::string anEntry = SO->GetID();
1619 /** Erase graphical object **/
1620 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1621 ViewManagerList aViewMenegers = anApp->viewManagers();
1622 ViewManagerList::const_iterator it = aViewMenegers.begin();
1623 for( ; it != aViewMenegers.end(); it++) {
1624 SUIT_ViewManager* vm = *it;
1625 int nbSf = vm ? vm->getViewsCount() : 0;
1627 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1628 for(int i = 0; i < nbSf; i++){
1629 SUIT_ViewWindow *sf = aViews[i];
1630 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1631 SMESH::RemoveActor(sf,anActor);
1637 /** Remove an object from data structures **/
1638 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1639 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1640 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1641 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1642 aMesh->RemoveGroup( aGroup );
1644 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1645 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1646 aMesh->RemoveSubMesh( aSubMesh );
1648 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1650 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1653 IObject = new SALOME_InteractiveObject
1654 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1655 QString objType = CheckTypeObject(IObject);
1656 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1657 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1658 aStudyBuilder->RemoveObjectWithChildren( SO );
1660 else {// default action: remove SObject from the study
1661 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1662 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1664 aStudyBuilder->RemoveObjectWithChildren( SO );
1668 } /* listSO back loop */
1669 } /* IObject->hasEntry() */
1672 aStudyBuilder->CommitCommand();
1674 /* Clear any previous selection */
1676 aSel->setSelectedObjects( l1 );
1678 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1683 SMESHGUI_EXPORT CAM_Module* createModule()
1685 return new SMESHGUI();
1688 SMESHGUI_EXPORT char* getModuleVersion() {
1689 return (char*)SMESH_VERSION_STR;
1693 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1695 //=============================================================================
1699 //=============================================================================
1700 SMESHGUI::SMESHGUI() :
1701 SalomeApp_Module( "SMESH" ),
1702 LightApp_Module( "SMESH" )
1704 if ( CORBA::is_nil( myComponentSMESH ) )
1706 CORBA::Boolean anIsEmbeddedMode;
1707 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1708 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1710 // 0019923: EDF 765 SMESH : default values of hypothesis
1711 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1712 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1713 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1714 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1715 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1717 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1718 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1719 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1721 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1722 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1726 myActiveDialogBox = 0;
1727 myFilterLibraryDlg = 0;
1731 myEventCallbackCommand = vtkCallbackCommand::New();
1732 myEventCallbackCommand->Delete();
1733 myEventCallbackCommand->SetClientData( this );
1734 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1737 SMESH::GetFilterManager();
1738 SMESH::GetPattern();
1739 SMESH::GetMeasurements();
1741 /* load resources for all available meshers */
1742 SMESH::InitAvailableHypotheses();
1745 //=============================================================================
1749 //=============================================================================
1750 SMESHGUI::~SMESHGUI()
1752 #ifdef WITHGENERICOBJ
1753 SMESH::GetFilterManager()->UnRegister();
1754 SMESH::GetMeasurements()->UnRegister();
1756 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1757 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1760 //=============================================================================
1764 //=============================================================================
1765 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1767 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1769 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1774 //=============================================================================
1778 //=============================================================================
1779 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1781 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1785 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1786 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1787 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1788 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1789 return autoUpdate && !exceeded;
1792 //=============================================================================
1796 //=============================================================================
1797 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1799 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1802 //=============================================================================
1806 //=============================================================================
1807 SMESHGUI* SMESHGUI::GetSMESHGUI()
1809 SMESHGUI* smeshMod = 0;
1810 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1813 CAM_Module* module = app->module( "Mesh" );
1814 smeshMod = dynamic_cast<SMESHGUI*>( module );
1817 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1819 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1822 _PTR(Study) aStudy = study->studyDS();
1824 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1833 Standard_EXPORT SMESHGUI* GetComponentGUI()
1835 return SMESHGUI::GetSMESHGUI();
1839 //=============================================================================
1843 //=============================================================================
1844 void SMESHGUI::SetState(int aState)
1849 //=============================================================================
1853 //=============================================================================
1854 void SMESHGUI::ResetState()
1859 //=============================================================================
1863 //=============================================================================
1864 void SMESHGUI::EmitSignalDeactivateDialog()
1866 emit SignalDeactivateActiveDialog();
1869 //=============================================================================
1873 //=============================================================================
1874 void SMESHGUI::EmitSignalStudyFrameChanged()
1876 emit SignalStudyFrameChanged();
1879 //=============================================================================
1883 //=============================================================================
1884 void SMESHGUI::EmitSignalCloseAllDialogs()
1886 emit SignalCloseAllDialogs();
1889 //=============================================================================
1893 //=============================================================================
1894 void SMESHGUI::EmitSignalVisibilityChanged()
1896 emit SignalVisibilityChanged();
1899 //=============================================================================
1903 //=============================================================================
1904 QDialog *SMESHGUI::GetActiveDialogBox()
1906 return myActiveDialogBox;
1909 //=============================================================================
1913 //=============================================================================
1914 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1916 myActiveDialogBox = (QDialog *) aDlg;
1920 //=============================================================================
1924 //=============================================================================
1925 SUIT_Desktop* SMESHGUI::desktop()
1927 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1929 return app->desktop();
1934 //=============================================================================
1938 //=============================================================================
1939 SalomeApp_Study* SMESHGUI::activeStudy()
1941 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1943 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1948 //=============================================================================
1952 //=============================================================================
1953 void SMESHGUI::Modified( bool theIsUpdateActions )
1955 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1956 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1957 appStudy->Modified();
1958 if( theIsUpdateActions )
1959 app->updateActions();
1964 //=============================================================================
1968 //=============================================================================
1969 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1971 /* Here the position is on the bottom right corner - 10 */
1972 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1974 SUIT_Desktop *PP = desktop();
1975 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1976 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1980 //=============================================================================
1984 //=============================================================================
1985 static int isStudyLocked(_PTR(Study) theStudy){
1986 return theStudy->GetProperties()->IsLocked();
1989 static bool checkLock(_PTR(Study) theStudy) {
1990 if (isStudyLocked(theStudy)) {
1991 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1992 QObject::tr("WRN_WARNING"),
1993 QObject::tr("WRN_STUDY_LOCKED") );
1999 //=======================================================================
2000 //function : CheckActiveStudyLocked
2002 //=======================================================================
2004 bool SMESHGUI::isActiveStudyLocked()
2006 _PTR(Study) aStudy = activeStudy()->studyDS();
2007 return checkLock( aStudy );
2010 //=============================================================================
2014 //=============================================================================
2015 bool SMESHGUI::OnGUIEvent( int theCommandID )
2017 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2021 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2022 SUIT_ResourceMgr* mgr = resourceMgr();
2026 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2027 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2030 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2031 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2033 //QAction* act = action( theCommandID );
2035 switch (theCommandID) {
2037 if(checkLock(aStudy)) break;
2048 if(checkLock(aStudy)) break;
2049 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2053 case 150: //MED FILE INFORMATION
2055 SALOME_ListIO selected;
2056 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2058 aSel->selectedObjects( selected );
2059 if( selected.Extent() )
2061 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2062 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2063 if ( !aMesh->_is_nil() )
2065 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2072 case 122: // EXPORT MED
2085 ::ExportMeshToFile(theCommandID);
2089 case 200: // SCALAR BAR
2091 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2092 SALOME_ListIO selected;
2094 aSel->selectedObjects( selected );
2096 if( selected.Extent() ) {
2097 Handle(SALOME_InteractiveObject) anIO = selected.First();
2098 if( anIO->hasEntry() ) {
2099 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2100 anActor->SetControlMode( SMESH_Actor::eNone );
2101 #ifndef DISABLE_PLOT2DVIEWER
2102 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2111 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2116 // dump control distribution data to the text file
2117 ::SaveDistribution();
2123 // show/ distribution
2124 ::ShowDistribution();
2128 #ifndef DISABLE_PLOT2DVIEWER
2131 // plot distribution
2132 ::PlotDistribution();
2143 ::DisableAutoColor();
2146 case 1134: // Clipping
2147 case 1133: // Tranparency
2148 case 1132: // Display preferences (colors, shrink size, line width, ...)
2155 ::SetDisplayMode(theCommandID, myMarkerMap);
2158 //2D quadratic representation
2161 ::SetDisplayMode(theCommandID, myMarkerMap);
2165 case 216: // 0D elements
2168 case 219: // Volumes
2169 case 220: // All Entity
2170 ::SetDisplayEntity(theCommandID);
2173 case 221: // Orientation of faces
2175 LightApp_SelectionMgr* mgr = selectionMgr();
2176 SALOME_ListIO selected; mgr->selectedObjects( selected );
2178 SALOME_ListIteratorOfListIO it(selected);
2179 for( ; it.More(); it.Next()) {
2180 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2181 if(anIObject->hasEntry()) {
2182 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2183 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2192 if(checkLock(aStudy)) break;
2194 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2197 SMESH::UpdateView();
2199 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2200 SMESH::OnVisuException();
2202 catch (...) { // PAL16774 (Crash after display of many groups)
2203 SMESH::OnVisuException();
2207 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2208 aSel->selectedObjects( l );
2209 aSel->setSelectedObjects( l );
2214 case 301: // DISPLAY
2215 case 302: // DISPLAY ONLY
2217 SMESH::EDisplaing anAction;
2218 switch (theCommandID) {
2219 case 300: anAction = SMESH::eErase; break;
2220 case 301: anAction = SMESH::eDisplay; break;
2221 case 302: anAction = SMESH::eDisplayOnly; break;
2224 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2225 SALOME_ListIO sel_objects, to_process;
2227 aSel->selectedObjects( sel_objects );
2229 if( theCommandID==302 )
2231 MESSAGE("anAction = SMESH::eDisplayOnly");
2232 startOperation( myEraseAll );
2235 extractContainers( sel_objects, to_process );
2238 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2242 SALOME_ListIteratorOfListIO It( to_process );
2243 for ( ; It.More(); It.Next()) {
2245 Handle(SALOME_InteractiveObject) IOS = It.Value();
2246 if (IOS->hasEntry()) {
2248 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2249 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2250 break; // PAL16774 (Crash after display of many groups)
2252 if (anAction == SMESH::eDisplayOnly)
2254 MESSAGE("anAction = SMESH::eDisplayOnly");
2255 anAction = SMESH::eDisplay;
2261 // PAL13338 + PAL15161 -->
2262 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2263 MESSAGE("anAction = SMESH::eDisplayOnly");
2264 SMESH::UpdateView();
2265 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2267 // PAL13338 + PAL15161 <--
2269 catch (...) { // PAL16774 (Crash after display of many groups)
2270 SMESH::OnVisuException();
2273 if (anAction == SMESH::eErase) {
2274 MESSAGE("anAction == SMESH::eErase");
2276 aSel->setSelectedObjects( l1 );
2279 aSel->setSelectedObjects( to_process );
2286 if(checkLock(aStudy)) break;
2289 EmitSignalDeactivateDialog();
2291 ( new SMESHGUI_NodesDlg( this ) )->show();
2294 SUIT_MessageBox::warning(desktop(),
2295 tr("SMESH_WRN_WARNING"),
2296 tr("SMESH_WRN_VIEWER_VTK"));
2301 case 2151: // FILTER
2305 EmitSignalDeactivateDialog();
2306 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2311 case 701: // COMPUTE MESH
2312 case 711: // PRECOMPUTE MESH
2313 case 712: // EVALUATE MESH
2314 case 713: // MESH ORDER
2316 if (checkLock(aStudy)) break;
2317 startOperation( theCommandID );
2321 case 702: // Create mesh
2322 case 703: // Create sub-mesh
2323 case 704: // Edit mesh/sub-mesh
2324 startOperation( theCommandID );
2326 case 705: // copy mesh
2328 if (checkLock(aStudy)) break;
2329 EmitSignalDeactivateDialog();
2330 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2333 case 710: // Build compound mesh
2335 if (checkLock(aStudy)) break;
2336 EmitSignalDeactivateDialog();
2337 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2341 case 407: // DIAGONAL INVERSION
2342 case 408: // Delete diagonal
2346 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2347 tr( "NOT_A_VTK_VIEWER" ) );
2351 if ( checkLock( aStudy ) )
2354 /*Standard_Boolean aRes;
2355 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2356 if ( aMesh->_is_nil() )
2358 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2359 tr( "SMESH_BAD_SELECTION" ) );
2363 EmitSignalDeactivateDialog();
2364 if ( theCommandID == 407 )
2365 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2367 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2370 case 409: // Change orientation
2371 case 410: // Union of triangles
2372 case 411: // Cutting of quadrangles
2373 case 419: // Splitting volumes into tetrahedra
2377 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2378 tr( "NOT_A_VTK_VIEWER" ) );
2382 if ( checkLock( aStudy ) )
2385 EmitSignalDeactivateDialog();
2386 SMESHGUI_MultiEditDlg* aDlg = NULL;
2387 if ( theCommandID == 409 )
2388 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2389 else if ( theCommandID == 410 )
2390 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2391 else if ( theCommandID == 419 )
2392 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2394 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2399 case 412: // Smoothing
2401 if(checkLock(aStudy)) break;
2403 EmitSignalDeactivateDialog();
2404 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2407 SUIT_MessageBox::warning(desktop(),
2408 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2412 case 413: // Extrusion
2414 if (checkLock(aStudy)) break;
2416 EmitSignalDeactivateDialog();
2417 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2419 SUIT_MessageBox::warning(desktop(),
2420 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2424 case 414: // Revolution
2426 if(checkLock(aStudy)) break;
2428 EmitSignalDeactivateDialog();
2429 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2432 SUIT_MessageBox::warning(desktop(),
2433 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2437 case 415: // Pattern mapping
2439 if ( checkLock( aStudy ) )
2443 EmitSignalDeactivateDialog();
2444 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2447 SUIT_MessageBox::warning(desktop(),
2448 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2452 case 416: // Extrusion along a path
2454 if (checkLock(aStudy)) break;
2456 EmitSignalDeactivateDialog();
2457 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2459 SUIT_MessageBox::warning(desktop(),
2460 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2464 case 417: // Convert mesh to quadratic
2466 startOperation( 417 );
2467 /* if (checkLock(aStudy)) break;
2469 EmitSignalDeactivateDialog();
2470 new SMESHGUI_ConvToQuadDlg();
2472 SUIT_MessageBox::warning(desktop(),
2473 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2477 case 418: // create 2D mesh from 3D
2479 startOperation( 418 );
2482 case 806: // CREATE GEO GROUP
2484 startOperation( 806 );
2487 case 801: // CREATE GROUP
2491 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2492 tr( "NOT_A_VTK_VIEWER" ) );
2496 if(checkLock(aStudy)) break;
2497 EmitSignalDeactivateDialog();
2498 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2500 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2501 SALOME_ListIO selected;
2503 aSel->selectedObjects( selected );
2505 int nbSel = selected.Extent();
2507 // check if mesh is selected
2508 aMesh = SMESH::GetMeshByIO( selected.First() );
2510 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2515 case 802: // CONSTRUCT GROUP
2519 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2520 tr( "NOT_A_VTK_VIEWER" ) );
2524 if(checkLock(aStudy)) break;
2525 EmitSignalDeactivateDialog();
2527 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2528 SALOME_ListIO selected;
2530 aSel->selectedObjects( selected );
2532 int nbSel = selected.Extent();
2534 // check if submesh is selected
2535 Handle(SALOME_InteractiveObject) IObject = selected.First();
2536 if (IObject->hasEntry()) {
2537 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2539 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2540 if (!aSubMesh->_is_nil()) {
2542 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2543 // get submesh elements list by types
2544 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2545 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2546 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2547 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2548 // create group for each type o elements
2549 QString aName = IObject->getName();
2550 QStringList anEntryList;
2551 if (aNodes->length() > 0) {
2552 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2553 aGroup->Add(aNodes.inout());
2554 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2555 anEntryList.append( aSObject->GetID().c_str() );
2557 if (aEdges->length() > 0) {
2558 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2559 aGroup->Add(aEdges.inout());
2560 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2561 anEntryList.append( aSObject->GetID().c_str() );
2563 if (aFaces->length() > 0) {
2564 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2565 aGroup->Add(aFaces.inout());
2566 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2567 anEntryList.append( aSObject->GetID().c_str() );
2569 if (aVolumes->length() > 0) {
2570 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2571 aGroup->Add(aVolumes.inout());
2572 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2573 anEntryList.append( aSObject->GetID().c_str() );
2576 anApp->browseObjects( anEntryList );
2578 catch(const SALOME::SALOME_Exception & S_ex){
2579 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2586 SUIT_MessageBox::warning(desktop(),
2587 tr("SMESH_WRN_WARNING"),
2588 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2593 case 803: // EDIT GROUP
2597 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2598 tr( "NOT_A_VTK_VIEWER" ) );
2602 if(checkLock(aStudy)) break;
2603 EmitSignalDeactivateDialog();
2605 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2606 SALOME_ListIO selected;
2608 aSel->selectedObjects( selected );
2610 SALOME_ListIteratorOfListIO It (selected);
2611 int nbSelectedGroups = 0;
2612 for ( ; It.More(); It.Next() )
2614 SMESH::SMESH_GroupBase_var aGroup =
2615 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2616 if (!aGroup->_is_nil()) {
2618 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2622 if (nbSelectedGroups == 0)
2624 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2630 case 804: // Add elements to group
2632 if(checkLock(aStudy)) break;
2633 if (myState == 800) {
2634 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2635 if (aDlg) aDlg->onAdd();
2640 case 805: // Remove elements from group
2642 if(checkLock(aStudy)) break;
2643 if (myState == 800) {
2644 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2645 if (aDlg) aDlg->onRemove();
2650 case 815: // Edit GEOM GROUP as standalone
2654 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2655 tr( "NOT_A_VTK_VIEWER" ) );
2659 if(checkLock(aStudy)) break;
2660 EmitSignalDeactivateDialog();
2662 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2663 SALOME_ListIO selected;
2665 aSel->selectedObjects( selected );
2667 SALOME_ListIteratorOfListIO It (selected);
2668 for ( ; It.More(); It.Next() )
2670 SMESH::SMESH_GroupOnGeom_var aGroup =
2671 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2672 if (!aGroup->_is_nil()) {
2673 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2678 SMESH::SMESH_GroupOnFilter_var aGroup =
2679 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2680 if (!aGroup->_is_nil()) {
2681 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2689 case 810: // Union Groups
2690 case 811: // Intersect groups
2691 case 812: // Cut groups
2695 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2696 tr( "NOT_A_VTK_VIEWER" ) );
2700 if ( checkLock( aStudy ) )
2703 EmitSignalDeactivateDialog();
2705 SMESHGUI_GroupOpDlg* aDlg = 0;
2706 if ( theCommandID == 810 )
2707 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2708 else if ( theCommandID == 811 )
2709 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2711 aDlg = new SMESHGUI_CutGroupsDlg( this );
2718 case 814: // Create groups of entities from existing groups of superior dimensions
2720 if ( checkLock( aStudy ) )
2723 EmitSignalDeactivateDialog();
2724 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2730 case 813: // Delete groups with their contents
2734 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2735 tr( "NOT_A_VTK_VIEWER" ) );
2739 if ( checkLock( aStudy ) )
2742 EmitSignalDeactivateDialog();
2744 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2748 case 900: // MESH INFOS
2749 case 903: // WHAT IS
2751 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2752 EmitSignalDeactivateDialog();
2753 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2754 SALOME_ListIO selected;
2756 aSel->selectedObjects( selected );
2758 if ( selected.Extent() > 1 ) { // a dlg for each IO
2759 SALOME_ListIteratorOfListIO It( selected );
2760 for ( ; It.More(); It.Next() ) {
2761 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2762 dlg->showInfo( It.Value() );
2767 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2773 case 904: // FIND ELEM
2775 startOperation( theCommandID );
2779 case 1100: // EDIT HYPOTHESIS
2781 if(checkLock(aStudy)) break;
2783 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2784 SALOME_ListIO selected;
2786 aSel->selectedObjects( selected );
2788 int nbSel = selected.Extent();
2791 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2792 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2794 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2795 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2796 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2797 if ( !aHypothesis->_is_nil() )
2800 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2801 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2803 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2813 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2815 if(checkLock(aStudy)) break;
2816 SUIT_OverrideCursor wc;
2818 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2819 SALOME_ListIO selected;
2821 aSel->selectedObjects( selected, QString::null, false );
2823 SALOME_ListIteratorOfListIO It(selected);
2824 for (int i = 0; It.More(); It.Next(), i++) {
2825 Handle(SALOME_InteractiveObject) IObject = It.Value();
2826 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2829 aSel->setSelectedObjects( l1 );
2834 case 4009: // ELEM0D
2836 case 4021: // TRIANGLE
2838 case 4023: // POLYGON
2842 case 4134: // PYRAMID
2843 case 4135: // OCTA12
2845 if(checkLock(aStudy)) break;
2847 EmitSignalDeactivateDialog();
2848 SMDSAbs_EntityType type = SMDSEntity_Edge;
2849 switch (theCommandID) {
2851 type = SMDSEntity_0D; break;
2853 type = SMDSEntity_Triangle; break;
2855 type = SMDSEntity_Quadrangle; break;
2857 type = SMDSEntity_Tetra; break;
2859 type = SMDSEntity_Polygon; break;
2861 type = SMDSEntity_Hexa; break;
2863 type = SMDSEntity_Penta; break;
2865 type = SMDSEntity_Pyramid; break;
2867 type = SMDSEntity_Hexagonal_Prism; break;
2870 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
2873 SUIT_MessageBox::warning(desktop(),
2874 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2878 case 4033: // POLYHEDRON
2880 if(checkLock(aStudy)) break;
2882 EmitSignalDeactivateDialog();
2883 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2886 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2887 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2891 case 4034: // QUADRATIC EDGE
2892 case 4035: // QUADRATIC TRIANGLE
2893 case 4036: // QUADRATIC QUADRANGLE
2894 case 4136: // BIQUADRATIC QUADRANGLE
2895 case 4037: // QUADRATIC TETRAHEDRON
2896 case 4038: // QUADRATIC PYRAMID
2897 case 4039: // QUADRATIC PENTAHEDRON
2898 case 4040: // QUADRATIC HEXAHEDRON
2899 case 4140: // TRIQUADRATIC HEXAHEDRON
2901 if(checkLock(aStudy)) break;
2903 EmitSignalDeactivateDialog();
2904 SMDSAbs_EntityType type;
2906 switch (theCommandID) {
2908 type = SMDSEntity_Quad_Edge; break;
2910 type = SMDSEntity_Quad_Triangle; break;
2912 type = SMDSEntity_Quad_Quadrangle; break;
2914 type = SMDSEntity_BiQuad_Quadrangle; break;
2916 type = SMDSEntity_Quad_Tetra; break;
2918 type = SMDSEntity_Quad_Pyramid; break;
2920 type = SMDSEntity_Quad_Penta; break;
2922 type = SMDSEntity_Quad_Hexa;
2924 type = SMDSEntity_TriQuad_Hexa;
2928 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2931 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2932 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2936 case 4041: // REMOVES NODES
2938 if(checkLock(aStudy)) break;
2940 EmitSignalDeactivateDialog();
2941 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2944 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2945 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2949 case 4042: // REMOVES ELEMENTS
2951 if(checkLock(aStudy)) break;
2953 EmitSignalDeactivateDialog();
2954 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2958 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2959 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2963 case 4043: { // CLEAR_MESH
2965 if(checkLock(aStudy)) break;
2967 SALOME_ListIO selected;
2968 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2969 aSel->selectedObjects( selected );
2971 SUIT_OverrideCursor wc;
2972 SALOME_ListIteratorOfListIO It (selected);
2973 for ( ; It.More(); It.Next() )
2975 Handle(SALOME_InteractiveObject) IOS = It.Value();
2976 SMESH::SMESH_Mesh_var aMesh =
2977 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2978 if ( aMesh->_is_nil()) continue;
2980 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2982 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2983 SMESH::ModifiedMesh( aMeshSObj, false, true);
2984 // hide groups and submeshes
2985 _PTR(ChildIterator) anIter =
2986 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2987 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2989 _PTR(SObject) so = anIter->Value();
2990 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2993 catch (const SALOME::SALOME_Exception& S_ex){
2995 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2999 SMESH::UpdateView();
3003 case 4044: // REMOVE ORPHAN NODES
3005 if(checkLock(aStudy)) break;
3006 SALOME_ListIO selected;
3007 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3008 aSel->selectedObjects( selected );
3009 if ( selected.Extent() == 1 ) {
3010 Handle(SALOME_InteractiveObject) anIO = selected.First();
3011 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3012 if ( !aMesh->_is_nil() ) {
3013 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3014 tr( "SMESH_WARNING" ),
3015 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3016 SUIT_MessageBox::Yes |
3017 SUIT_MessageBox::No,
3018 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3021 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3022 int removed = aMeshEditor->RemoveOrphanNodes();
3023 SUIT_MessageBox::information(SMESHGUI::desktop(),
3024 tr("SMESH_INFORMATION"),
3025 tr("NB_NODES_REMOVED").arg(removed));
3026 if ( removed > 0 ) {
3027 SMESH::UpdateView();
3028 SMESHGUI::Modified();
3031 catch (const SALOME::SALOME_Exception& S_ex) {
3032 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3041 case 4051: // RENUMBERING NODES
3043 if(checkLock(aStudy)) break;
3045 EmitSignalDeactivateDialog();
3046 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3050 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3051 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3055 case 4052: // RENUMBERING ELEMENTS
3057 if(checkLock(aStudy)) break;
3059 EmitSignalDeactivateDialog();
3060 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3064 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3065 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3069 case 4061: // TRANSLATION
3071 if(checkLock(aStudy)) break;
3073 EmitSignalDeactivateDialog();
3074 ( new SMESHGUI_TranslationDlg( this ) )->show();
3077 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3078 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3082 case 4062: // ROTATION
3084 if(checkLock(aStudy)) break;
3086 EmitSignalDeactivateDialog();
3087 ( new SMESHGUI_RotationDlg( this ) )->show();
3090 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3091 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3095 case 4063: // SYMMETRY
3097 if(checkLock(aStudy)) break;
3099 EmitSignalDeactivateDialog();
3100 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3103 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3104 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3108 case 4064: // SEWING
3110 if(checkLock(aStudy)) break;
3112 EmitSignalDeactivateDialog();
3113 ( new SMESHGUI_SewingDlg( this ) )->show();
3116 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3117 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3121 case 4065: // MERGE NODES
3123 if(checkLock(aStudy)) break;
3125 EmitSignalDeactivateDialog();
3126 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3129 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3130 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3134 case 4066: // MERGE EQUAL ELEMENTS
3136 if (checkLock(aStudy)) break;
3138 EmitSignalDeactivateDialog();
3139 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3141 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3142 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3147 case 4067: // MAKE MESH PASS THROUGH POINT
3148 startOperation( 4067 );
3153 if(checkLock(aStudy)) break;
3155 EmitSignalDeactivateDialog();
3156 ( new SMESHGUI_ScaleDlg( this ) )->show();
3159 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3160 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3165 case 4069: // DUPLICATE NODES
3167 if(checkLock(aStudy)) break;
3169 EmitSignalDeactivateDialog();
3170 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3173 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3174 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3179 case 5105: // Library of selection filters
3181 static QList<int> aTypes;
3182 if ( aTypes.isEmpty() )
3184 aTypes.append( SMESH::NODE );
3185 aTypes.append( SMESH::EDGE );
3186 aTypes.append( SMESH::FACE );
3187 aTypes.append( SMESH::VOLUME );
3189 if (!myFilterLibraryDlg)
3190 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3191 else if (myFilterLibraryDlg->isHidden())
3192 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3193 myFilterLibraryDlg->raise();
3197 case 6017: // CONTROLS
3225 LightApp_SelectionMgr* mgr = selectionMgr();
3226 SALOME_ListIO selected; mgr->selectedObjects( selected );
3228 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3229 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3231 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3232 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3233 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3234 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3235 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3236 ::Control( theCommandID );
3241 SUIT_MessageBox::warning(desktop(),
3242 tr( "SMESH_WRN_WARNING" ),
3243 tr( "SMESH_BAD_SELECTION" ) );
3247 SUIT_MessageBox::warning(desktop(),
3248 tr( "SMESH_WRN_WARNING" ),
3249 tr( "NOT_A_VTK_VIEWER" ) );
3254 LightApp_SelectionMgr* mgr = selectionMgr();
3255 SALOME_ListIO selected; mgr->selectedObjects( selected );
3257 SALOME_ListIteratorOfListIO it(selected);
3258 for( ; it.More(); it.Next()) {
3259 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3260 if(anIObject->hasEntry()) {
3261 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3262 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3270 LightApp_SelectionMgr* mgr = selectionMgr();
3271 SALOME_ListIO selected; mgr->selectedObjects( selected );
3273 SALOME_ListIteratorOfListIO it(selected);
3274 for( ; it.More(); it.Next()) {
3275 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3276 if(anIObject->hasEntry())
3277 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3278 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3286 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3287 EmitSignalDeactivateDialog();
3288 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3294 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3295 //updateObjBrowser();
3299 //=============================================================================
3303 //=============================================================================
3304 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3309 //=============================================================================
3313 //=============================================================================
3314 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3319 //=============================================================================
3323 //=============================================================================
3324 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3329 //=============================================================================
3330 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3331 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3333 //=============================================================================
3334 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3335 SUIT_ViewWindow* wnd )
3337 if(theIO->hasEntry()){
3338 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3339 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3343 //=======================================================================
3344 // function : createSMESHAction
3346 //=======================================================================
3347 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3348 const int key, const bool toggle, const QString& shortcutAction )
3351 QWidget* parent = application()->desktop();
3352 SUIT_ResourceMgr* resMgr = resourceMgr();
3354 if ( !icon_id.isEmpty() )
3355 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3357 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3358 if ( !pix.isNull() )
3359 icon = QIcon( pix );
3361 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3362 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3363 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3365 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3366 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3369 //=======================================================================
3370 // function : createPopupItem
3372 //=======================================================================
3373 void SMESHGUI::createPopupItem( const int id,
3374 const QString& clients,
3375 const QString& types,
3376 const QString& theRule,
3381 parentId = popupMgr()->actionId( action( pId ) );
3383 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3384 popupMgr()->insert( action( id ), parentId, 0 );
3386 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3387 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3388 QString rule = "(%1) and (%2) and (%3)";
3389 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3390 if( clients.isEmpty() )
3391 rule = rule.arg( QString( "true" ) );
3393 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3394 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3397 bool cont = myRules.contains( id );
3399 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3401 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3402 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3405 //=======================================================================
3406 // function : initialize
3408 //=======================================================================
3409 void SMESHGUI::initialize( CAM_Application* app )
3411 SalomeApp_Module::initialize( app );
3413 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3415 /* Automatic Update flag */
3416 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3418 // ----- create actions --------------
3420 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3421 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3422 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3423 createSMESHAction( 114, "NUM" );
3424 createSMESHAction( 115, "STL" );
3425 createSMESHAction( 116, "CGNS" );
3426 createSMESHAction( 117, "SAUV" );
3427 createSMESHAction( 121, "DAT" );
3428 createSMESHAction( 122, "MED" );
3429 createSMESHAction( 123, "UNV" );
3430 createSMESHAction( 140, "STL" );
3431 createSMESHAction( 142, "CGNS" );
3432 createSMESHAction( 144, "SAUV" );
3433 createSMESHAction( 124, "EXPORT_DAT" );
3434 createSMESHAction( 125, "EXPORT_MED" );
3435 createSMESHAction( 126, "EXPORT_UNV" );
3436 createSMESHAction( 141, "EXPORT_STL" );
3437 createSMESHAction( 143, "EXPORT_CGNS" );
3438 createSMESHAction( 145, "EXPORT_SAUV" );
3439 createSMESHAction( 150, "FILE_INFO" );
3440 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3441 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3442 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3443 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3444 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3445 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3446 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3447 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3448 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3449 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3450 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3451 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3452 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3453 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3454 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3455 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3456 createSMESHAction( 804, "ADD" );
3457 createSMESHAction( 805, "REMOVE" );
3458 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3459 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3460 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3461 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3462 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3463 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3464 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3465 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3466 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3467 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3468 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3469 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3470 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3471 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3472 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3473 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3474 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3475 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3476 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3477 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3478 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3479 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3480 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3481 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3482 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3483 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3484 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3485 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3486 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3487 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3488 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3489 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3490 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3491 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3492 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3493 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3494 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3495 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3496 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3497 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3498 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3499 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3500 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3501 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3502 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3503 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3504 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3505 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3506 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3507 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3508 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3509 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3510 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3511 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3512 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3513 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3514 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3515 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3516 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3517 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3518 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3519 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3520 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3521 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3522 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3523 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3524 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3525 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3526 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3527 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3528 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3529 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3530 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3531 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3532 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3533 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3534 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3535 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3536 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3537 createSMESHAction( 415, "MAP", "ICON_MAP" );
3538 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3539 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3540 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3541 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3542 createSMESHAction( 200, "RESET" );
3543 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3544 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3545 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3546 #ifndef DISABLE_PLOT2DVIEWER
3547 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3549 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3550 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3551 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3552 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3553 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3554 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3555 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3556 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3557 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3558 createSMESHAction( 220, "ALL" );
3559 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3561 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3562 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3564 createSMESHAction( 1100, "EDIT_HYPO" );
3565 createSMESHAction( 1102, "UNASSIGN" );
3566 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3567 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3568 createSMESHAction( 1131, "DISPMODE" );
3569 createSMESHAction( 1132, "COLORS" );
3570 createSMESHAction( 1133, "TRANSP" );
3571 createSMESHAction( 1134, "CLIP" );
3572 createSMESHAction( 1135, "DISP_ENT" );
3573 createSMESHAction( 1136, "AUTO_COLOR" );
3574 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3575 createSMESHAction( 2000, "CTRL" );
3577 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3578 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3580 createSMESHAction( 300, "ERASE" );
3581 createSMESHAction( 301, "DISPLAY" );
3582 createSMESHAction( 302, "DISPLAY_ONLY" );
3584 // ----- create menu --------------
3585 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3586 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3587 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3588 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3589 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3590 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3591 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3592 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3594 createMenu( separator(), fileId );
3596 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3597 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3598 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3599 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3600 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3601 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3602 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3603 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3604 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3605 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3607 createMenu( 111, importId, -1 );
3608 createMenu( 112, importId, -1 );
3609 createMenu( 113, importId, -1 );
3610 createMenu( 115, importId, -1 );
3612 createMenu( 116, importId, -1 );
3614 createMenu( 117, importId, -1 );
3615 createMenu( 121, exportId, -1 );
3616 createMenu( 122, exportId, -1 );
3617 createMenu( 123, exportId, -1 );
3618 createMenu( 140, exportId, -1 ); // export to STL
3620 createMenu( 142, exportId, -1 ); // export to CGNS
3622 createMenu( 144, exportId, -1 ); // export to SAUV
3623 createMenu( separator(), fileId, 10 );
3625 createMenu( 33, editId, -1 );
3627 createMenu( 5105, toolsId, -1 );
3629 createMenu( 702, meshId, -1 ); // "Mesh" menu
3630 createMenu( 703, meshId, -1 );
3631 createMenu( 704, meshId, -1 );
3632 createMenu( 710, meshId, -1 );
3633 createMenu( 705, meshId, -1 );
3634 createMenu( separator(), meshId, -1 );
3635 createMenu( 701, meshId, -1 );
3636 createMenu( 711, meshId, -1 );
3637 createMenu( 712, meshId, -1 );
3638 createMenu( 713, meshId, -1 );
3639 createMenu( separator(), meshId, -1 );
3640 createMenu( 801, meshId, -1 );
3641 createMenu( 806, meshId, -1 );
3642 createMenu( 802, meshId, -1 );
3643 createMenu( 803, meshId, -1 );
3644 createMenu( 815, meshId, -1 );
3645 createMenu( separator(), meshId, -1 );
3646 createMenu( 810, meshId, -1 );
3647 createMenu( 811, meshId, -1 );
3648 createMenu( 812, meshId, -1 );
3649 createMenu( separator(), meshId, -1 );
3650 createMenu( 814, meshId, -1 );
3651 createMenu( separator(), meshId, -1 );
3652 createMenu( 900, meshId, -1 );
3653 //createMenu( 902, meshId, -1 );
3654 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3655 createMenu( 904, meshId, -1 );
3656 createMenu( separator(), meshId, -1 );
3658 createMenu( 6005, nodeId, -1 );
3659 createMenu( 6028, nodeId, -1 );
3660 createMenu( 6002, edgeId, -1 );
3661 createMenu( 6003, edgeId, -1 );
3662 createMenu( 6001, edgeId, -1 );
3663 createMenu( 6004, edgeId, -1 );
3664 createMenu( 6029, edgeId, -1 );
3665 createMenu( 6021, faceId, -1 );
3666 createMenu( 6025, faceId, -1 );
3667 createMenu( 6027, faceId, -1 );
3668 createMenu( 6018, faceId, -1 );
3669 createMenu( 6019, faceId, -1 );
3670 createMenu( 6011, faceId, -1 );
3671 createMenu( 6012, faceId, -1 );
3672 createMenu( 6013, faceId, -1 );
3673 createMenu( 6014, faceId, -1 );
3674 createMenu( 6015, faceId, -1 );
3675 createMenu( 6016, faceId, -1 );
3676 createMenu( 6022, faceId, -1 );
3677 createMenu( 6030, faceId, -1 );
3678 createMenu( 6017, volumeId, -1 );
3679 createMenu( 6009, volumeId, -1 );
3680 createMenu( 6023, volumeId, -1 );
3681 createMenu( 6024, volumeId, -1 );
3682 createMenu( 6026, volumeId, -1 );
3683 createMenu( 6031, volumeId, -1 );
3685 createMenu( 4000, addId, -1 );
3686 createMenu( 4009, addId, -1 );
3687 createMenu( 4010, addId, -1 );
3688 createMenu( 4021, addId, -1 );
3689 createMenu( 4022, addId, -1 );
3690 createMenu( 4023, addId, -1 );
3691 createMenu( 4031, addId, -1 );
3692 createMenu( 4032, addId, -1 );
3693 createMenu( 4133, addId, -1 );
3694 createMenu( 4134, addId, -1 );
3695 createMenu( 4135, addId, -1 );
3696 createMenu( 4033, addId, -1 );
3697 createMenu( separator(), addId, -1 );
3698 createMenu( 4034, addId, -1 );
3699 createMenu( 4035, addId, -1 );
3700 createMenu( 4036, addId, -1 );
3701 createMenu( 4136, addId, -1 );
3702 createMenu( 4037, addId, -1 );
3703 createMenu( 4038, addId, -1 );
3704 createMenu( 4039, addId, -1 );
3705 createMenu( 4040, addId, -1 );
3706 createMenu( 4140, addId, -1 );
3708 createMenu( 4041, removeId, -1 );
3709 createMenu( 4042, removeId, -1 );
3710 createMenu( 4044, removeId, -1 );
3711 createMenu( separator(), removeId, -1 );
3712 createMenu( 813, removeId, -1 );
3713 createMenu( separator(), removeId, -1 );
3714 createMenu( 4043, removeId, -1 );
3716 createMenu( 4051, renumId, -1 );
3717 createMenu( 4052, renumId, -1 );
3719 createMenu( 4061, transfId, -1 );
3720 createMenu( 4062, transfId, -1 );
3721 createMenu( 4063, transfId, -1 );
3722 createMenu( 4068, transfId, -1 );
3723 createMenu( 4064, transfId, -1 );
3724 createMenu( 4065, transfId, -1 );
3725 createMenu( 4066, transfId, -1 );
3726 createMenu( 4069, transfId, -1 );
3728 createMenu( 4067,modifyId, -1 );
3729 createMenu( 407, modifyId, -1 );
3730 createMenu( 408, modifyId, -1 );
3731 createMenu( 409, modifyId, -1 );
3732 createMenu( 410, modifyId, -1 );
3733 createMenu( 411, modifyId, -1 );
3734 createMenu( 419, modifyId, -1 );
3735 createMenu( 412, modifyId, -1 );
3736 createMenu( 413, modifyId, -1 );
3737 createMenu( 416, modifyId, -1 );
3738 createMenu( 414, modifyId, -1 );
3739 createMenu( 415, modifyId, -1 );
3740 createMenu( 417, modifyId, -1 );
3741 createMenu( 418, modifyId, -1 );
3743 createMenu( 501, measureId, -1 );
3744 createMenu( 502, measureId, -1 );
3745 createMenu( 214, viewId, -1 );
3747 // ----- create toolbars --------------
3748 int meshTb = createTool( tr( "TB_MESH" ) ),
3749 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3750 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3751 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3752 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3754 createTool( 702, meshTb );
3755 createTool( 703, meshTb );
3756 createTool( 704, meshTb );
3757 createTool( 710, meshTb );
3758 createTool( 705, meshTb );
3759 createTool( separator(), meshTb );
3760 createTool( 701, meshTb );
3761 createTool( 711, meshTb );
3762 createTool( 712, meshTb );
3763 createTool( 713, meshTb );
3764 createTool( separator(), meshTb );
3765 createTool( 801, meshTb );
3766 createTool( 806, meshTb );
3767 createTool( 802, meshTb );
3768 createTool( 803, meshTb );
3769 //createTool( 815, meshTb );
3770 createTool( separator(), meshTb );
3771 createTool( 900, meshTb );
3772 //createTool( 902, meshTb );
3773 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3774 createTool( 904, meshTb );
3775 createTool( separator(), meshTb );
3777 createTool( 6005, ctrlTb );
3778 createTool( 6028, ctrlTb );
3779 createTool( separator(), ctrlTb );
3780 createTool( 6002, ctrlTb );
3781 createTool( 6003, ctrlTb );
3782 createTool( 6001, ctrlTb );
3783 createTool( 6004, ctrlTb );
3784 createTool( 6029, ctrlTb );
3785 createTool( separator(), ctrlTb );
3786 createTool( 6021, ctrlTb );
3787 createTool( 6025, ctrlTb );
3788 createTool( 6027, ctrlTb );
3789 createTool( 6018, ctrlTb );
3790 createTool( 6019, ctrlTb );
3791 createTool( 6011, ctrlTb );
3792 createTool( 6012, ctrlTb );
3793 createTool( 6013, ctrlTb );
3794 createTool( 6014, ctrlTb );
3795 createTool( 6015, ctrlTb );
3796 createTool( 6016, ctrlTb );
3797 createTool( 6022, ctrlTb );
3798 createTool( 6030, ctrlTb );
3799 createTool( separator(), ctrlTb );
3800 createTool( 6017, ctrlTb );
3801 createTool( 6009, ctrlTb );
3802 createTool( 6023, ctrlTb );
3803 createTool( 6024, ctrlTb );
3804 createTool( 6026, ctrlTb );
3805 createTool( 6031, ctrlTb );
3806 createTool( separator(), ctrlTb );
3808 createTool( 4000, addRemTb );
3809 createTool( 4009, addRemTb );
3810 createTool( 4010, addRemTb );
3811 createTool( 4021, addRemTb );
3812 createTool( 4022, addRemTb );
3813 createTool( 4023, addRemTb );
3814 createTool( 4031, addRemTb );
3815 createTool( 4032, addRemTb );
3816 createTool( 4133, addRemTb );
3817 createTool( 4134, addRemTb );
3818 createTool( 4135, addRemTb );
3819 createTool( 4033, addRemTb );
3820 createTool( separator(), addRemTb );
3821 createTool( 4034, addRemTb );
3822 createTool( 4035, addRemTb );
3823 createTool( 4036, addRemTb );
3824 createTool( 4136, addRemTb );
3825 createTool( 4037, addRemTb );
3826 createTool( 4038, addRemTb );
3827 createTool( 4039, addRemTb );
3828 createTool( 4040, addRemTb );
3829 createTool( 4140, addRemTb );
3830 createTool( separator(), addRemTb );
3831 createTool( 4041, addRemTb );
3832 createTool( 4042, addRemTb );
3833 createTool( 4044, addRemTb );
3834 createTool( 4043, addRemTb );
3835 createTool( separator(), addRemTb );
3836 createTool( 4051, addRemTb );
3837 createTool( 4052, addRemTb );
3838 createTool( separator(), addRemTb );
3839 createTool( 4061, addRemTb );
3840 createTool( 4062, addRemTb );
3841 createTool( 4063, addRemTb );
3842 createTool( 4068, addRemTb );
3843 createTool( 4064, addRemTb );
3844 createTool( 4065, addRemTb );
3845 createTool( 4066, addRemTb );
3846 createTool( 4069, addRemTb );
3847 createTool( separator(), addRemTb );
3849 createTool( 4067,modifyTb );
3850 createTool( 407, modifyTb );
3851 createTool( 408, modifyTb );
3852 createTool( 409, modifyTb );
3853 createTool( 410, modifyTb );
3854 createTool( 411, modifyTb );
3855 createTool( 419, modifyTb );
3856 createTool( 412, modifyTb );
3857 createTool( 413, modifyTb );
3858 createTool( 416, modifyTb );
3859 createTool( 414, modifyTb );
3860 createTool( 415, modifyTb );
3861 createTool( 417, modifyTb );
3862 createTool( 418, modifyTb );
3864 createTool( 214, dispModeTb );
3866 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3867 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3870 QString OB = "'ObjectBrowser'",
3871 View = "'" + SVTK_Viewer::Type() + "'",
3873 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3874 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3875 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3876 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3877 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3878 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3879 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3880 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3881 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3882 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3883 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3885 mesh_part = mesh + " " + subMesh + " " + group,
3886 mesh_group = mesh + " " + group,
3887 hyp_alg = hypo + " " + algo;
3889 // popup for object browser
3891 isInvisible("not( isVisible )"),
3892 isEmpty("numberOfNodes = 0"),
3893 isNotEmpty("numberOfNodes <> 0"),
3895 // has nodes, edges, etc in VISIBLE! actor
3896 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3897 hasElems("(count( elemTypes ) > 0)"),
3898 hasDifferentElems("(count( elemTypes ) > 1)"),
3899 hasElems0d("({'Elem0d'} in elemTypes)"),
3900 hasEdges("({'Edge'} in elemTypes)"),
3901 hasFaces("({'Face'} in elemTypes)"),
3902 hasVolumes("({'Volume'} in elemTypes)");
3904 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3905 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3906 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3907 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3908 createPopupItem( 803, OB, group ); // EDIT_GROUP
3909 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3911 popupMgr()->insert( separator(), -1, 0 );
3912 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3913 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3914 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3915 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3916 createPopupItem( 214, OB, mesh_part ); // UPDATE
3917 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3918 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3919 popupMgr()->insert( separator(), -1, 0 );
3920 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3921 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3922 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3923 popupMgr()->insert( separator(), -1, 0 );
3924 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3925 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3926 popupMgr()->insert( separator(), -1, 0 );
3927 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3928 popupMgr()->insert( separator(), -1, 0 );
3929 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3930 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3932 popupMgr()->insert( separator(), -1, 0 );
3934 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3935 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3936 QString only_one_2D = only_one_non_empty + " && dim>1";
3938 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3939 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3940 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3942 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3944 createPopupItem( 145, OB, mesh_group, multiple_non_empty ); // EXPORT_SAUV
3945 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3946 popupMgr()->insert( separator(), -1, 0 );
3949 createPopupItem( 803, View, group ); // EDIT_GROUP
3950 createPopupItem( 804, View, elems ); // ADD
3951 createPopupItem( 805, View, elems ); // REMOVE
3953 popupMgr()->insert( separator(), -1, 0 );
3954 createPopupItem( 214, View, mesh_part ); // UPDATE
3955 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3956 createPopupItem( 904, View, mesh ); // FIND_ELEM
3957 popupMgr()->insert( separator(), -1, 0 );
3959 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3960 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3961 popupMgr()->insert( separator(), -1, 0 );
3964 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3965 QString aType = QString( "%1type in {%2}" ).arg( lc );
3966 aType = aType.arg( mesh_part );
3967 QString aMeshInVTK = aClient + "&&" + aType;
3969 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3970 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3971 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3973 //-------------------------------------------------
3975 //-------------------------------------------------
3976 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3978 popupMgr()->insert( action( 9010 ), anId, -1 );
3979 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3980 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3982 popupMgr()->insert( action( 9011 ), anId, -1 );
3983 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3984 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3986 popupMgr()->insert( separator(), -1, -1 );
3988 //-------------------------------------------------
3990 //-------------------------------------------------
3991 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3993 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3994 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3995 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3997 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3998 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3999 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4001 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4002 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4003 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4005 popupMgr()->insert( separator(), anId, -1 );
4007 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4008 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4009 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4011 //-------------------------------------------------
4013 //-------------------------------------------------
4014 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4016 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4018 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4019 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4020 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4022 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4023 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4024 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4026 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4027 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4028 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4030 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4031 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4032 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4034 popupMgr()->insert( separator(), anId, -1 );
4036 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4037 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4040 //-------------------------------------------------
4041 // Representation of the 2D Quadratic elements
4042 //-------------------------------------------------
4043 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4044 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4045 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4046 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4048 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4049 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4050 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4052 //-------------------------------------------------
4053 // Orientation of faces
4054 //-------------------------------------------------
4055 popupMgr()->insert( action( 221 ), -1, -1 );
4056 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4057 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4059 //-------------------------------------------------
4061 //-------------------------------------------------
4062 popupMgr()->insert( action( 1132 ), -1, -1 );
4063 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4065 //-------------------------------------------------
4067 //-------------------------------------------------
4068 popupMgr()->insert( action( 1133 ), -1, -1 );
4069 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4071 //-------------------------------------------------
4073 //-------------------------------------------------
4075 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4076 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4077 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4078 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4080 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4082 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4083 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4085 popupMgr()->insert( separator(), anId, -1 );
4087 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4089 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4090 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4091 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4093 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4094 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4095 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4097 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4099 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4100 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4101 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4103 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4104 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4105 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4107 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4108 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4109 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4111 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4112 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4113 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4114 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4115 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4116 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4118 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4120 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4121 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4122 QtxPopupMgr::VisibleRule );
4123 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4125 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4126 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4127 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4129 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4130 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4131 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4133 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4134 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4135 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4137 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4138 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4139 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4141 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4142 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4143 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4145 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4146 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4147 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4149 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4150 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4151 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4153 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4154 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4155 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4157 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4158 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4159 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4161 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4162 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4163 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4165 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4166 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4167 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4168 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4169 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4170 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4172 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4174 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4175 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4176 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4178 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4179 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4180 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4182 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4183 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4184 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4186 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4187 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4188 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4190 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4191 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4192 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4194 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4195 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4196 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4198 popupMgr()->insert( separator(), anId, -1 );
4200 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4201 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4203 popupMgr()->insert( separator(), anId, -1 );
4205 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4207 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4208 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4210 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4211 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4212 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4214 #ifndef DISABLE_PLOT2DVIEWER
4215 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4216 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4219 //-------------------------------------------------
4221 //-------------------------------------------------
4222 popupMgr()->insert( separator(), -1, -1 );
4223 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4224 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4225 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4226 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4228 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4229 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4231 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4232 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4234 popupMgr()->insert( separator(), -1, -1 );
4236 //-------------------------------------------------
4238 //-------------------------------------------------
4239 popupMgr()->insert( action( 1134 ), -1, -1 );
4240 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4242 popupMgr()->insert( separator(), -1, -1 );
4244 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4245 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4247 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4248 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4251 //================================================================================
4253 * \brief Return true if SMESH or GEOM objects are selected.
4254 * Is called form LightApp_Module::activateModule() which clear selection if
4255 * not isSelectionCompatible()
4257 //================================================================================
4259 bool SMESHGUI::isSelectionCompatible()
4261 bool isCompatible = true;
4262 SALOME_ListIO selected;
4263 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4264 Sel->selectedObjects( selected );
4266 SALOME_ListIteratorOfListIO It( selected );
4267 for ( ; isCompatible && It.More(); It.Next())
4269 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4270 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4272 return isCompatible;
4276 bool SMESHGUI::reusableOperation( const int id )
4278 // compute, evaluate and precompute are not reusable operations
4279 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4282 bool SMESHGUI::activateModule( SUIT_Study* study )
4284 bool res = SalomeApp_Module::activateModule( study );
4286 setMenuShown( true );
4287 setToolShown( true );
4289 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4290 PyGILState_STATE gstate = PyGILState_Ensure();
4291 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4292 if(pluginsmanager==NULL)
4296 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4301 PyGILState_Release(gstate);
4302 // end of GEOM plugins loading
4304 // Reset actions accelerator keys
4305 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4306 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4307 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4309 action( 33)->setEnabled(true); // Delete: Key_Delete
4311 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4312 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4313 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4314 if ( _PTR(Study) aStudy = s->studyDS()) {
4315 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4316 updateObjBrowser(); // objects can be removed
4319 // get all view currently opened in the study and connect their signals to
4320 // the corresponding slots of the class.
4321 SUIT_Desktop* aDesk = study->application()->desktop();
4323 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4324 SUIT_ViewWindow* wnd;
4325 foreach ( wnd, wndList )
4332 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4334 setMenuShown( false );
4335 setToolShown( false );
4337 EmitSignalCloseAllDialogs();
4339 // Unset actions accelerator keys
4340 action(111)->setShortcut(QKeySequence()); // Import DAT
4341 action(112)->setShortcut(QKeySequence()); // Import UNV
4342 action(113)->setShortcut(QKeySequence()); // Import MED
4344 action( 33)->setEnabled(false); // Delete: Key_Delete
4346 return SalomeApp_Module::deactivateModule( study );
4349 void SMESHGUI::studyClosed( SUIT_Study* s )
4351 SMESH::RemoveVisuData( s->id() );
4352 SalomeApp_Module::studyClosed( s );
4355 void SMESHGUI::OnGUIEvent()
4357 const QObject* obj = sender();
4358 if ( !obj || !obj->inherits( "QAction" ) )
4360 int id = actionId((QAction*)obj);
4365 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4367 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4368 if ( CORBA::is_nil( myComponentSMESH ) )
4370 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4372 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4373 return aGUI.myComponentSMESH;
4376 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4377 return myComponentSMESH;
4380 QString SMESHGUI::engineIOR() const
4382 CORBA::ORB_var anORB = getApp()->orb();
4383 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4384 return QString( anIOR.in() );
4387 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4389 SalomeApp_Module::contextMenuPopup( client, menu, title );
4391 selectionMgr()->selectedObjects( lst );
4392 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4393 Handle(SALOME_InteractiveObject) io = lst.First();
4394 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4395 _PTR(Study) study = appStudy->studyDS();
4396 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4398 QString aName = QString( obj->GetName().c_str() );
4399 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4400 aName.remove( (aName.length() - 1), 1 );
4406 LightApp_Selection* SMESHGUI::createSelection() const
4408 return new SMESHGUI_Selection();
4411 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4413 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4414 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4417 void SMESHGUI::viewManagers( QStringList& list ) const
4419 list.append( SVTK_Viewer::Type() );
4422 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4424 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4425 SMESH::UpdateSelectionProp( this );
4427 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4428 for(int i = 0; i < aViews.count() ; i++){
4429 SUIT_ViewWindow *sf = aViews[i];
4435 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4437 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4438 myClippingPlaneInfoMap.erase( theViewManager );
4441 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4443 theActor->AddObserver( SMESH::DeleteActorEvent,
4444 myEventCallbackCommand.GetPointer(),
4448 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4449 unsigned long theEvent,
4450 void* theClientData,
4453 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4454 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4455 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4456 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4457 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4458 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4459 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4460 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4461 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4462 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4463 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4464 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4465 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4466 if( anActor == *anIter3 ) {
4467 anActorList.erase( anIter3 );
4478 void SMESHGUI::createPreferences()
4480 // General tab ------------------------------------------------------------------------
4481 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4483 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4484 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4485 setPreferenceProperty( lim, "min", 0 );
4486 setPreferenceProperty( lim, "max", 100000000 );
4487 setPreferenceProperty( lim, "step", 1000 );
4488 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4490 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4491 setPreferenceProperty( qaGroup, "columns", 2 );
4492 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4493 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4494 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4495 setPreferenceProperty( prec, "min", 0 );
4496 setPreferenceProperty( prec, "max", 16 );
4497 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4498 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4499 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4500 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4501 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4503 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4504 setPreferenceProperty( dispgroup, "columns", 2 );
4505 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4507 modes.append( tr("MEN_WIRE") );
4508 modes.append( tr("MEN_SHADE") );
4509 modes.append( tr("MEN_NODES") );
4510 modes.append( tr("MEN_SHRINK") );
4511 QList<QVariant> indices;
4512 indices.append( 0 );
4513 indices.append( 1 );
4514 indices.append( 2 );
4515 indices.append( 3 );
4516 setPreferenceProperty( dispmode, "strings", modes );
4517 setPreferenceProperty( dispmode, "indexes", indices );
4519 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4520 setPreferenceProperty( arcgroup, "columns", 2 );
4521 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4522 QStringList quadraticModes;
4523 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4524 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4526 indices.append( 0 );
4527 indices.append( 1 );
4528 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4529 setPreferenceProperty( quadraticmode, "indexes", indices );
4531 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4532 "SMESH", "max_angle" );
4533 setPreferenceProperty( maxAngle, "min", 1 );
4534 setPreferenceProperty( maxAngle, "max", 90 );
4538 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4539 setPreferenceProperty( exportgroup, "columns", 2 );
4540 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4541 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4543 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4544 setPreferenceProperty( computeGroup, "columns", 2 );
4545 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4547 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4548 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4549 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4551 indices.append( 0 );
4552 indices.append( 1 );
4553 indices.append( 2 );
4554 setPreferenceProperty( notifyMode, "strings", modes );
4555 setPreferenceProperty( notifyMode, "indexes", indices );
4557 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4558 setPreferenceProperty( infoGroup, "columns", 4 );
4559 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4561 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4562 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4564 indices.append( 0 );
4565 indices.append( 1 );
4566 setPreferenceProperty( elemInfo, "strings", modes );
4567 setPreferenceProperty( elemInfo, "indexes", indices );
4568 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4569 setPreferenceProperty( nodesLim, "min", 0 );
4570 setPreferenceProperty( nodesLim, "max", 10000000 );
4571 setPreferenceProperty( nodesLim, "step", 10000 );
4572 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4574 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4575 setPreferenceProperty( segGroup, "columns", 2 );
4576 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4577 "SMESH", "segmentation" );
4578 setPreferenceProperty( segLen, "min", 1 );
4579 setPreferenceProperty( segLen, "max", 10000000 );
4580 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4581 "SMESH", "nb_segments_per_edge" );
4582 setPreferenceProperty( nbSeg, "min", 1 );
4583 setPreferenceProperty( nbSeg, "max", 10000000 );
4585 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4586 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4587 "SMESH", "forget_mesh_on_hyp_modif" );
4590 // Quantities with individual precision settings
4591 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4592 setPreferenceProperty( precGroup, "columns", 2 );
4594 const int nbQuantities = 6;
4595 int precs[nbQuantities], ii = 0;
4596 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4597 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4598 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4599 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4600 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4601 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4602 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4603 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4604 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4605 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4606 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4607 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4609 // Set property for precision value for spinboxes
4610 for ( ii = 0; ii < nbQuantities; ii++ ){
4611 setPreferenceProperty( precs[ii], "min", -14 );
4612 setPreferenceProperty( precs[ii], "max", 14 );
4613 setPreferenceProperty( precs[ii], "precision", 2 );
4616 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4617 setPreferenceProperty( previewGroup, "columns", 2 );
4618 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4619 setPreferenceProperty( chunkSize, "min", 0 );
4620 setPreferenceProperty( chunkSize, "max", 1000 );
4621 setPreferenceProperty( chunkSize, "step", 50 );
4623 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4624 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4626 // Mesh tab ------------------------------------------------------------------------
4627 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4628 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4629 setPreferenceProperty( nodeGroup, "columns", 3 );
4631 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4633 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4635 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4636 QList<QVariant> aMarkerTypeIndicesList;
4637 QList<QVariant> aMarkerTypeIconsList;
4638 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4639 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4640 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4641 aMarkerTypeIndicesList << i;
4642 aMarkerTypeIconsList << pixmap;
4644 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4645 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4647 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4649 QList<QVariant> aMarkerScaleIndicesList;
4650 QStringList aMarkerScaleValuesList;
4651 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4652 aMarkerScaleIndicesList << i;
4653 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4655 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4656 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4658 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4659 setPreferenceProperty( elemGroup, "columns", 2 );
4661 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4662 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4664 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4665 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4667 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4669 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4670 setPreferenceProperty( grpGroup, "columns", 2 );
4672 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4674 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4675 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4676 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4677 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4678 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4679 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4681 setPreferenceProperty( size0d, "min", 1 );
4682 setPreferenceProperty( size0d, "max", 10 );
4684 setPreferenceProperty( elemW, "min", 1 );
4685 setPreferenceProperty( elemW, "max", 5 );
4687 setPreferenceProperty( shrink, "min", 0 );
4688 setPreferenceProperty( shrink, "max", 100 );
4690 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4691 setPreferenceProperty( orientGroup, "columns", 1 );
4693 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4694 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4696 setPreferenceProperty( orientScale, "min", 0.05 );
4697 setPreferenceProperty( orientScale, "max", 0.5 );
4698 setPreferenceProperty( orientScale, "step", 0.05 );
4700 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4702 // Selection tab ------------------------------------------------------------------------
4703 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4705 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4706 setPreferenceProperty( selGroup, "columns", 2 );
4708 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4709 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4711 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4712 setPreferenceProperty( preGroup, "columns", 2 );
4714 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4716 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4717 setPreferenceProperty( precSelGroup, "columns", 2 );
4719 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4720 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4721 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4723 // Scalar Bar tab ------------------------------------------------------------------------
4724 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4725 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4726 setPreferenceProperty( fontGr, "columns", 2 );
4728 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4729 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4731 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4732 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4734 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4735 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4737 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4738 setPreferenceProperty( numcol, "min", 2 );
4739 setPreferenceProperty( numcol, "max", 256 );
4741 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4742 setPreferenceProperty( numlab, "min", 2 );
4743 setPreferenceProperty( numlab, "max", 65 );
4745 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4746 setPreferenceProperty( orientGr, "columns", 2 );
4747 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4748 QStringList orients;
4749 orients.append( tr( "SMESH_VERTICAL" ) );
4750 orients.append( tr( "SMESH_HORIZONTAL" ) );
4751 indices.clear(); indices.append( 0 ); indices.append( 1 );
4752 setPreferenceProperty( orient, "strings", orients );
4753 setPreferenceProperty( orient, "indexes", indices );
4755 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4756 setPreferenceProperty( posVSizeGr, "columns", 2 );
4757 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4758 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4759 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4760 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4761 setPreferenceProperty( xv, "step", 0.1 );
4762 setPreferenceProperty( xv, "min", 0.0 );
4763 setPreferenceProperty( xv, "max", 1.0 );
4764 setPreferenceProperty( yv, "step", 0.1 );
4765 setPreferenceProperty( yv, "min", 0.0 );
4766 setPreferenceProperty( yv, "max", 1.0 );
4767 setPreferenceProperty( wv, "step", 0.1 );
4768 setPreferenceProperty( wv, "min", 0.0 );
4769 setPreferenceProperty( wv, "max", 1.0 );
4770 setPreferenceProperty( hv, "min", 0.0 );
4771 setPreferenceProperty( hv, "max", 1.0 );
4772 setPreferenceProperty( hv, "step", 0.1 );
4774 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4775 setPreferenceProperty( posHSizeGr, "columns", 2 );
4776 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4777 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4778 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4779 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4780 setPreferenceProperty( xv, "min", 0.0 );
4781 setPreferenceProperty( xv, "max", 1.0 );
4782 setPreferenceProperty( xv, "step", 0.1 );
4783 setPreferenceProperty( xh, "min", 0.0 );
4784 setPreferenceProperty( xh, "max", 1.0 );
4785 setPreferenceProperty( xh, "step", 0.1 );
4786 setPreferenceProperty( yh, "min", 0.0 );
4787 setPreferenceProperty( yh, "max", 1.0 );
4788 setPreferenceProperty( yh, "step", 0.1 );
4789 setPreferenceProperty( wh, "min", 0.0 );
4790 setPreferenceProperty( wh, "max", 1.0 );
4791 setPreferenceProperty( wh, "step", 0.1 );
4792 setPreferenceProperty( hh, "min", 0.0 );
4793 setPreferenceProperty( hh, "max", 1.0 );
4794 setPreferenceProperty( hh, "step", 0.1 );
4796 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4797 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4798 setPreferenceProperty( distributionGr, "columns", 3 );
4800 types.append( tr( "SMESH_MONOCOLOR" ) );
4801 types.append( tr( "SMESH_MULTICOLOR" ) );
4802 indices.clear(); indices.append( 0 ); indices.append( 1 );
4803 setPreferenceProperty( coloringType, "strings", types );
4804 setPreferenceProperty( coloringType, "indexes", indices );
4805 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4809 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4811 if( sect=="SMESH" ) {
4812 float sbX1,sbY1,sbW,sbH;
4813 float aTol = 1.00000009999999;
4814 std::string aWarning;
4815 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4816 if( name=="selection_object_color" || name=="selection_element_color" ||
4817 name=="highlight_color" ||
4818 name=="selection_precision_node" || name=="selection_precision_element" ||
4819 name=="selection_precision_object")
4820 SMESH::UpdateSelectionProp( this );
4821 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4822 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4823 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4824 if(sbX1+sbW > aTol){
4825 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4828 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4829 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4832 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4833 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4834 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4835 if(sbY1+sbH > aTol){
4836 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4837 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4838 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4841 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4842 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4843 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4844 if(sbX1+sbW > aTol){
4845 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4848 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4849 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4852 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4853 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4854 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4855 if(sbY1+sbH > aTol){
4856 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4859 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4860 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4863 else if ( name == "segmentation" ) {
4864 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4865 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4867 else if ( name == "nb_segments_per_edge" ) {
4868 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4869 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4871 else if ( name == "historical_python_dump" ||
4872 name == "forget_mesh_on_hyp_modif") {
4873 QString val = aResourceMgr->stringValue( "SMESH", name );
4874 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
4877 if(aWarning.size() != 0){
4878 aWarning += "The default values are applied instead.";
4879 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4880 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4881 QObject::tr(aWarning.c_str()));
4886 //================================================================================
4888 * \brief Update something in accordance with update flags
4889 * \param theFlags - update flags
4891 * Update viewer or/and object browser etc. in accordance with update flags ( see
4892 * LightApp_UpdateFlags enumeration ).
4894 //================================================================================
4895 void SMESHGUI::update( const int flags )
4897 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4898 SMESH::UpdateView();
4900 SalomeApp_Module::update( flags );
4903 //================================================================================
4905 * \brief Set default selection mode
4907 * SLOT called when operation commited. Sets default selection mode
4909 //================================================================================
4910 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4912 SVTK_ViewWindow* vtkWnd =
4913 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4915 vtkWnd->SetSelectionMode( ActorSelection );
4918 //================================================================================
4920 * \brief Set default selection mode
4922 * SLOT called when operation aborted. Sets default selection mode
4924 //================================================================================
4925 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4927 SVTK_ViewWindow* vtkWnd =
4928 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4930 vtkWnd->SetSelectionMode( ActorSelection );
4933 //================================================================================
4935 * \brief Creates operation with given identifier
4936 * \param id - identifier of operation to be started
4937 * \return Pointer on created operation or NULL if operation is not created
4939 * Virtual method redefined from the base class creates operation with given id.
4940 * It is called called automatically from startOperation method of base class.
4942 //================================================================================
4943 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4945 LightApp_Operation* op = 0;
4946 // to do : create operation here
4949 case 417: //convert to quadratic
4950 op = new SMESHGUI_ConvToQuadOp();
4952 case 418: // create 2D mesh as boundary on 3D
4953 op = new SMESHGUI_Make2DFrom3DOp();
4955 case 701: // Compute mesh
4956 op = new SMESHGUI_ComputeOp();
4958 case 702: // Create mesh
4959 op = new SMESHGUI_MeshOp( true, true );
4961 case 703: // Create sub-mesh
4962 op = new SMESHGUI_MeshOp( true, false );
4964 case 704: // Edit mesh/sub-mesh
4965 op = new SMESHGUI_MeshOp( false );
4967 case 711: // Precompute mesh
4968 op = new SMESHGUI_PrecomputeOp();
4970 case 712: // Evaluate mesh
4971 op = new SMESHGUI_EvaluateOp();
4973 case 713: // Evaluate mesh
4974 op = new SMESHGUI_MeshOrderOp();
4976 case 806: // Create group on geom
4977 op = new SMESHGUI_GroupOnShapeOp();
4979 case 904: // Find element
4980 op = new SMESHGUI_FindElemByPointOp();
4982 case 4067: // make mesh pass through point
4983 op = new SMESHGUI_MakeNodeAtPointOp();
4990 op = SalomeApp_Module::createOperation( id );
4994 //================================================================================
4996 * \brief Stops current operations and starts a given one
4997 * \param id - The id of the operation to start
4999 //================================================================================
5001 void SMESHGUI::switchToOperation(int id)
5003 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5004 activeStudy()->abortAllOperations();
5005 startOperation( id );
5008 LightApp_Displayer* SMESHGUI::displayer()
5011 myDisplayer = new SMESHGUI_Displayer( getApp() );
5015 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5018 int aTolerance = 64;
5019 int anIterations = 0;
5025 if( anIterations % aPeriod == 0 )
5028 if( aTolerance < 1 )
5032 aHue = (int)( 360.0 * rand() / RAND_MAX );
5035 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5036 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5037 for( ; it != itEnd; ++it )
5039 SALOMEDS::Color anAutoColor = *it;
5040 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5043 aQColor.getHsv( &h, &s, &v );
5044 if( abs( h - aHue ) < aTolerance )
5056 aColor.setHsv( aHue, 255, 255 );
5058 SALOMEDS::Color aSColor;
5059 aSColor.R = (double)aColor.red() / 255.0;
5060 aSColor.G = (double)aColor.green() / 255.0;
5061 aSColor.B = (double)aColor.blue() / 255.0;
5066 const char gSeparator = '_'; // character used to separate parameter names
5067 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
5068 const char gPathSep = '|'; // character used to separate paths
5071 * \brief Store visual parameters
5073 * This method is called just before the study document is saved.
5074 * Store visual parameters in AttributeParameter attribue(s)
5076 void SMESHGUI::storeVisualParameters (int savePoint)
5078 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5079 if (!appStudy || !appStudy->studyDS())
5081 _PTR(Study) studyDS = appStudy->studyDS();
5083 // componentName is used for encoding of entries when storing them in IParameters
5084 std::string componentName = myComponentSMESH->ComponentDataType();
5085 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5086 //if (!aSComponent) return;
5089 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5090 componentName.c_str(),
5092 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5094 // store map of custom markers
5095 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5096 if( !aMarkerMap.empty() )
5098 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5099 for( ; anIter != aMarkerMap.end(); anIter++ )
5101 int anId = anIter->first;
5102 VTK::MarkerData aMarkerData = anIter->second;
5103 std::string aMarkerFileName = aMarkerData.first;
5104 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5105 if( aMarkerTexture.size() < 3 )
5106 continue; // should contain at least width, height and the first value
5108 QString aPropertyName( "texture" );
5109 aPropertyName += gSeparator;
5110 aPropertyName += QString::number( anId );
5112 QString aPropertyValue = aMarkerFileName.c_str();
5113 aPropertyValue += gPathSep;
5115 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5116 ushort aWidth = *aTextureIter++;
5117 ushort aHeight = *aTextureIter++;
5118 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5119 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5120 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5121 aPropertyValue += QString::number( *aTextureIter );
5123 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5127 // viewers counters are used for storing view_numbers in IParameters
5130 // main cycle to store parameters of displayed objects
5131 QList<SUIT_ViewManager*> lst;
5132 QList<SUIT_ViewManager*>::Iterator it;
5133 getApp()->viewManagers(lst);
5134 for (it = lst.begin(); it != lst.end(); it++)
5136 SUIT_ViewManager* vman = *it;
5137 QString vType = vman->getType();
5139 // saving VTK actors properties
5140 if (vType == SVTK_Viewer::Type())
5142 // store the clipping planes attached to the view manager
5143 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5144 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5145 if( anIter != myClippingPlaneInfoMap.end() )
5146 aClippingPlaneInfoList = anIter->second;
5148 if( !aClippingPlaneInfoList.empty() ) {
5149 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5150 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5152 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5153 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5155 QString aPropertyName( "ClippingPlane" );
5156 aPropertyName += gSeparator;
5157 aPropertyName += QString::number( vtkViewers );
5158 aPropertyName += gSeparator;
5159 aPropertyName += QString::number( anId );
5161 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5162 aPropertyValue += gDigitsSep;
5163 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5164 aPropertyValue += gDigitsSep;
5165 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5166 aPropertyValue += gDigitsSep;
5167 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5169 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5173 QVector<SUIT_ViewWindow*> views = vman->getViews();
5174 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5176 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5178 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5179 vtkActorCollection* allActors = aCopy.GetActors();
5180 allActors->InitTraversal();
5181 while (vtkActor* actor = allActors->GetNextActor())
5183 if (actor->GetVisibility()) // store only visible actors
5185 SMESH_Actor* aSmeshActor = 0;
5186 if (actor->IsA("SMESH_Actor"))
5187 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5188 if (aSmeshActor && aSmeshActor->hasIO())
5190 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5193 // entry is "encoded" = it does NOT contain component adress,
5194 // since it is a subject to change on next component loading
5195 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5197 std::string param, vtkParam = vType.toLatin1().data();
5198 vtkParam += gSeparator;
5199 vtkParam += QString::number(vtkViewers).toLatin1().data();
5200 vtkParam += gSeparator;
5203 param = vtkParam + "Visibility";
5204 ip->setParameter(entry, param, "On");
5207 param = vtkParam + "Representation";
5208 ip->setParameter(entry, param, QString::number
5209 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5212 param = vtkParam + "IsShrunk";
5213 ip->setParameter(entry, param, QString::number
5214 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5216 // Displayed entities
5217 unsigned int aMode = aSmeshActor->GetEntityMode();
5218 bool isE = aMode & SMESH_Actor::eEdges;
5219 bool isF = aMode & SMESH_Actor::eFaces;
5220 bool isV = aMode & SMESH_Actor::eVolumes;
5222 QString modeStr ("e");
5223 modeStr += gDigitsSep; modeStr += QString::number(isE);
5224 modeStr += gDigitsSep; modeStr += "f";
5225 modeStr += gDigitsSep; modeStr += QString::number(isF);
5226 modeStr += gDigitsSep; modeStr += "v";
5227 modeStr += gDigitsSep; modeStr += QString::number(isV);
5229 param = vtkParam + "Entities";
5230 ip->setParameter(entry, param, modeStr.toLatin1().data());
5232 // Colors (surface:edge:)
5233 vtkFloatingPointType r, g, b;
5236 aSmeshActor->GetSufaceColor(r, g, b, delta);
5237 QString colorStr ("surface");
5238 colorStr += gDigitsSep; colorStr += QString::number(r);
5239 colorStr += gDigitsSep; colorStr += QString::number(g);
5240 colorStr += gDigitsSep; colorStr += QString::number(b);
5242 colorStr += gDigitsSep; colorStr += "backsurface";
5243 colorStr += gDigitsSep; colorStr += QString::number(delta);
5246 aSmeshActor->GetEdgeColor(r, g, b);
5247 colorStr += gDigitsSep; colorStr += "edge";
5248 colorStr += gDigitsSep; colorStr += QString::number(r);
5249 colorStr += gDigitsSep; colorStr += QString::number(g);
5250 colorStr += gDigitsSep; colorStr += QString::number(b);
5252 aSmeshActor->GetNodeColor(r, g, b);
5253 colorStr += gDigitsSep; colorStr += "node";
5254 colorStr += gDigitsSep; colorStr += QString::number(r);
5255 colorStr += gDigitsSep; colorStr += QString::number(g);
5256 colorStr += gDigitsSep; colorStr += QString::number(b);
5258 aSmeshActor->GetOutlineColor(r, g, b);
5259 colorStr += gDigitsSep; colorStr += "outline";
5260 colorStr += gDigitsSep; colorStr += QString::number(r);
5261 colorStr += gDigitsSep; colorStr += QString::number(g);
5262 colorStr += gDigitsSep; colorStr += QString::number(b);
5264 param = vtkParam + "Colors";
5265 ip->setParameter(entry, param, colorStr.toLatin1().data());
5267 // Sizes of lines and points
5268 QString sizeStr ("line");
5269 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5270 sizeStr += gDigitsSep; sizeStr += "shrink";
5271 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5273 param = vtkParam + "Sizes";
5274 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5279 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5280 if( aMarkerType == VTK::MT_USER ) {
5281 markerStr += "custom";
5282 markerStr += gDigitsSep;
5283 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5287 markerStr += gDigitsSep;
5288 markerStr += QString::number( (int)aMarkerType );
5289 markerStr += gDigitsSep;
5290 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5293 param = vtkParam + "PointMarker";
5294 ip->setParameter(entry, param, markerStr.toLatin1().data());
5297 param = vtkParam + "Opacity";
5298 ip->setParameter(entry, param,
5299 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5302 param = vtkParam + "ClippingPlane";
5304 if( !aClippingPlaneInfoList.empty() ) {
5305 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5306 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5308 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5309 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5310 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5311 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5312 if( aSmeshActor == *anIter2 ) {
5313 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5314 QString::number( anId ).toLatin1().constData() );
5321 ip->setParameter( entry, param, "Off" );
5322 } // if (io->hasEntry())
5323 } // SMESH_Actor && hasIO
5325 } // while.. actors traversal
5329 } // if (SVTK view model)
5330 } // for (viewManagers)
5333 // data structures for clipping planes processing
5336 vtkIdType Orientation;
5337 vtkFloatingPointType Distance;
5338 vtkFloatingPointType Angle[2];
5340 typedef std::list<TPlaneData> TPlaneDataList;
5341 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5343 typedef std::list<vtkActor*> TActorList;
5346 TActorList ActorList;
5347 SUIT_ViewManager* ViewManager;
5349 typedef std::list<TPlaneInfo> TPlaneInfoList;
5350 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5353 * \brief Restore visual parameters
5355 * This method is called after the study document is opened.
5356 * Restore visual parameters from AttributeParameter attribue(s)
5358 void SMESHGUI::restoreVisualParameters (int savePoint)
5360 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5361 if (!appStudy || !appStudy->studyDS())
5363 _PTR(Study) studyDS = appStudy->studyDS();
5365 // componentName is used for encoding of entries when storing them in IParameters
5366 std::string componentName = myComponentSMESH->ComponentDataType();
5367 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5368 //if (!aSComponent) return;
5371 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5372 componentName.c_str(),
5374 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5376 // restore map of custom markers and map of clipping planes
5377 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5378 TPlaneDataMap aPlaneDataMap;
5380 std::vector<std::string> properties = ip->getProperties();
5381 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5383 std::string property = *propIt;
5384 QString aPropertyName( property.c_str() );
5385 QString aPropertyValue( ip->getProperty( property ).c_str() );
5387 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5388 if( aPropertyNameList.isEmpty() )
5391 QString aPropertyType = aPropertyNameList[0];
5392 if( aPropertyType == "texture" )
5394 if( aPropertyNameList.size() != 2 )
5398 int anId = aPropertyNameList[1].toInt( &ok );
5399 if( !ok || anId < 1 )
5402 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5403 if( aPropertyValueList.size() != 2 )
5406 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5407 QString aMarkerTextureString = aPropertyValueList[1];
5408 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5409 if( aMarkerTextureStringList.size() != 3 )
5413 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5418 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5422 VTK::MarkerTexture aMarkerTexture;
5423 aMarkerTexture.push_back( aWidth );
5424 aMarkerTexture.push_back( aHeight );
5426 QString aMarkerTextureData = aMarkerTextureStringList[2];
5427 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5429 QChar aChar = aMarkerTextureData.at( i );
5430 if( aChar.isDigit() )
5431 aMarkerTexture.push_back( aChar.digitValue() );
5434 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5436 else if( aPropertyType == "ClippingPlane" )
5438 if( aPropertyNameList.size() != 3 )
5442 int aViewId = aPropertyNameList[1].toInt( &ok );
5443 if( !ok || aViewId < 0 )
5447 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5448 if( !ok || aClippingPlaneId < 0 )
5451 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5452 if( aPropertyValueList.size() != 4 )
5455 TPlaneData aPlaneData;
5456 aPlaneData.Id = aClippingPlaneId;
5459 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5464 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5469 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5474 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5478 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5479 aPlaneDataList.push_back( aPlaneData );
5483 TPlaneInfoMap aPlaneInfoMap;
5485 std::vector<std::string> entries = ip->getEntries();
5487 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5489 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5490 QString entry (ip->decodeEntry(*entIt).c_str());
5492 // Check that the entry corresponds to a real object in the Study
5493 // as the object may be deleted or modified after the visual state is saved.
5494 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5495 if (!so) continue; //Skip the not existent entry
5497 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5498 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5500 std::vector<std::string>::iterator namesIt = paramNames.begin();
5501 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5503 // actors are stored in a map after displaying of them for
5504 // quicker access in the future: map < viewID to actor >
5505 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5507 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5509 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5510 // '_' is used as separator and should not be used in viewer type or parameter names.
5511 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5512 if (lst.size() != 3)
5515 QString viewerTypStr = lst[0];
5516 QString viewIndexStr = lst[1];
5517 QString paramNameStr = lst[2];
5520 int viewIndex = viewIndexStr.toUInt(&ok);
5521 if (!ok) // bad conversion of view index to integer
5525 if (viewerTypStr == SVTK_Viewer::Type())
5527 SMESH_Actor* aSmeshActor = 0;
5528 if (vtkActors.IsBound(viewIndex))
5529 aSmeshActor = vtkActors.Find(viewIndex);
5531 QList<SUIT_ViewManager*> lst;
5532 getApp()->viewManagers(viewerTypStr, lst);
5534 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5535 SUIT_ViewManager* vman = NULL;
5536 if (viewIndex >= 0 && viewIndex < lst.count())
5537 vman = lst.at(viewIndex);
5539 if (paramNameStr == "Visibility")
5541 if (!aSmeshActor && displayer() && vman)
5543 SUIT_ViewModel* vmodel = vman->getViewModel();
5544 // SVTK view model can be casted to SALOME_View
5545 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5547 // store displayed actor in a temporary map for quicker
5548 // access later when restoring other parameters
5549 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5550 vtkRenderer* Renderer = vtkView->getRenderer();
5551 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5552 vtkActorCollection* theActors = aCopy.GetActors();
5553 theActors->InitTraversal();
5554 bool isFound = false;
5555 vtkActor *ac = theActors->GetNextActor();
5556 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5557 if (ac->IsA("SMESH_Actor")) {
5558 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5559 if (aGeomAc->hasIO()) {
5560 Handle(SALOME_InteractiveObject) io =
5561 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5562 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5564 vtkActors.Bind(viewIndex, aGeomAc);
5570 } // if (paramNameStr == "Visibility")
5573 // the rest properties "work" with SMESH_Actor
5576 QString val ((*valuesIt).c_str());
5579 if (paramNameStr == "Representation") {
5580 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5583 else if (paramNameStr == "IsShrunk") {
5585 if (!aSmeshActor->IsShrunk())
5586 aSmeshActor->SetShrink();
5589 if (aSmeshActor->IsShrunk())
5590 aSmeshActor->UnShrink();
5593 // Displayed entities
5594 else if (paramNameStr == "Entities") {
5595 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5596 if (mode.count() == 6) {
5597 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5598 MESSAGE("Invalid order of data in Entities, must be: "
5599 "e:0/1:f:0/1:v:0/1");
5602 unsigned int aMode = aSmeshActor->GetEntityMode();
5603 unsigned int aNewMode =
5604 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5605 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5606 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5607 if (aNewMode != aMode)
5608 aSmeshActor->SetEntityMode(aNewMode);
5613 else if (paramNameStr == "Colors") {
5614 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5615 if (colors.count() == 16 || colors.count() == 18 ) {
5616 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5617 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
5618 (colors.count() == 18 && colors[14] != "outline")) {
5619 MESSAGE("Invalid order of data in Colors, must be: "
5620 "surface:r:g:b:backsurface:r:g:b:edge:r:g:b:node:r:g:b or surface:r:g:b:backsurface:delta:edge:r:g:b:node:r:g:b:outline:r:g:b");
5626 vtkFloatingPointType otr,otg,otb;
5627 //Old case backsurface color is independent
5628 if( colors.count() == 16 ) {
5630 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5631 er = colors[9].toFloat();
5632 eg = colors[10].toFloat();
5633 eb = colors[11].toFloat();
5635 nr = colors[13].toFloat();
5636 ng = colors[14].toFloat();
5637 nb = colors[15].toFloat();
5638 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5640 //New case backsurface color depends on surface color
5641 delta = colors[5].toInt();
5643 er = colors[7].toFloat();
5644 eg = colors[8].toFloat();
5645 eb = colors[9].toFloat();
5647 nr = colors[11].toFloat();
5648 ng = colors[12].toFloat();
5649 nb = colors[13].toFloat();
5651 otr = colors[15].toFloat();
5652 otg = colors[16].toFloat();
5653 otb = colors[17].toFloat();
5655 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5656 aSmeshActor->SetEdgeColor(er,eg,eb);
5657 aSmeshActor->SetNodeColor(nr,ng,nb);
5658 aSmeshActor->SetOutlineColor(otr,otg,otb);
5662 // Sizes of lines and points
5663 else if (paramNameStr == "Sizes") {
5664 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5665 if (sizes.count() == 4) {
5666 if (sizes[0] != "line" || sizes[2] != "shrink") {
5667 MESSAGE("Invalid order of data in Sizes, must be: "
5668 "line:int:shrink:float");
5671 aSmeshActor->SetLineWidth(sizes[1].toInt());
5672 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5675 else if (sizes.count() == 6) { // just to support old format
5676 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5677 MESSAGE("Invalid order of data in Sizes, must be: "
5678 "line:int:node:int:shrink:float");
5681 aSmeshActor->SetLineWidth(sizes[1].toInt());
5682 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5683 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5688 else if (paramNameStr == "PointMarker") {
5689 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5690 if( data.count() >= 2 ) {
5692 int aParam1 = data[1].toInt( &ok );
5694 if( data[0] == "std" && data.count() == 3 ) {
5695 int aParam2 = data[2].toInt( &ok );
5696 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5698 else if( data[0] == "custom" ) {
5699 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5700 if( markerIt != aMarkerMap.end() ) {
5701 VTK::MarkerData aMarkerData = markerIt->second;
5702 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5709 else if (paramNameStr == "Opacity") {
5710 aSmeshActor->SetOpacity(val.toFloat());
5713 else if (paramNameStr.startsWith("ClippingPlane")) {
5714 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5715 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5716 // new format - val looks like "Off" or "0" (plane id)
5717 // (note: in new format "Off" value is used only for consistency,
5718 // so it is processed together with values in old format)
5719 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5720 if( anIsOldFormat ) {
5721 if (paramNameStr == "ClippingPlane1" || val == "Off")
5722 aSmeshActor->RemoveAllClippingPlanes();
5724 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5725 double aDistance = vals[1].toFloat();
5726 vtkFloatingPointType anAngle[2];
5727 anAngle[0] = vals[2].toFloat();
5728 anAngle[1] = vals[3].toFloat();
5730 QList<SUIT_ViewManager*> lst;
5731 getApp()->viewManagers(viewerTypStr, lst);
5732 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5733 if (viewIndex >= 0 && viewIndex < lst.count()) {
5734 SUIT_ViewManager* vman = lst.at(viewIndex);
5735 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5737 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5739 SMESH::TActorList anActorList;
5740 anActorList.push_back( aSmeshActor );
5741 SMESH::OrientedPlane* aPlane =
5742 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5744 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5745 aClippingPlaneInfo.Plane = aPlane;
5746 aClippingPlaneInfo.ActorList = anActorList;
5747 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5754 int aPlaneId = val.toInt( &ok );
5755 if( ok && aPlaneId >= 0 ) {
5756 bool anIsDefinedPlane = false;
5757 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5758 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5759 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5760 TPlaneInfo& aPlaneInfo = *anIter;
5761 if( aPlaneInfo.PlaneId == aPlaneId ) {
5762 aPlaneInfo.ActorList.push_back( aSmeshActor );
5763 anIsDefinedPlane = true;
5767 if( !anIsDefinedPlane ) {
5768 TPlaneInfo aPlaneInfo;
5769 aPlaneInfo.PlaneId = aPlaneId;
5770 aPlaneInfo.ActorList.push_back( aSmeshActor );
5771 aPlaneInfo.ViewManager = vman;
5773 // to make the list sorted by plane id
5774 anIter = aPlaneInfoList.begin();
5775 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5776 const TPlaneInfo& aPlaneInfoRef = *anIter;
5777 if( aPlaneInfoRef.PlaneId > aPlaneId )
5780 aPlaneInfoList.insert( anIter, aPlaneInfo );
5785 } // if (aSmeshActor)
5786 } // other parameters than Visibility
5788 } // for names/parameters iterator
5789 } // for entries iterator
5791 // take into account planes with empty list of actors referred to them
5792 QList<SUIT_ViewManager*> aVMList;
5793 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5795 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5796 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5797 int aViewId = aPlaneDataIter->first;
5798 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5799 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5801 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5803 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5804 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5805 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5806 const TPlaneData& aPlaneData = *anIter2;
5807 int aPlaneId = aPlaneData.Id;
5809 bool anIsFound = false;
5810 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5811 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5812 const TPlaneInfo& aPlaneInfo = *anIter3;
5813 if( aPlaneInfo.PlaneId == aPlaneId ) {
5820 TPlaneInfo aPlaneInfo; // ActorList field is empty
5821 aPlaneInfo.PlaneId = aPlaneId;
5822 aPlaneInfo.ViewManager = aViewManager;
5824 // to make the list sorted by plane id
5825 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5826 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5827 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5828 if( aPlaneInfoRef.PlaneId > aPlaneId )
5831 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5837 // add clipping planes to actors according to the restored parameters
5838 // and update the clipping plane map
5839 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5840 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5841 int aViewId = anIter1->first;
5842 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5844 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5845 if( anIter2 == aPlaneDataMap.end() )
5847 const TPlaneDataList& aPlaneDataList = anIter2->second;
5849 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5850 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5851 const TPlaneInfo& aPlaneInfo = *anIter3;
5852 int aPlaneId = aPlaneInfo.PlaneId;
5853 const TActorList& anActorList = aPlaneInfo.ActorList;
5854 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5858 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5862 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5864 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5865 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5866 const TPlaneData& aPlaneData = *anIter4;
5867 if( aPlaneData.Id == aPlaneId ) {
5868 SMESH::OrientedPlane* aPlane =
5869 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5871 (SMESH::Orientation)aPlaneData.Orientation,
5872 aPlaneData.Distance,
5875 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5876 aClippingPlaneInfo.Plane = aPlane;
5877 aClippingPlaneInfo.ActorList = anActorList;
5878 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5886 // update all VTK views
5887 QList<SUIT_ViewManager*> lst;
5888 getApp()->viewManagers(lst);
5889 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5890 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5891 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5892 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5893 vtkView->getRenderer()->ResetCameraClippingRange();
5900 \brief Adds preferences for dfont of VTK viewer
5902 \param pIf group identifier
5903 \param param parameter
5904 \return identifier of preferences
5906 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5908 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5910 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5913 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5914 fam.append( tr( "SMESH_FONT_COURIER" ) );
5915 fam.append( tr( "SMESH_FONT_TIMES" ) );
5917 setPreferenceProperty( tfont, "fonts", fam );
5919 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5920 setPreferenceProperty( tfont, "features", f );
5926 \brief Actions after hypothesis edition
5927 Updates object browser after hypothesis edition
5929 void SMESHGUI::onHypothesisEdit( int result )
5932 SMESHGUI::Modified();
5933 updateObjBrowser( true );
5938 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5939 \param pview view being closed
5941 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5942 #ifndef DISABLE_PLOT2DVIEWER
5943 //Crear all Plot2d Viewers if need.
5944 SMESH::ClearPlot2Viewers(pview);
5949 \brief Connects or disconnects signals about activating and cloning view on the module slots
5950 \param pview view which is connected/disconnected
5952 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5956 SUIT_ViewManager* viewMgr = pview->getViewManager();
5958 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5959 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5961 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5962 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5967 \brief Return \c true if object can be renamed
5969 bool SMESHGUI::renameAllowed( const QString& entry) const {
5970 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5974 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5978 bool appRes = SalomeApp_Module::renameAllowed(entry);
5982 // check type to prevent renaming of inappropriate objects
5983 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5984 if (aType == MESH || aType == GROUP ||
5985 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5986 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5987 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5988 aType == HYPOTHESIS || aType == ALGORITHM)
5995 Rename object by entry.
5996 \param entry entry of the object
5997 \param name new name of the object
5998 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6000 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6002 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6006 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
6010 bool appRes = SalomeApp_Module::renameObject(entry,name);
6014 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6015 _PTR(GenericAttribute) anAttr;
6016 _PTR(AttributeName) aName;
6018 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6020 // check type to prevent renaming of inappropriate objects
6021 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
6022 if (aType == MESH || aType == GROUP ||
6023 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
6024 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
6025 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
6026 aType == HYPOTHESIS || aType == ALGORITHM) {
6027 if ( !name.isEmpty() ) {
6028 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6030 // update name of group object and its actor
6031 Handle(SALOME_InteractiveObject) IObject =
6032 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6034 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6035 if( !aGroupObject->_is_nil() ) {
6036 aGroupObject->SetName( qPrintable(name) );
6037 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6038 anActor->setName( qPrintable(name) );