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" );
889 void SaveDistribution()
891 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
892 SALOME_ListIO selected;
894 aSel->selectedObjects( selected );
896 if ( selected.Extent() == 1 ) {
897 Handle(SALOME_InteractiveObject) anIO = selected.First();
898 if ( anIO->hasEntry() ) {
899 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
900 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
901 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
902 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
903 if ( aScalarBarActor && aFunctor ) {
904 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
906 std::vector<int> elements;
907 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
908 if ( mesh->_is_nil() ) {
909 SMESH::SMESH_IDSource_var idSource =
910 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
911 if ( !idSource->_is_nil() )
913 SMESH::long_array_var ids = idSource->GetIDs();
914 elements.resize( ids->length() );
915 for ( unsigned i = 0; i < elements.size(); ++i )
916 elements[i] = ids[i];
919 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
920 vtkLookupTable* lookupTable =
921 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
922 double * minmax = lookupTable->GetRange();
923 std::vector<int> nbEvents;
924 std::vector<double> funValues;
925 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
926 QString anInitialPath = "";
927 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
928 anInitialPath = QDir::currentPath();
929 QString aMeshName = anIO->getName();
931 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
932 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
933 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
934 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
935 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
938 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
940 if ( !aFilename.isEmpty() ) {
941 QFile f( aFilename );
942 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
943 QTextStream out( &f );
944 out << "# Mesh: " << aMeshName << endl;
945 out << "# Control: " << functorToString( aFunctor ) << endl;
947 out.setFieldWidth( 10 );
948 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
949 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
960 void ShowDistribution() {
961 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
962 SALOME_ListIO selected;
964 aSel->selectedObjects( selected );
966 if ( selected.Extent() == 1 ) {
967 Handle(SALOME_InteractiveObject) anIO = selected.First();
968 if ( anIO->hasEntry() ) {
969 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
970 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
971 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
972 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
978 #ifndef DISABLE_PLOT2DVIEWER
979 void PlotDistribution() {
980 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
984 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
985 SALOME_ListIO selected;
987 aSel->selectedObjects( selected );
989 if ( selected.Extent() == 1 ) {
990 Handle(SALOME_InteractiveObject) anIO = selected.First();
991 if ( anIO->hasEntry() ) {
992 //Find Actor by entry before getting Plot2d viewer,
993 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
994 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
996 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1001 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1005 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1009 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1010 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1011 QString functorName = functorToString( anActor->GetFunctor());
1012 QString aHistogramName("%1 : %2");
1013 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1014 aHistogram->setName(aHistogramName);
1015 aHistogram->setHorTitle(functorName);
1016 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1017 aPlot->displayObject(aHistogram, true);
1022 #endif //DISABLE_PLOT2DVIEWER
1024 void DisableAutoColor(){
1025 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1026 SALOME_ListIO selected;
1028 aSel->selectedObjects( selected );
1030 if(selected.Extent()){
1031 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1032 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1033 if ( !aMesh->_is_nil() ) {
1034 aMesh->SetAutoColor( false );
1039 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1040 SALOME_ListIO selected;
1041 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1045 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1046 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1047 if( !aSel || !appStudy )
1050 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1051 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1052 aModule->EmitSignalDeactivateDialog();
1053 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1054 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1059 _PTR(Study) aStudy = appStudy->studyDS();
1061 aSel->selectedObjects( selected );
1063 if(selected.Extent() >= 1){
1064 switch(theCommandID){
1066 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1067 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1071 QColor c, e, b, n, c0D, o, outl, selection, preselection;
1075 vtkFloatingPointType Shrink = 0.0;
1076 vtkFloatingPointType faces_orientation_scale = 0.0;
1077 bool faces_orientation_3dvectors = false;
1079 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1080 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1081 int aMarkerTextureCurrent = 0;
1083 SALOME_ListIteratorOfListIO It( selected );
1084 for( ; It.More(); It.Next()){
1085 Handle(SALOME_InteractiveObject) IObject = It.Value();
1086 if(IObject->hasEntry()){
1087 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1088 vtkFloatingPointType color[3];
1089 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1090 int c0 = int (color[0] * 255);
1091 int c1 = int (color[1] * 255);
1092 int c2 = int (color[2] * 255);
1093 c.setRgb(c0, c1, c2);
1095 vtkFloatingPointType edgecolor[3];
1096 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1097 c0 = int (edgecolor[0] * 255);
1098 c1 = int (edgecolor[1] * 255);
1099 c2 = int (edgecolor[2] * 255);
1100 e.setRgb(c0, c1, c2);
1102 vtkFloatingPointType nodecolor[3];
1103 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1104 c0 = int (nodecolor[0] * 255);
1105 c1 = int (nodecolor[1] * 255);
1106 c2 = int (nodecolor[2] * 255);
1107 n.setRgb(c0, c1, c2);
1109 vtkFloatingPointType color0D[3];
1110 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1111 c0 = int (color0D[0] * 255);
1112 c1 = int (color0D[1] * 255);
1113 c2 = int (color0D[2] * 255);
1114 c0D.setRgb(c0, c1, c2);
1116 vtkFloatingPointType outlineColor[3];
1117 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1118 c0 = int (outlineColor[0] * 255);
1119 c1 = int (outlineColor[1] * 255);
1120 c2 = int (outlineColor[2] * 255);
1121 outl.setRgb(c0, c1, c2);
1123 vtkFloatingPointType hColor[3];
1124 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1125 c0 = int (hColor[0] * 255);
1126 c1 = int (hColor[1] * 255);
1127 c2 = int (hColor[2] * 255);
1128 selection.setRgb(c0, c1, c2);
1130 vtkFloatingPointType phColor[3];
1131 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1132 c0 = int (phColor[0] * 255);
1133 c1 = int (phColor[1] * 255);
1134 c2 = int (phColor[2] * 255);
1135 preselection.setRgb(c0, c1, c2);
1137 size0D = (int)anActor->Get0DSize();
1140 Edgewidth = (int)anActor->GetLineWidth();
1143 Shrink = anActor->GetShrinkFactor();
1145 vtkFloatingPointType faces_orientation_color[3];
1146 anActor->GetFacesOrientationColor(faces_orientation_color);
1147 c0 = int (faces_orientation_color[0] * 255);
1148 c1 = int (faces_orientation_color[1] * 255);
1149 c2 = int (faces_orientation_color[2] * 255);
1150 o.setRgb(c0, c1, c2);
1152 faces_orientation_scale = anActor->GetFacesOrientationScale();
1153 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1155 aMarkerTypeCurrent = anActor->GetMarkerType();
1156 aMarkerScaleCurrent = anActor->GetMarkerScale();
1157 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1159 // even if there are multiple objects in the selection,
1160 // we need only the first one to get values for the dialog
1166 SMESHGUI_Preferences_ColorDlg *aDlg =
1167 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1168 aDlg->SetColor(1, c);
1169 aDlg->SetColor(2, e);
1170 aDlg->SetColor(3, n);
1171 aDlg->SetColor(4, outl);
1172 aDlg->SetDeltaBrightness(delta);
1173 aDlg->SetColor(5, c0D);
1174 aDlg->SetColor(6, o);
1175 aDlg->SetIntValue(1, Edgewidth);
1176 aDlg->SetIntValue(2, int(Shrink*100.));
1177 aDlg->SetIntValue(3, size0D);
1178 aDlg->SetDoubleValue(1, faces_orientation_scale);
1179 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1180 aDlg->SetColor(7, selection);
1181 aDlg->SetColor(8, preselection);
1183 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1185 if( aMarkerTypeCurrent != VTK::MT_USER )
1186 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1188 aDlg->setCustomMarker( aMarkerTextureCurrent );
1191 QColor color = aDlg->GetColor(1);
1192 QColor edgecolor = aDlg->GetColor(2);
1193 QColor nodecolor = aDlg->GetColor(3);
1194 QColor outlinecolor = aDlg->GetColor(4);
1195 QColor color0D = aDlg->GetColor(5);
1196 QColor faces_orientation_color = aDlg->GetColor(6);
1197 QColor selectioncolor = aDlg->GetColor(7);
1198 QColor preSelectioncolor = aDlg->GetColor(8);
1199 int delta = aDlg->GetDeltaBrightness();
1202 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1204 SALOME_ListIteratorOfListIO It( selected );
1205 for( ; It.More(); It.Next()){
1206 Handle(SALOME_InteractiveObject) IObject = It.Value();
1207 if(IObject->hasEntry()){
1208 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1209 /* actor color and backface color */
1210 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1211 vtkFloatingPointType (color.green()) / 255.,
1212 vtkFloatingPointType (color.blue()) / 255.,
1215 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1216 vtkFloatingPointType (edgecolor.green()) / 255.,
1217 vtkFloatingPointType (edgecolor.blue()) / 255.);
1219 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1220 vtkFloatingPointType (outlinecolor.green()) / 255.,
1221 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1224 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1225 vtkFloatingPointType (selectioncolor.green()) / 255.,
1226 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1228 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1229 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1230 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1233 /* Shrink factor and size edges */
1234 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1235 anActor->SetLineWidth(aDlg->GetIntValue(1));
1237 /* Nodes color and size */
1238 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1239 vtkFloatingPointType (nodecolor.green()) / 255.,
1240 vtkFloatingPointType (nodecolor.blue()) / 255.);
1243 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1244 vtkFloatingPointType (color0D.green()) / 255.,
1245 vtkFloatingPointType (color0D.blue()) / 255.);
1246 anActor->Set0DSize(aDlg->GetIntValue(3));
1248 /* Faces orientation */
1249 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1250 vtkFloatingPointType(faces_orientation_color.greenF()),
1251 vtkFloatingPointType(faces_orientation_color.blueF())};
1252 anActor->SetFacesOrientationColor(c);
1253 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1254 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1256 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1257 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1258 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1259 if( aMarkerTypeNew != VTK::MT_USER )
1260 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1262 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1263 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1264 if( anIter != aMarkerMap.end() )
1265 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1268 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1269 if( !aGroupObject->_is_nil() )
1271 SMESH::ElementType anElementType = aGroupObject->GetType();
1273 switch( anElementType )
1275 case SMESH::NODE: aColor = nodecolor; break;
1276 case SMESH::EDGE: aColor = edgecolor; break;
1277 default: aColor = color; break;
1280 SALOMEDS::Color aGroupColor;
1281 aGroupColor.R = (float)aColor.red() / 255.0;
1282 aGroupColor.G = (float)aColor.green() / 255.0;
1283 aGroupColor.B = (float)aColor.blue() / 255.0;
1284 aGroupObject->SetColor( aGroupColor );
1289 SMESH::RepaintCurrentView();
1295 SALOME_ListIteratorOfListIO It( selected );
1296 for( ; It.More(); It.Next()){
1297 Handle(SALOME_InteractiveObject) IObject = It.Value();
1298 if(IObject->hasEntry()){
1299 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1300 switch(theCommandID){
1302 anActor->SetRepresentation(SMESH_Actor::eEdge);
1305 anActor->SetRepresentation(SMESH_Actor::eSurface);
1308 if(anActor->IsShrunk())
1309 anActor->UnShrink();
1311 anActor->SetShrink();
1314 anActor->SetRepresentation(SMESH_Actor::ePoint);
1317 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1318 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1321 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1322 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1328 SMESH::RepaintCurrentView();
1332 void Control( int theCommandID )
1334 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1335 SALOME_ListIO selected;
1337 aSel->selectedObjects( selected );
1339 if( !selected.IsEmpty() ){
1340 Handle(SALOME_InteractiveObject) anIO = selected.First();
1342 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1343 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1344 switch ( theCommandID ){
1346 aControl = SMESH_Actor::eLength;
1349 aControl = SMESH_Actor::eLength2D;
1352 aControl = SMESH_Actor::eFreeEdges;
1355 aControl = SMESH_Actor::eFreeBorders;
1358 aControl = SMESH_Actor::eMultiConnection;
1361 aControl = SMESH_Actor::eFreeNodes;
1364 aControl = SMESH_Actor::eMultiConnection2D;
1367 aControl = SMESH_Actor::eArea;
1370 aControl = SMESH_Actor::eTaper;
1373 aControl = SMESH_Actor::eAspectRatio;
1376 aControl = SMESH_Actor::eAspectRatio3D;
1379 aControl = SMESH_Actor::eMinimumAngle;
1382 aControl = SMESH_Actor::eWarping;
1385 aControl = SMESH_Actor::eSkew;
1388 aControl = SMESH_Actor::eVolume3D;
1391 aControl = SMESH_Actor::eFreeFaces;
1394 aControl = SMESH_Actor::eMaxElementLength2D;
1397 aControl = SMESH_Actor::eMaxElementLength3D;
1400 aControl = SMESH_Actor::eBareBorderVolume;
1403 aControl = SMESH_Actor::eBareBorderFace;
1406 aControl = SMESH_Actor::eOverConstrainedVolume;
1409 aControl = SMESH_Actor::eOverConstrainedFace;
1412 anActor->SetControlMode(aControl);
1413 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1414 SMESH::RepaintCurrentView();
1415 #ifndef DISABLE_PLOT2DVIEWER
1416 if(anActor->GetPlot2Histogram()) {
1417 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1418 QString functorName = functorToString( anActor->GetFunctor());
1419 QString aHistogramName("%1 : %2");
1420 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1421 aHistogram->setName(aHistogramName);
1422 aHistogram->setHorTitle(functorName);
1423 SMESH::ProcessIn2DViewers(anActor);
1432 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1433 MeshObjectType theType,
1434 const QString theInTypeName,
1435 QString & theOutTypeName)
1437 SMESH_TypeFilter aTypeFilter( theType );
1439 if( !theIO.IsNull() )
1441 entry = theIO->getEntry();
1442 LightApp_DataOwner owner( entry );
1443 if ( aTypeFilter.isOk( &owner )) {
1444 theOutTypeName = theInTypeName;
1452 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1454 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1455 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1457 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1458 CORBA::String_var anID = aSComp->GetID().c_str();
1459 if (!strcmp(anID.in(),theIO->getEntry()))
1465 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1466 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1467 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1468 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1469 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1477 QString CheckHomogeneousSelection()
1479 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1480 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1481 SALOME_ListIO selected;
1483 aSel->selectedObjects( selected );
1485 QString RefType = CheckTypeObject(selected.First());
1486 SALOME_ListIteratorOfListIO It(selected);
1487 for ( ; It.More(); It.Next())
1489 Handle(SALOME_InteractiveObject) IObject = It.Value();
1490 QString Type = CheckTypeObject(IObject);
1491 if (Type.compare(RefType) != 0)
1492 return "Heterogeneous Selection";
1499 void SMESHGUI::OnEditDelete()
1501 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1502 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1503 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1505 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1506 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1507 _PTR(GenericAttribute) anAttr;
1508 _PTR(AttributeIOR) anIOR;
1510 int objectCount = 0;
1512 QString aParentComponent = QString::null;
1513 Handle(SALOME_InteractiveObject) anIO;
1514 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1516 anIO = anIt.Value();
1517 QString cur = anIO->getComponentDataType();
1518 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1520 // check if object is reference
1521 _PTR(SObject) aRefSObj;
1522 aNameList.append("\n - ");
1523 if ( aSO->ReferencedObject( aRefSObj ) ) {
1524 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1525 aNameList.append( aRefName );
1526 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1529 aNameList.append(anIO->getName());
1533 if( aParentComponent.isNull() )
1534 aParentComponent = cur;
1535 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1536 aParentComponent = "";
1539 if ( objectCount == 0 )
1540 return; // No Valid Objects Selected
1542 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1543 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1544 QObject::tr("ERR_ERROR"),
1545 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1548 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1549 if (SUIT_MessageBox::warning
1550 (SMESHGUI::desktop(),
1551 QObject::tr("SMESH_WRN_WARNING"),
1552 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1553 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1554 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1557 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1559 SALOME_ListIteratorOfListIO It(selected);
1561 aStudyBuilder->NewCommand(); // There is a transaction
1562 for( ; It.More(); It.Next()){ // loop on selected IO's
1563 Handle(SALOME_InteractiveObject) IObject = It.Value();
1564 if(IObject->hasEntry()) {
1565 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1567 // disable removal of "SMESH" component object
1568 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1570 if ( engineIOR() == anIOR->Value().c_str() )
1573 //Check the referenced object
1574 _PTR(SObject) aRefSObject;
1575 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1576 aSO = aRefSObject; // Delete main Object instead of reference
1578 // put the whole hierarchy of sub-objects of the selected SO into a list and
1579 // then treat them all starting from the deepest objects (at list back)
1581 std::list< _PTR(SObject) > listSO;
1582 listSO.push_back( aSO );
1583 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1584 for ( ; itSO != listSO.end(); ++itSO ) {
1585 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1586 for (it->InitEx(false); it->More(); it->Next())
1587 listSO.push_back( it->Value() );
1590 // treat SO's in the list starting from the back
1592 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1593 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1594 _PTR(SObject) SO = *ritSO;
1595 if ( !SO ) continue;
1596 std::string anEntry = SO->GetID();
1598 /** Erase graphical object **/
1599 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1600 ViewManagerList aViewMenegers = anApp->viewManagers();
1601 ViewManagerList::const_iterator it = aViewMenegers.begin();
1602 for( ; it != aViewMenegers.end(); it++) {
1603 SUIT_ViewManager* vm = *it;
1604 int nbSf = vm ? vm->getViewsCount() : 0;
1606 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1607 for(int i = 0; i < nbSf; i++){
1608 SUIT_ViewWindow *sf = aViews[i];
1609 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1610 SMESH::RemoveActor(sf,anActor);
1616 /** Remove an object from data structures **/
1617 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1618 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1619 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1620 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1621 aMesh->RemoveGroup( aGroup );
1623 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1624 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1625 aMesh->RemoveSubMesh( aSubMesh );
1627 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1629 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1632 IObject = new SALOME_InteractiveObject
1633 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1634 QString objType = CheckTypeObject(IObject);
1635 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1636 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1637 aStudyBuilder->RemoveObjectWithChildren( SO );
1639 else {// default action: remove SObject from the study
1640 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1641 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1643 aStudyBuilder->RemoveObjectWithChildren( SO );
1647 } /* listSO back loop */
1648 } /* IObject->hasEntry() */
1651 aStudyBuilder->CommitCommand();
1653 /* Clear any previous selection */
1655 aSel->setSelectedObjects( l1 );
1657 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1662 SMESHGUI_EXPORT CAM_Module* createModule()
1664 return new SMESHGUI();
1667 SMESHGUI_EXPORT char* getModuleVersion() {
1668 return (char*)SMESH_VERSION_STR;
1672 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1674 //=============================================================================
1678 //=============================================================================
1679 SMESHGUI::SMESHGUI() :
1680 SalomeApp_Module( "SMESH" ),
1681 LightApp_Module( "SMESH" )
1683 if ( CORBA::is_nil( myComponentSMESH ) )
1685 CORBA::Boolean anIsEmbeddedMode;
1686 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1687 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1689 // 0019923: EDF 765 SMESH : default values of hypothesis
1690 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1691 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1692 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1693 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1694 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1697 myActiveDialogBox = 0;
1698 myFilterLibraryDlg = 0;
1702 myEventCallbackCommand = vtkCallbackCommand::New();
1703 myEventCallbackCommand->Delete();
1704 myEventCallbackCommand->SetClientData( this );
1705 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1708 SMESH::GetFilterManager();
1709 SMESH::GetPattern();
1710 SMESH::GetMeasurements();
1712 /* load resources for all available meshers */
1713 SMESH::InitAvailableHypotheses();
1716 //=============================================================================
1720 //=============================================================================
1721 SMESHGUI::~SMESHGUI()
1723 #ifdef WITHGENERICOBJ
1724 SMESH::GetFilterManager()->UnRegister();
1725 SMESH::GetMeasurements()->UnRegister();
1727 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1728 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1731 //=============================================================================
1735 //=============================================================================
1736 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1738 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1740 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1745 //=============================================================================
1749 //=============================================================================
1750 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1752 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1756 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1757 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1758 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1759 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1760 return autoUpdate && !exceeded;
1763 //=============================================================================
1767 //=============================================================================
1768 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1770 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1773 //=============================================================================
1777 //=============================================================================
1778 SMESHGUI* SMESHGUI::GetSMESHGUI()
1780 SMESHGUI* smeshMod = 0;
1781 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1784 CAM_Module* module = app->module( "Mesh" );
1785 smeshMod = dynamic_cast<SMESHGUI*>( module );
1788 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1790 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1793 _PTR(Study) aStudy = study->studyDS();
1795 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1804 Standard_EXPORT SMESHGUI* GetComponentGUI()
1806 return SMESHGUI::GetSMESHGUI();
1810 //=============================================================================
1814 //=============================================================================
1815 void SMESHGUI::SetState(int aState)
1820 //=============================================================================
1824 //=============================================================================
1825 void SMESHGUI::ResetState()
1830 //=============================================================================
1834 //=============================================================================
1835 void SMESHGUI::EmitSignalDeactivateDialog()
1837 emit SignalDeactivateActiveDialog();
1840 //=============================================================================
1844 //=============================================================================
1845 void SMESHGUI::EmitSignalStudyFrameChanged()
1847 emit SignalStudyFrameChanged();
1850 //=============================================================================
1854 //=============================================================================
1855 void SMESHGUI::EmitSignalCloseAllDialogs()
1857 emit SignalCloseAllDialogs();
1860 //=============================================================================
1864 //=============================================================================
1865 void SMESHGUI::EmitSignalVisibilityChanged()
1867 emit SignalVisibilityChanged();
1870 //=============================================================================
1874 //=============================================================================
1875 QDialog *SMESHGUI::GetActiveDialogBox()
1877 return myActiveDialogBox;
1880 //=============================================================================
1884 //=============================================================================
1885 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1887 myActiveDialogBox = (QDialog *) aDlg;
1891 //=============================================================================
1895 //=============================================================================
1896 SUIT_Desktop* SMESHGUI::desktop()
1898 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1900 return app->desktop();
1905 //=============================================================================
1909 //=============================================================================
1910 SalomeApp_Study* SMESHGUI::activeStudy()
1912 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1914 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1919 //=============================================================================
1923 //=============================================================================
1924 void SMESHGUI::Modified( bool theIsUpdateActions )
1926 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1927 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1928 appStudy->Modified();
1929 if( theIsUpdateActions )
1930 app->updateActions();
1935 //=============================================================================
1939 //=============================================================================
1940 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1942 /* Here the position is on the bottom right corner - 10 */
1943 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1945 SUIT_Desktop *PP = desktop();
1946 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1947 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1951 //=============================================================================
1955 //=============================================================================
1956 static int isStudyLocked(_PTR(Study) theStudy){
1957 return theStudy->GetProperties()->IsLocked();
1960 static bool checkLock(_PTR(Study) theStudy) {
1961 if (isStudyLocked(theStudy)) {
1962 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1963 QObject::tr("WRN_WARNING"),
1964 QObject::tr("WRN_STUDY_LOCKED") );
1970 //=======================================================================
1971 //function : CheckActiveStudyLocked
1973 //=======================================================================
1975 bool SMESHGUI::isActiveStudyLocked()
1977 _PTR(Study) aStudy = activeStudy()->studyDS();
1978 return checkLock( aStudy );
1981 //=============================================================================
1985 //=============================================================================
1986 bool SMESHGUI::OnGUIEvent( int theCommandID )
1988 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1992 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1993 SUIT_ResourceMgr* mgr = resourceMgr();
1997 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1998 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2001 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2002 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2004 //QAction* act = action( theCommandID );
2006 switch (theCommandID) {
2008 if(checkLock(aStudy)) break;
2019 if(checkLock(aStudy)) break;
2020 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2024 case 150: //MED FILE INFORMATION
2026 SALOME_ListIO selected;
2027 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2029 aSel->selectedObjects( selected );
2030 if( selected.Extent() )
2032 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2033 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2034 if ( !aMesh->_is_nil() )
2036 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2043 case 122: // EXPORT MED
2056 ::ExportMeshToFile(theCommandID);
2060 case 200: // SCALAR BAR
2062 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2063 SALOME_ListIO selected;
2065 aSel->selectedObjects( selected );
2067 if( selected.Extent() ) {
2068 Handle(SALOME_InteractiveObject) anIO = selected.First();
2069 if( anIO->hasEntry() ) {
2070 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2071 anActor->SetControlMode( SMESH_Actor::eNone );
2072 #ifndef DISABLE_PLOT2DVIEWER
2073 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2082 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2087 // dump control distribution data to the text file
2088 ::SaveDistribution();
2094 // show/ distribution
2095 ::ShowDistribution();
2099 #ifndef DISABLE_PLOT2DVIEWER
2102 // plot distribution
2103 ::PlotDistribution();
2114 ::DisableAutoColor();
2117 case 1134: // Clipping
2118 case 1133: // Tranparency
2119 case 1132: // Colors / Size
2126 ::SetDisplayMode(theCommandID, myMarkerMap);
2129 //2D quadratic representation
2132 ::SetDisplayMode(theCommandID, myMarkerMap);
2136 case 216: // 0D elements
2139 case 219: // Volumes
2140 case 220: // All Entity
2141 ::SetDisplayEntity(theCommandID);
2144 case 221: // Orientation of faces
2146 LightApp_SelectionMgr* mgr = selectionMgr();
2147 SALOME_ListIO selected; mgr->selectedObjects( selected );
2149 SALOME_ListIteratorOfListIO it(selected);
2150 for( ; it.More(); it.Next()) {
2151 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2152 if(anIObject->hasEntry()) {
2153 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2154 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2163 if(checkLock(aStudy)) break;
2165 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2168 SMESH::UpdateView();
2170 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2171 SMESH::OnVisuException();
2173 catch (...) { // PAL16774 (Crash after display of many groups)
2174 SMESH::OnVisuException();
2178 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2179 aSel->selectedObjects( l );
2180 aSel->setSelectedObjects( l );
2185 case 301: // DISPLAY
2186 case 302: // DISPLAY ONLY
2188 SMESH::EDisplaing anAction;
2189 switch (theCommandID) {
2190 case 300: anAction = SMESH::eErase; break;
2191 case 301: anAction = SMESH::eDisplay; break;
2192 case 302: anAction = SMESH::eDisplayOnly; break;
2195 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2196 SALOME_ListIO sel_objects, to_process;
2198 aSel->selectedObjects( sel_objects );
2200 if( theCommandID==302 )
2202 MESSAGE("anAction = SMESH::eDisplayOnly");
2203 startOperation( myEraseAll );
2206 extractContainers( sel_objects, to_process );
2209 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2213 SALOME_ListIteratorOfListIO It( to_process );
2214 for ( ; It.More(); It.Next()) {
2216 Handle(SALOME_InteractiveObject) IOS = It.Value();
2217 if (IOS->hasEntry()) {
2219 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2220 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2221 break; // PAL16774 (Crash after display of many groups)
2223 if (anAction == SMESH::eDisplayOnly)
2225 MESSAGE("anAction = SMESH::eDisplayOnly");
2226 anAction = SMESH::eDisplay;
2232 // PAL13338 + PAL15161 -->
2233 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2234 MESSAGE("anAction = SMESH::eDisplayOnly");
2235 SMESH::UpdateView();
2236 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2238 // PAL13338 + PAL15161 <--
2240 catch (...) { // PAL16774 (Crash after display of many groups)
2241 SMESH::OnVisuException();
2244 if (anAction == SMESH::eErase) {
2245 MESSAGE("anAction == SMESH::eErase");
2247 aSel->setSelectedObjects( l1 );
2250 aSel->setSelectedObjects( to_process );
2257 if(checkLock(aStudy)) break;
2260 EmitSignalDeactivateDialog();
2262 ( new SMESHGUI_NodesDlg( this ) )->show();
2265 SUIT_MessageBox::warning(desktop(),
2266 tr("SMESH_WRN_WARNING"),
2267 tr("SMESH_WRN_VIEWER_VTK"));
2272 case 2151: // FILTER
2276 EmitSignalDeactivateDialog();
2277 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2282 case 701: // COMPUTE MESH
2283 case 711: // PRECOMPUTE MESH
2284 case 712: // EVALUATE MESH
2285 case 713: // MESH ORDER
2287 if (checkLock(aStudy)) break;
2288 startOperation( theCommandID );
2292 case 702: // Create mesh
2293 case 703: // Create sub-mesh
2294 case 704: // Edit mesh/sub-mesh
2295 startOperation( theCommandID );
2297 case 705: // copy mesh
2299 if (checkLock(aStudy)) break;
2300 EmitSignalDeactivateDialog();
2301 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2304 case 710: // Build compound mesh
2306 if (checkLock(aStudy)) break;
2307 EmitSignalDeactivateDialog();
2308 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2312 case 407: // DIAGONAL INVERSION
2313 case 408: // Delete diagonal
2317 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2318 tr( "NOT_A_VTK_VIEWER" ) );
2322 if ( checkLock( aStudy ) )
2325 /*Standard_Boolean aRes;
2326 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2327 if ( aMesh->_is_nil() )
2329 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2330 tr( "SMESH_BAD_SELECTION" ) );
2334 EmitSignalDeactivateDialog();
2335 if ( theCommandID == 407 )
2336 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2338 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2341 case 409: // Change orientation
2342 case 410: // Union of triangles
2343 case 411: // Cutting of quadrangles
2344 case 419: // Splitting volumes into tetrahedra
2348 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2349 tr( "NOT_A_VTK_VIEWER" ) );
2353 if ( checkLock( aStudy ) )
2356 EmitSignalDeactivateDialog();
2357 SMESHGUI_MultiEditDlg* aDlg = NULL;
2358 if ( theCommandID == 409 )
2359 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2360 else if ( theCommandID == 410 )
2361 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2362 else if ( theCommandID == 419 )
2363 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2365 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2370 case 412: // Smoothing
2372 if(checkLock(aStudy)) break;
2374 EmitSignalDeactivateDialog();
2375 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2378 SUIT_MessageBox::warning(desktop(),
2379 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2383 case 413: // Extrusion
2385 if (checkLock(aStudy)) break;
2387 EmitSignalDeactivateDialog();
2388 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2390 SUIT_MessageBox::warning(desktop(),
2391 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2395 case 414: // Revolution
2397 if(checkLock(aStudy)) break;
2399 EmitSignalDeactivateDialog();
2400 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2403 SUIT_MessageBox::warning(desktop(),
2404 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2408 case 415: // Pattern mapping
2410 if ( checkLock( aStudy ) )
2414 EmitSignalDeactivateDialog();
2415 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2418 SUIT_MessageBox::warning(desktop(),
2419 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2423 case 416: // Extrusion along a path
2425 if (checkLock(aStudy)) break;
2427 EmitSignalDeactivateDialog();
2428 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2430 SUIT_MessageBox::warning(desktop(),
2431 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2435 case 417: // Convert mesh to quadratic
2437 startOperation( 417 );
2438 /* if (checkLock(aStudy)) break;
2440 EmitSignalDeactivateDialog();
2441 new SMESHGUI_ConvToQuadDlg();
2443 SUIT_MessageBox::warning(desktop(),
2444 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2448 case 418: // create 2D mesh from 3D
2450 startOperation( 418 );
2453 case 806: // CREATE GEO GROUP
2455 startOperation( 806 );
2458 case 801: // CREATE GROUP
2462 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2463 tr( "NOT_A_VTK_VIEWER" ) );
2467 if(checkLock(aStudy)) break;
2468 EmitSignalDeactivateDialog();
2469 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2471 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2472 SALOME_ListIO selected;
2474 aSel->selectedObjects( selected );
2476 int nbSel = selected.Extent();
2478 // check if mesh is selected
2479 aMesh = SMESH::GetMeshByIO( selected.First() );
2481 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2486 case 802: // CONSTRUCT GROUP
2490 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2491 tr( "NOT_A_VTK_VIEWER" ) );
2495 if(checkLock(aStudy)) break;
2496 EmitSignalDeactivateDialog();
2498 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2499 SALOME_ListIO selected;
2501 aSel->selectedObjects( selected );
2503 int nbSel = selected.Extent();
2505 // check if submesh is selected
2506 Handle(SALOME_InteractiveObject) IObject = selected.First();
2507 if (IObject->hasEntry()) {
2508 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2510 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2511 if (!aSubMesh->_is_nil()) {
2513 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2514 // get submesh elements list by types
2515 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2516 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2517 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2518 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2519 // create group for each type o elements
2520 QString aName = IObject->getName();
2521 QStringList anEntryList;
2522 if (aNodes->length() > 0) {
2523 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2524 aGroup->Add(aNodes.inout());
2525 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2526 anEntryList.append( aSObject->GetID().c_str() );
2528 if (aEdges->length() > 0) {
2529 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2530 aGroup->Add(aEdges.inout());
2531 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2532 anEntryList.append( aSObject->GetID().c_str() );
2534 if (aFaces->length() > 0) {
2535 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2536 aGroup->Add(aFaces.inout());
2537 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2538 anEntryList.append( aSObject->GetID().c_str() );
2540 if (aVolumes->length() > 0) {
2541 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2542 aGroup->Add(aVolumes.inout());
2543 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2544 anEntryList.append( aSObject->GetID().c_str() );
2547 anApp->browseObjects( anEntryList );
2549 catch(const SALOME::SALOME_Exception & S_ex){
2550 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2557 SUIT_MessageBox::warning(desktop(),
2558 tr("SMESH_WRN_WARNING"),
2559 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2564 case 803: // EDIT GROUP
2568 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2569 tr( "NOT_A_VTK_VIEWER" ) );
2573 if(checkLock(aStudy)) break;
2574 EmitSignalDeactivateDialog();
2576 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2577 SALOME_ListIO selected;
2579 aSel->selectedObjects( selected );
2581 SALOME_ListIteratorOfListIO It (selected);
2582 int nbSelectedGroups = 0;
2583 for ( ; It.More(); It.Next() )
2585 SMESH::SMESH_GroupBase_var aGroup =
2586 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2587 if (!aGroup->_is_nil()) {
2589 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2593 if (nbSelectedGroups == 0)
2595 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2601 case 804: // Add elements to group
2603 if(checkLock(aStudy)) break;
2604 if (myState == 800) {
2605 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2606 if (aDlg) aDlg->onAdd();
2611 case 805: // Remove elements from group
2613 if(checkLock(aStudy)) break;
2614 if (myState == 800) {
2615 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2616 if (aDlg) aDlg->onRemove();
2621 case 815: // Edit GEOM GROUP as standalone
2625 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2626 tr( "NOT_A_VTK_VIEWER" ) );
2630 if(checkLock(aStudy)) break;
2631 EmitSignalDeactivateDialog();
2633 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2634 SALOME_ListIO selected;
2636 aSel->selectedObjects( selected );
2638 SALOME_ListIteratorOfListIO It (selected);
2639 for ( ; It.More(); It.Next() )
2641 SMESH::SMESH_GroupOnGeom_var aGroup =
2642 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2643 if (!aGroup->_is_nil()) {
2644 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2649 SMESH::SMESH_GroupOnFilter_var aGroup =
2650 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2651 if (!aGroup->_is_nil()) {
2652 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2660 case 810: // Union Groups
2661 case 811: // Intersect groups
2662 case 812: // Cut groups
2666 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2667 tr( "NOT_A_VTK_VIEWER" ) );
2671 if ( checkLock( aStudy ) )
2674 EmitSignalDeactivateDialog();
2676 SMESHGUI_GroupOpDlg* aDlg = 0;
2677 if ( theCommandID == 810 )
2678 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2679 else if ( theCommandID == 811 )
2680 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2682 aDlg = new SMESHGUI_CutGroupsDlg( this );
2689 case 814: // Create groups of entities from existing groups of superior dimensions
2691 if ( checkLock( aStudy ) )
2694 EmitSignalDeactivateDialog();
2695 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2701 case 813: // Delete groups with their contents
2705 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2706 tr( "NOT_A_VTK_VIEWER" ) );
2710 if ( checkLock( aStudy ) )
2713 EmitSignalDeactivateDialog();
2715 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2719 case 900: // MESH INFOS
2720 case 903: // WHAT IS
2722 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2723 EmitSignalDeactivateDialog();
2724 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2725 SALOME_ListIO selected;
2727 aSel->selectedObjects( selected );
2729 if ( selected.Extent() > 1 ) { // a dlg for each IO
2730 SALOME_ListIteratorOfListIO It( selected );
2731 for ( ; It.More(); It.Next() ) {
2732 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2733 dlg->showInfo( It.Value() );
2738 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2744 case 904: // FIND ELEM
2746 startOperation( theCommandID );
2750 case 1100: // EDIT HYPOTHESIS
2752 if(checkLock(aStudy)) break;
2754 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2755 SALOME_ListIO selected;
2757 aSel->selectedObjects( selected );
2759 int nbSel = selected.Extent();
2762 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2763 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2765 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2766 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2767 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2768 if ( !aHypothesis->_is_nil() )
2771 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2772 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2774 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2784 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2786 if(checkLock(aStudy)) break;
2787 SUIT_OverrideCursor wc;
2789 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2790 SALOME_ListIO selected;
2792 aSel->selectedObjects( selected, QString::null, false );
2794 SALOME_ListIteratorOfListIO It(selected);
2795 for (int i = 0; It.More(); It.Next(), i++) {
2796 Handle(SALOME_InteractiveObject) IObject = It.Value();
2797 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2800 aSel->setSelectedObjects( l1 );
2805 case 4009: // ELEM0D
2807 case 4021: // TRIANGLE
2809 case 4023: // POLYGON
2813 case 4134: // PYRAMID
2814 case 4135: // OCTA12
2816 if(checkLock(aStudy)) break;
2818 EmitSignalDeactivateDialog();
2819 SMDSAbs_EntityType type = SMDSEntity_Edge;
2820 switch (theCommandID) {
2822 type = SMDSEntity_0D; break;
2824 type = SMDSEntity_Triangle; break;
2826 type = SMDSEntity_Quadrangle; break;
2828 type = SMDSEntity_Tetra; break;
2830 type = SMDSEntity_Polygon; break;
2832 type = SMDSEntity_Hexa; break;
2834 type = SMDSEntity_Penta; break;
2836 type = SMDSEntity_Pyramid; break;
2838 type = SMDSEntity_Hexagonal_Prism; break;
2841 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
2844 SUIT_MessageBox::warning(desktop(),
2845 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2849 case 4033: // POLYHEDRON
2851 if(checkLock(aStudy)) break;
2853 EmitSignalDeactivateDialog();
2854 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2857 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2858 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2862 case 4034: // QUADRATIC EDGE
2863 case 4035: // QUADRATIC TRIANGLE
2864 case 4036: // QUADRATIC QUADRANGLE
2865 case 4136: // BIQUADRATIC QUADRANGLE
2866 case 4037: // QUADRATIC TETRAHEDRON
2867 case 4038: // QUADRATIC PYRAMID
2868 case 4039: // QUADRATIC PENTAHEDRON
2869 case 4040: // QUADRATIC HEXAHEDRON
2870 case 4140: // TRIQUADRATIC HEXAHEDRON
2872 if(checkLock(aStudy)) break;
2874 EmitSignalDeactivateDialog();
2875 SMDSAbs_EntityType type;
2877 switch (theCommandID) {
2879 type = SMDSEntity_Quad_Edge; break;
2881 type = SMDSEntity_Quad_Triangle; break;
2883 type = SMDSEntity_Quad_Quadrangle; break;
2885 type = SMDSEntity_BiQuad_Quadrangle; break;
2887 type = SMDSEntity_Quad_Tetra; break;
2889 type = SMDSEntity_Quad_Pyramid; break;
2891 type = SMDSEntity_Quad_Penta; break;
2893 type = SMDSEntity_Quad_Hexa;
2895 type = SMDSEntity_TriQuad_Hexa;
2899 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2902 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2903 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2907 case 4041: // REMOVES NODES
2909 if(checkLock(aStudy)) break;
2911 EmitSignalDeactivateDialog();
2912 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2915 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2916 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2920 case 4042: // REMOVES ELEMENTS
2922 if(checkLock(aStudy)) break;
2924 EmitSignalDeactivateDialog();
2925 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2929 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2930 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2934 case 4043: { // CLEAR_MESH
2936 if(checkLock(aStudy)) break;
2938 SALOME_ListIO selected;
2939 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2940 aSel->selectedObjects( selected );
2942 SUIT_OverrideCursor wc;
2943 SALOME_ListIteratorOfListIO It (selected);
2944 for ( ; It.More(); It.Next() )
2946 Handle(SALOME_InteractiveObject) IOS = It.Value();
2947 SMESH::SMESH_Mesh_var aMesh =
2948 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2949 if ( aMesh->_is_nil()) continue;
2951 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2953 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2954 SMESH::ModifiedMesh( aMeshSObj, false, true);
2955 // hide groups and submeshes
2956 _PTR(ChildIterator) anIter =
2957 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2958 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2960 _PTR(SObject) so = anIter->Value();
2961 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2964 catch (const SALOME::SALOME_Exception& S_ex){
2966 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2970 SMESH::UpdateView();
2974 case 4044: // REMOVE ORPHAN NODES
2976 if(checkLock(aStudy)) break;
2977 SALOME_ListIO selected;
2978 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2979 aSel->selectedObjects( selected );
2980 if ( selected.Extent() == 1 ) {
2981 Handle(SALOME_InteractiveObject) anIO = selected.First();
2982 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2983 if ( !aMesh->_is_nil() ) {
2984 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2985 tr( "SMESH_WARNING" ),
2986 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2987 SUIT_MessageBox::Yes |
2988 SUIT_MessageBox::No,
2989 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2992 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2993 int removed = aMeshEditor->RemoveOrphanNodes();
2994 SUIT_MessageBox::information(SMESHGUI::desktop(),
2995 tr("SMESH_INFORMATION"),
2996 tr("NB_NODES_REMOVED").arg(removed));
2997 if ( removed > 0 ) {
2998 SMESH::UpdateView();
2999 SMESHGUI::Modified();
3002 catch (const SALOME::SALOME_Exception& S_ex) {
3003 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3012 case 4051: // RENUMBERING NODES
3014 if(checkLock(aStudy)) break;
3016 EmitSignalDeactivateDialog();
3017 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3021 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3022 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3026 case 4052: // RENUMBERING ELEMENTS
3028 if(checkLock(aStudy)) break;
3030 EmitSignalDeactivateDialog();
3031 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3035 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3036 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3040 case 4061: // TRANSLATION
3042 if(checkLock(aStudy)) break;
3044 EmitSignalDeactivateDialog();
3045 ( new SMESHGUI_TranslationDlg( this ) )->show();
3048 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3049 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3053 case 4062: // ROTATION
3055 if(checkLock(aStudy)) break;
3057 EmitSignalDeactivateDialog();
3058 ( new SMESHGUI_RotationDlg( this ) )->show();
3061 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3062 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3066 case 4063: // SYMMETRY
3068 if(checkLock(aStudy)) break;
3070 EmitSignalDeactivateDialog();
3071 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3074 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3075 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3079 case 4064: // SEWING
3081 if(checkLock(aStudy)) break;
3083 EmitSignalDeactivateDialog();
3084 ( new SMESHGUI_SewingDlg( this ) )->show();
3087 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3088 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3092 case 4065: // MERGE NODES
3094 if(checkLock(aStudy)) break;
3096 EmitSignalDeactivateDialog();
3097 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3100 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3101 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3105 case 4066: // MERGE EQUAL ELEMENTS
3107 if (checkLock(aStudy)) break;
3109 EmitSignalDeactivateDialog();
3110 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3112 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3113 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3118 case 4067: // MAKE MESH PASS THROUGH POINT
3119 startOperation( 4067 );
3124 if(checkLock(aStudy)) break;
3126 EmitSignalDeactivateDialog();
3127 ( new SMESHGUI_ScaleDlg( this ) )->show();
3130 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3131 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3136 case 4069: // DUPLICATE NODES
3138 if(checkLock(aStudy)) break;
3140 EmitSignalDeactivateDialog();
3141 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3144 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3145 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3150 case 5105: // Library of selection filters
3152 static QList<int> aTypes;
3153 if ( aTypes.isEmpty() )
3155 aTypes.append( SMESH::NODE );
3156 aTypes.append( SMESH::EDGE );
3157 aTypes.append( SMESH::FACE );
3158 aTypes.append( SMESH::VOLUME );
3160 if (!myFilterLibraryDlg)
3161 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3162 else if (myFilterLibraryDlg->isHidden())
3163 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3164 myFilterLibraryDlg->raise();
3168 case 6017: // CONTROLS
3192 LightApp_SelectionMgr* mgr = selectionMgr();
3193 SALOME_ListIO selected; mgr->selectedObjects( selected );
3195 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3196 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3198 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3199 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3200 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3201 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3202 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3203 ::Control( theCommandID );
3208 SUIT_MessageBox::warning(desktop(),
3209 tr( "SMESH_WRN_WARNING" ),
3210 tr( "SMESH_BAD_SELECTION" ) );
3214 SUIT_MessageBox::warning(desktop(),
3215 tr( "SMESH_WRN_WARNING" ),
3216 tr( "NOT_A_VTK_VIEWER" ) );
3221 LightApp_SelectionMgr* mgr = selectionMgr();
3222 SALOME_ListIO selected; mgr->selectedObjects( selected );
3224 SALOME_ListIteratorOfListIO it(selected);
3225 for( ; it.More(); it.Next()) {
3226 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3227 if(anIObject->hasEntry()) {
3228 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3229 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3237 LightApp_SelectionMgr* mgr = selectionMgr();
3238 SALOME_ListIO selected; mgr->selectedObjects( selected );
3240 SALOME_ListIteratorOfListIO it(selected);
3241 for( ; it.More(); it.Next()) {
3242 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3243 if(anIObject->hasEntry())
3244 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3245 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3253 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3254 EmitSignalDeactivateDialog();
3255 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3261 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3262 //updateObjBrowser();
3266 //=============================================================================
3270 //=============================================================================
3271 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3276 //=============================================================================
3280 //=============================================================================
3281 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3286 //=============================================================================
3290 //=============================================================================
3291 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3296 //=============================================================================
3297 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3298 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3300 //=============================================================================
3301 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3302 SUIT_ViewWindow* wnd )
3304 if(theIO->hasEntry()){
3305 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3306 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3310 //=======================================================================
3311 // function : createSMESHAction
3313 //=======================================================================
3314 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3315 const int key, const bool toggle, const QString& shortcutAction )
3318 QWidget* parent = application()->desktop();
3319 SUIT_ResourceMgr* resMgr = resourceMgr();
3321 if ( !icon_id.isEmpty() )
3322 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3324 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3325 if ( !pix.isNull() )
3326 icon = QIcon( pix );
3328 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3329 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3330 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3332 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3333 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3336 //=======================================================================
3337 // function : createPopupItem
3339 //=======================================================================
3340 void SMESHGUI::createPopupItem( const int id,
3341 const QString& clients,
3342 const QString& types,
3343 const QString& theRule,
3348 parentId = popupMgr()->actionId( action( pId ) );
3350 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3351 popupMgr()->insert( action( id ), parentId, 0 );
3353 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3354 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3355 QString rule = "(%1) and (%2) and (%3)";
3356 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3357 if( clients.isEmpty() )
3358 rule = rule.arg( QString( "true" ) );
3360 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3361 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3364 bool cont = myRules.contains( id );
3366 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3368 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3369 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3372 //=======================================================================
3373 // function : initialize
3375 //=======================================================================
3376 void SMESHGUI::initialize( CAM_Application* app )
3378 SalomeApp_Module::initialize( app );
3380 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3382 /* Automatic Update flag */
3383 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3385 // ----- create actions --------------
3387 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3388 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3389 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3390 createSMESHAction( 114, "NUM" );
3391 createSMESHAction( 115, "STL" );
3392 createSMESHAction( 116, "CGNS" );
3393 createSMESHAction( 117, "SAUV" );
3394 createSMESHAction( 121, "DAT" );
3395 createSMESHAction( 122, "MED" );
3396 createSMESHAction( 123, "UNV" );
3397 createSMESHAction( 140, "STL" );
3398 createSMESHAction( 142, "CGNS" );
3399 createSMESHAction( 144, "SAUV" );
3400 createSMESHAction( 124, "EXPORT_DAT" );
3401 createSMESHAction( 125, "EXPORT_MED" );
3402 createSMESHAction( 126, "EXPORT_UNV" );
3403 createSMESHAction( 141, "EXPORT_STL" );
3404 createSMESHAction( 143, "EXPORT_CGNS" );
3405 createSMESHAction( 145, "EXPORT_SAUV" );
3406 createSMESHAction( 150, "FILE_INFO" );
3407 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3408 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3409 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3410 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3411 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3412 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3413 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3414 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3415 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3416 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3417 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3418 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3419 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3420 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3421 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3422 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3423 createSMESHAction( 804, "ADD" );
3424 createSMESHAction( 805, "REMOVE" );
3425 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3426 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3427 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3428 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3429 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3430 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3431 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3432 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3433 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3434 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3435 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3436 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3437 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3438 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3439 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3440 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3441 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3442 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3443 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3444 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3445 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3446 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3447 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3448 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3449 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3450 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3451 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3452 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3453 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3454 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3455 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3456 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3457 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3458 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3459 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3460 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3461 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3462 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3463 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3464 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3465 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3466 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3467 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3468 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3469 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3470 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3471 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3472 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3473 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3474 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3475 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3476 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3477 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3478 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3479 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3480 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3481 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3482 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3483 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3484 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3485 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3486 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3487 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3488 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3489 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3490 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3491 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3492 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3493 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3494 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3495 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3496 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3497 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3498 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3499 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3500 createSMESHAction( 415, "MAP", "ICON_MAP" );
3501 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3502 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3503 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3504 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3505 createSMESHAction( 200, "RESET" );
3506 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3507 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3508 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3509 #ifndef DISABLE_PLOT2DVIEWER
3510 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3512 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3513 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3514 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3515 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3516 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3517 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3518 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3519 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3520 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3521 createSMESHAction( 220, "ALL" );
3522 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3524 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3525 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3527 createSMESHAction( 1100, "EDIT_HYPO" );
3528 createSMESHAction( 1102, "UNASSIGN" );
3529 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3530 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3531 createSMESHAction( 1131, "DISPMODE" );
3532 createSMESHAction( 1132, "COLORS" );
3533 createSMESHAction( 1133, "TRANSP" );
3534 createSMESHAction( 1134, "CLIP" );
3535 createSMESHAction( 1135, "DISP_ENT" );
3536 createSMESHAction( 1136, "AUTO_COLOR" );
3537 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3538 createSMESHAction( 2000, "CTRL" );
3540 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3541 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3543 createSMESHAction( 300, "ERASE" );
3544 createSMESHAction( 301, "DISPLAY" );
3545 createSMESHAction( 302, "DISPLAY_ONLY" );
3547 // ----- create menu --------------
3548 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3549 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3550 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3551 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3552 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3553 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3554 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3555 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3557 createMenu( separator(), fileId );
3559 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3560 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3561 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3562 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3563 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3564 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3565 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3566 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3567 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3568 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3570 createMenu( 111, importId, -1 );
3571 createMenu( 112, importId, -1 );
3572 createMenu( 113, importId, -1 );
3573 createMenu( 115, importId, -1 );
3575 createMenu( 116, importId, -1 );
3577 createMenu( 117, importId, -1 );
3578 createMenu( 121, exportId, -1 );
3579 createMenu( 122, exportId, -1 );
3580 createMenu( 123, exportId, -1 );
3581 createMenu( 140, exportId, -1 ); // export to STL
3583 createMenu( 142, exportId, -1 ); // export to CGNS
3585 createMenu( 144, exportId, -1 ); // export to SAUV
3586 createMenu( separator(), fileId, 10 );
3588 createMenu( 33, editId, -1 );
3590 createMenu( 5105, toolsId, -1 );
3592 createMenu( 702, meshId, -1 ); // "Mesh" menu
3593 createMenu( 703, meshId, -1 );
3594 createMenu( 704, meshId, -1 );
3595 createMenu( 710, meshId, -1 );
3596 createMenu( 705, meshId, -1 );
3597 createMenu( separator(), meshId, -1 );
3598 createMenu( 701, meshId, -1 );
3599 createMenu( 711, meshId, -1 );
3600 createMenu( 712, meshId, -1 );
3601 createMenu( 713, meshId, -1 );
3602 createMenu( separator(), meshId, -1 );
3603 createMenu( 801, meshId, -1 );
3604 createMenu( 806, meshId, -1 );
3605 createMenu( 802, meshId, -1 );
3606 createMenu( 803, meshId, -1 );
3607 createMenu( 815, meshId, -1 );
3608 createMenu( separator(), meshId, -1 );
3609 createMenu( 810, meshId, -1 );
3610 createMenu( 811, meshId, -1 );
3611 createMenu( 812, meshId, -1 );
3612 createMenu( separator(), meshId, -1 );
3613 createMenu( 814, meshId, -1 );
3614 createMenu( separator(), meshId, -1 );
3615 createMenu( 900, meshId, -1 );
3616 //createMenu( 902, meshId, -1 );
3617 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3618 createMenu( 904, meshId, -1 );
3619 createMenu( separator(), meshId, -1 );
3621 createMenu( 6005, nodeId, -1 );
3622 createMenu( 6002, edgeId, -1 );
3623 createMenu( 6003, edgeId, -1 );
3624 createMenu( 6001, edgeId, -1 );
3625 createMenu( 6004, edgeId, -1 );
3626 createMenu( 6021, faceId, -1 );
3627 createMenu( 6025, faceId, -1 );
3628 createMenu( 6027, faceId, -1 );
3629 createMenu( 6018, faceId, -1 );
3630 createMenu( 6019, faceId, -1 );
3631 createMenu( 6011, faceId, -1 );
3632 createMenu( 6012, faceId, -1 );
3633 createMenu( 6013, faceId, -1 );
3634 createMenu( 6014, faceId, -1 );
3635 createMenu( 6015, faceId, -1 );
3636 createMenu( 6016, faceId, -1 );
3637 createMenu( 6022, faceId, -1 );
3638 createMenu( 6017, volumeId, -1 );
3639 createMenu( 6009, volumeId, -1 );
3640 createMenu( 6023, volumeId, -1 );
3641 createMenu( 6024, volumeId, -1 );
3642 createMenu( 6026, volumeId, -1 );
3644 createMenu( 4000, addId, -1 );
3645 createMenu( 4009, addId, -1 );
3646 createMenu( 4010, addId, -1 );
3647 createMenu( 4021, addId, -1 );
3648 createMenu( 4022, addId, -1 );
3649 createMenu( 4023, addId, -1 );
3650 createMenu( 4031, addId, -1 );
3651 createMenu( 4032, addId, -1 );
3652 createMenu( 4133, addId, -1 );
3653 createMenu( 4134, addId, -1 );
3654 createMenu( 4135, addId, -1 );
3655 createMenu( 4033, addId, -1 );
3656 createMenu( separator(), addId, -1 );
3657 createMenu( 4034, addId, -1 );
3658 createMenu( 4035, addId, -1 );
3659 createMenu( 4036, addId, -1 );
3660 createMenu( 4136, addId, -1 );
3661 createMenu( 4037, addId, -1 );
3662 createMenu( 4038, addId, -1 );
3663 createMenu( 4039, addId, -1 );
3664 createMenu( 4040, addId, -1 );
3665 createMenu( 4140, addId, -1 );
3667 createMenu( 4041, removeId, -1 );
3668 createMenu( 4042, removeId, -1 );
3669 createMenu( 4044, removeId, -1 );
3670 createMenu( separator(), removeId, -1 );
3671 createMenu( 813, removeId, -1 );
3672 createMenu( separator(), removeId, -1 );
3673 createMenu( 4043, removeId, -1 );
3675 createMenu( 4051, renumId, -1 );
3676 createMenu( 4052, renumId, -1 );
3678 createMenu( 4061, transfId, -1 );
3679 createMenu( 4062, transfId, -1 );
3680 createMenu( 4063, transfId, -1 );
3681 createMenu( 4068, transfId, -1 );
3682 createMenu( 4064, transfId, -1 );
3683 createMenu( 4065, transfId, -1 );
3684 createMenu( 4066, transfId, -1 );
3685 createMenu( 4069, transfId, -1 );
3687 createMenu( 4067,modifyId, -1 );
3688 createMenu( 407, modifyId, -1 );
3689 createMenu( 408, modifyId, -1 );
3690 createMenu( 409, modifyId, -1 );
3691 createMenu( 410, modifyId, -1 );
3692 createMenu( 411, modifyId, -1 );
3693 createMenu( 419, modifyId, -1 );
3694 createMenu( 412, modifyId, -1 );
3695 createMenu( 413, modifyId, -1 );
3696 createMenu( 416, modifyId, -1 );
3697 createMenu( 414, modifyId, -1 );
3698 createMenu( 415, modifyId, -1 );
3699 createMenu( 417, modifyId, -1 );
3700 createMenu( 418, modifyId, -1 );
3702 createMenu( 501, measureId, -1 );
3703 createMenu( 502, measureId, -1 );
3704 createMenu( 214, viewId, -1 );
3706 // ----- create toolbars --------------
3707 int meshTb = createTool( tr( "TB_MESH" ) ),
3708 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3709 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3710 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3711 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3713 createTool( 702, meshTb );
3714 createTool( 703, meshTb );
3715 createTool( 704, meshTb );
3716 createTool( 710, meshTb );
3717 createTool( 705, meshTb );
3718 createTool( separator(), meshTb );
3719 createTool( 701, meshTb );
3720 createTool( 711, meshTb );
3721 createTool( 712, meshTb );
3722 createTool( 713, meshTb );
3723 createTool( separator(), meshTb );
3724 createTool( 801, meshTb );
3725 createTool( 806, meshTb );
3726 createTool( 802, meshTb );
3727 createTool( 803, meshTb );
3728 //createTool( 815, meshTb );
3729 createTool( separator(), meshTb );
3730 createTool( 900, meshTb );
3731 //createTool( 902, meshTb );
3732 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3733 createTool( 904, meshTb );
3734 createTool( separator(), meshTb );
3736 createTool( 6005, ctrlTb );
3737 createTool( separator(), ctrlTb );
3738 createTool( 6002, ctrlTb );
3739 createTool( 6003, ctrlTb );
3740 createTool( 6001, ctrlTb );
3741 createTool( 6004, ctrlTb );
3742 createTool( separator(), ctrlTb );
3743 createTool( 6021, ctrlTb );
3744 createTool( 6025, ctrlTb );
3745 createTool( 6027, ctrlTb );
3746 createTool( 6018, ctrlTb );
3747 createTool( 6019, ctrlTb );
3748 createTool( 6011, ctrlTb );
3749 createTool( 6012, ctrlTb );
3750 createTool( 6013, ctrlTb );
3751 createTool( 6014, ctrlTb );
3752 createTool( 6015, ctrlTb );
3753 createTool( 6016, ctrlTb );
3754 createTool( 6022, ctrlTb );
3755 createTool( separator(), ctrlTb );
3756 createTool( 6017, ctrlTb );
3757 createTool( 6009, ctrlTb );
3758 createTool( 6023, ctrlTb );
3759 createTool( 6024, ctrlTb );
3760 createTool( 6026, ctrlTb );
3761 createTool( separator(), ctrlTb );
3763 createTool( 4000, addRemTb );
3764 createTool( 4009, addRemTb );
3765 createTool( 4010, addRemTb );
3766 createTool( 4021, addRemTb );
3767 createTool( 4022, addRemTb );
3768 createTool( 4023, addRemTb );
3769 createTool( 4031, addRemTb );
3770 createTool( 4032, addRemTb );
3771 createTool( 4133, addRemTb );
3772 createTool( 4134, addRemTb );
3773 createTool( 4135, addRemTb );
3774 createTool( 4033, addRemTb );
3775 createTool( separator(), addRemTb );
3776 createTool( 4034, addRemTb );
3777 createTool( 4035, addRemTb );
3778 createTool( 4036, addRemTb );
3779 createTool( 4136, addRemTb );
3780 createTool( 4037, addRemTb );
3781 createTool( 4038, addRemTb );
3782 createTool( 4039, addRemTb );
3783 createTool( 4040, addRemTb );
3784 createTool( 4140, addRemTb );
3785 createTool( separator(), addRemTb );
3786 createTool( 4041, addRemTb );
3787 createTool( 4042, addRemTb );
3788 createTool( 4044, addRemTb );
3789 createTool( 4043, addRemTb );
3790 createTool( separator(), addRemTb );
3791 createTool( 4051, addRemTb );
3792 createTool( 4052, addRemTb );
3793 createTool( separator(), addRemTb );
3794 createTool( 4061, addRemTb );
3795 createTool( 4062, addRemTb );
3796 createTool( 4063, addRemTb );
3797 createTool( 4068, addRemTb );
3798 createTool( 4064, addRemTb );
3799 createTool( 4065, addRemTb );
3800 createTool( 4066, addRemTb );
3801 createTool( 4069, addRemTb );
3802 createTool( separator(), addRemTb );
3804 createTool( 4067,modifyTb );
3805 createTool( 407, modifyTb );
3806 createTool( 408, modifyTb );
3807 createTool( 409, modifyTb );
3808 createTool( 410, modifyTb );
3809 createTool( 411, modifyTb );
3810 createTool( 419, modifyTb );
3811 createTool( 412, modifyTb );
3812 createTool( 413, modifyTb );
3813 createTool( 416, modifyTb );
3814 createTool( 414, modifyTb );
3815 createTool( 415, modifyTb );
3816 createTool( 417, modifyTb );
3817 createTool( 418, modifyTb );
3819 createTool( 214, dispModeTb );
3821 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3822 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3825 QString OB = "'ObjectBrowser'",
3826 View = "'" + SVTK_Viewer::Type() + "'",
3828 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3829 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3830 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3831 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3832 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3833 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3834 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3835 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3836 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3837 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3838 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3840 mesh_part = mesh + " " + subMesh + " " + group,
3841 mesh_group = mesh + " " + group,
3842 hyp_alg = hypo + " " + algo;
3844 // popup for object browser
3846 isInvisible("not( isVisible )"),
3847 isEmpty("numberOfNodes = 0"),
3848 isNotEmpty("numberOfNodes <> 0"),
3850 // has nodes, edges, etc in VISIBLE! actor
3851 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3852 hasElems("(count( elemTypes ) > 0)"),
3853 hasDifferentElems("(count( elemTypes ) > 1)"),
3854 hasElems0d("({'Elem0d'} in elemTypes)"),
3855 hasEdges("({'Edge'} in elemTypes)"),
3856 hasFaces("({'Face'} in elemTypes)"),
3857 hasVolumes("({'Volume'} in elemTypes)");
3859 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3860 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3861 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3862 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3863 createPopupItem( 803, OB, group ); // EDIT_GROUP
3864 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3866 popupMgr()->insert( separator(), -1, 0 );
3867 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3868 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3869 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3870 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3871 createPopupItem( 214, OB, mesh_part ); // UPDATE
3872 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3873 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3874 popupMgr()->insert( separator(), -1, 0 );
3875 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3876 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3877 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3878 popupMgr()->insert( separator(), -1, 0 );
3879 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3880 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3881 popupMgr()->insert( separator(), -1, 0 );
3882 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3883 popupMgr()->insert( separator(), -1, 0 );
3884 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3885 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3887 popupMgr()->insert( separator(), -1, 0 );
3889 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3890 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3891 QString only_one_2D = only_one_non_empty + " && dim>1";
3893 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3894 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3895 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3897 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3899 createPopupItem( 145, OB, mesh_group, multiple_non_empty ); // EXPORT_SAUV
3900 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3901 popupMgr()->insert( separator(), -1, 0 );
3904 createPopupItem( 803, View, group ); // EDIT_GROUP
3905 createPopupItem( 804, View, elems ); // ADD
3906 createPopupItem( 805, View, elems ); // REMOVE
3908 popupMgr()->insert( separator(), -1, 0 );
3909 createPopupItem( 214, View, mesh_part ); // UPDATE
3910 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3911 createPopupItem( 904, View, mesh ); // FIND_ELEM
3912 popupMgr()->insert( separator(), -1, 0 );
3914 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3915 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3916 popupMgr()->insert( separator(), -1, 0 );
3919 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3920 QString aType = QString( "%1type in {%2}" ).arg( lc );
3921 aType = aType.arg( mesh_part );
3922 QString aMeshInVTK = aClient + "&&" + aType;
3924 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3925 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3926 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3928 //-------------------------------------------------
3930 //-------------------------------------------------
3931 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3933 popupMgr()->insert( action( 9010 ), anId, -1 );
3934 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3935 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3937 popupMgr()->insert( action( 9011 ), anId, -1 );
3938 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3939 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3941 popupMgr()->insert( separator(), -1, -1 );
3943 //-------------------------------------------------
3945 //-------------------------------------------------
3946 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3948 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3949 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3950 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3952 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3953 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3954 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3956 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3957 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3958 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3960 popupMgr()->insert( separator(), anId, -1 );
3962 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3963 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3964 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3966 //-------------------------------------------------
3968 //-------------------------------------------------
3969 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3971 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3973 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3974 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3975 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3977 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3978 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3979 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3981 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3982 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3983 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3985 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3986 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3987 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3989 popupMgr()->insert( separator(), anId, -1 );
3991 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3992 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3995 //-------------------------------------------------
3996 // Representation of the 2D Quadratic elements
3997 //-------------------------------------------------
3998 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3999 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4000 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4001 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4003 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4004 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4005 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4007 //-------------------------------------------------
4008 // Orientation of faces
4009 //-------------------------------------------------
4010 popupMgr()->insert( action( 221 ), -1, -1 );
4011 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4012 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4014 //-------------------------------------------------
4016 //-------------------------------------------------
4017 popupMgr()->insert( action( 1132 ), -1, -1 );
4018 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4020 //-------------------------------------------------
4022 //-------------------------------------------------
4023 popupMgr()->insert( action( 1133 ), -1, -1 );
4024 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4026 //-------------------------------------------------
4028 //-------------------------------------------------
4030 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4031 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4032 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4033 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4035 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4037 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4038 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4040 popupMgr()->insert( separator(), anId, -1 );
4042 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4044 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4045 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4046 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4048 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4050 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4051 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4052 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4054 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4055 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4056 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4058 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4059 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4060 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4062 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4063 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4064 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4066 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4068 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4069 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4070 QtxPopupMgr::VisibleRule );
4071 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4073 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4074 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4075 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4077 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4078 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4079 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4081 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4082 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4083 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4085 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4086 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4087 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4089 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4090 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4091 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4093 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4094 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4095 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4097 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4098 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4099 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4101 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4102 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4103 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4105 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4106 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4107 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4109 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4110 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4111 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4113 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4114 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4115 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4117 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4119 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4120 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4121 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4123 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4124 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4125 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4127 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4128 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4129 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4131 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4132 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4133 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4135 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4136 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4137 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4139 popupMgr()->insert( separator(), anId, -1 );
4141 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4142 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4144 popupMgr()->insert( separator(), anId, -1 );
4146 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4148 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4149 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4151 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4152 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4153 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4155 #ifndef DISABLE_PLOT2DVIEWER
4156 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4157 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4160 //-------------------------------------------------
4162 //-------------------------------------------------
4163 popupMgr()->insert( separator(), -1, -1 );
4164 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4165 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4166 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4167 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4169 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4170 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4172 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4173 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4175 popupMgr()->insert( separator(), -1, -1 );
4177 //-------------------------------------------------
4179 //-------------------------------------------------
4180 popupMgr()->insert( action( 1134 ), -1, -1 );
4181 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4183 popupMgr()->insert( separator(), -1, -1 );
4185 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4186 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4188 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4189 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4192 //================================================================================
4194 * \brief Return true if SMESH or GEOM objects are selected.
4195 * Is called form LightApp_Module::activateModule() which clear selection if
4196 * not isSelectionCompatible()
4198 //================================================================================
4200 bool SMESHGUI::isSelectionCompatible()
4202 bool isCompatible = true;
4203 SALOME_ListIO selected;
4204 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4205 Sel->selectedObjects( selected );
4207 SALOME_ListIteratorOfListIO It( selected );
4208 for ( ; isCompatible && It.More(); It.Next())
4210 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4211 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4213 return isCompatible;
4217 bool SMESHGUI::reusableOperation( const int id )
4219 // compute, evaluate and precompute are not reusable operations
4220 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4223 bool SMESHGUI::activateModule( SUIT_Study* study )
4225 bool res = SalomeApp_Module::activateModule( study );
4227 setMenuShown( true );
4228 setToolShown( true );
4230 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4231 PyGILState_STATE gstate = PyGILState_Ensure();
4232 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4233 if(pluginsmanager==NULL)
4237 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4242 PyGILState_Release(gstate);
4243 // end of GEOM plugins loading
4245 // Reset actions accelerator keys
4246 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4247 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4248 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4250 action( 33)->setEnabled(true); // Delete: Key_Delete
4252 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4253 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4254 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4255 if ( _PTR(Study) aStudy = s->studyDS()) {
4256 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4257 updateObjBrowser(); // objects can be removed
4260 // get all view currently opened in the study and connect their signals to
4261 // the corresponding slots of the class.
4262 SUIT_Desktop* aDesk = study->application()->desktop();
4264 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4265 SUIT_ViewWindow* wnd;
4266 foreach ( wnd, wndList )
4273 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4275 setMenuShown( false );
4276 setToolShown( false );
4278 EmitSignalCloseAllDialogs();
4280 // Unset actions accelerator keys
4281 action(111)->setShortcut(QKeySequence()); // Import DAT
4282 action(112)->setShortcut(QKeySequence()); // Import UNV
4283 action(113)->setShortcut(QKeySequence()); // Import MED
4285 action( 33)->setEnabled(false); // Delete: Key_Delete
4287 return SalomeApp_Module::deactivateModule( study );
4290 void SMESHGUI::studyClosed( SUIT_Study* s )
4292 SMESH::RemoveVisuData( s->id() );
4293 SalomeApp_Module::studyClosed( s );
4296 void SMESHGUI::OnGUIEvent()
4298 const QObject* obj = sender();
4299 if ( !obj || !obj->inherits( "QAction" ) )
4301 int id = actionId((QAction*)obj);
4306 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4308 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4309 if ( CORBA::is_nil( myComponentSMESH ) )
4311 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4313 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4314 return aGUI.myComponentSMESH;
4317 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4318 return myComponentSMESH;
4321 QString SMESHGUI::engineIOR() const
4323 CORBA::ORB_var anORB = getApp()->orb();
4324 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4325 return QString( anIOR.in() );
4328 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4330 SalomeApp_Module::contextMenuPopup( client, menu, title );
4332 selectionMgr()->selectedObjects( lst );
4333 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4334 Handle(SALOME_InteractiveObject) io = lst.First();
4335 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4336 _PTR(Study) study = appStudy->studyDS();
4337 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4339 QString aName = QString( obj->GetName().c_str() );
4340 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4341 aName.remove( (aName.length() - 1), 1 );
4347 LightApp_Selection* SMESHGUI::createSelection() const
4349 return new SMESHGUI_Selection();
4352 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4354 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4355 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4358 void SMESHGUI::viewManagers( QStringList& list ) const
4360 list.append( SVTK_Viewer::Type() );
4363 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4365 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4366 SMESH::UpdateSelectionProp( this );
4368 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4369 for(int i = 0; i < aViews.count() ; i++){
4370 SUIT_ViewWindow *sf = aViews[i];
4376 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4378 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4379 myClippingPlaneInfoMap.erase( theViewManager );
4382 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4384 theActor->AddObserver( SMESH::DeleteActorEvent,
4385 myEventCallbackCommand.GetPointer(),
4389 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4390 unsigned long theEvent,
4391 void* theClientData,
4394 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4395 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4396 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4397 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4398 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4399 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4400 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4401 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4402 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4403 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4404 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4405 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4406 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4407 if( anActor == *anIter3 ) {
4408 anActorList.erase( anIter3 );
4419 void SMESHGUI::createPreferences()
4421 // General tab ------------------------------------------------------------------------
4422 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4424 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4425 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4426 setPreferenceProperty( lim, "min", 0 );
4427 setPreferenceProperty( lim, "max", 100000000 );
4428 setPreferenceProperty( lim, "step", 1000 );
4429 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4431 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4432 setPreferenceProperty( qaGroup, "columns", 2 );
4433 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4434 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4435 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4436 setPreferenceProperty( prec, "min", 0 );
4437 setPreferenceProperty( prec, "max", 16 );
4439 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4440 setPreferenceProperty( dispgroup, "columns", 2 );
4441 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4443 modes.append( tr("MEN_WIRE") );
4444 modes.append( tr("MEN_SHADE") );
4445 modes.append( tr("MEN_NODES") );
4446 modes.append( tr("MEN_SHRINK") );
4447 QList<QVariant> indices;
4448 indices.append( 0 );
4449 indices.append( 1 );
4450 indices.append( 2 );
4451 indices.append( 3 );
4452 setPreferenceProperty( dispmode, "strings", modes );
4453 setPreferenceProperty( dispmode, "indexes", indices );
4455 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4456 setPreferenceProperty( arcgroup, "columns", 2 );
4457 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4458 QStringList quadraticModes;
4459 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4460 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4462 indices.append( 0 );
4463 indices.append( 1 );
4464 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4465 setPreferenceProperty( quadraticmode, "indexes", indices );
4467 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4468 "SMESH", "max_angle" );
4469 setPreferenceProperty( maxAngle, "min", 1 );
4470 setPreferenceProperty( maxAngle, "max", 90 );
4474 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4475 setPreferenceProperty( exportgroup, "columns", 2 );
4476 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4477 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4479 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4480 setPreferenceProperty( computeGroup, "columns", 2 );
4481 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4483 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4484 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4485 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4487 indices.append( 0 );
4488 indices.append( 1 );
4489 indices.append( 2 );
4490 setPreferenceProperty( notifyMode, "strings", modes );
4491 setPreferenceProperty( notifyMode, "indexes", indices );
4493 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4494 setPreferenceProperty( infoGroup, "columns", 4 );
4495 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4497 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4498 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4500 indices.append( 0 );
4501 indices.append( 1 );
4502 setPreferenceProperty( elemInfo, "strings", modes );
4503 setPreferenceProperty( elemInfo, "indexes", indices );
4504 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4505 setPreferenceProperty( nodesLim, "min", 0 );
4506 setPreferenceProperty( nodesLim, "max", 10000000 );
4507 setPreferenceProperty( nodesLim, "step", 10000 );
4508 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4510 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4511 setPreferenceProperty( segGroup, "columns", 2 );
4512 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4513 "SMESH", "segmentation" );
4514 setPreferenceProperty( segLen, "min", 1 );
4515 setPreferenceProperty( segLen, "max", 10000000 );
4516 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4517 "SMESH", "nb_segments_per_edge" );
4518 setPreferenceProperty( nbSeg, "min", 1 );
4519 setPreferenceProperty( nbSeg, "max", 10000000 );
4521 // Quantities with individual precision settings
4522 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4523 setPreferenceProperty( precGroup, "columns", 2 );
4525 const int nbQuantities = 6;
4526 int precs[nbQuantities], ii = 0;
4527 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4528 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4529 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4530 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4531 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4532 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4533 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4534 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4535 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4536 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4537 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4538 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4540 // Set property for precision value for spinboxes
4541 for ( ii = 0; ii < nbQuantities; ii++ ){
4542 setPreferenceProperty( precs[ii], "min", -14 );
4543 setPreferenceProperty( precs[ii], "max", 14 );
4544 setPreferenceProperty( precs[ii], "precision", 2 );
4547 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4548 setPreferenceProperty( previewGroup, "columns", 2 );
4549 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4550 setPreferenceProperty( chunkSize, "min", 0 );
4551 setPreferenceProperty( chunkSize, "max", 1000 );
4552 setPreferenceProperty( chunkSize, "step", 50 );
4554 // Mesh tab ------------------------------------------------------------------------
4555 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4556 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4557 setPreferenceProperty( nodeGroup, "columns", 3 );
4559 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4561 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4563 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4564 QList<QVariant> aMarkerTypeIndicesList;
4565 QList<QVariant> aMarkerTypeIconsList;
4566 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4567 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4568 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4569 aMarkerTypeIndicesList << i;
4570 aMarkerTypeIconsList << pixmap;
4572 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4573 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4575 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4577 QList<QVariant> aMarkerScaleIndicesList;
4578 QStringList aMarkerScaleValuesList;
4579 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4580 aMarkerScaleIndicesList << i;
4581 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4583 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4584 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4586 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4587 setPreferenceProperty( elemGroup, "columns", 2 );
4589 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4590 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4592 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4593 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4595 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4597 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4598 setPreferenceProperty( grpGroup, "columns", 2 );
4600 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4602 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4603 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4604 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4605 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4606 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4607 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4609 setPreferenceProperty( size0d, "min", 1 );
4610 setPreferenceProperty( size0d, "max", 10 );
4612 setPreferenceProperty( elemW, "min", 1 );
4613 setPreferenceProperty( elemW, "max", 5 );
4615 setPreferenceProperty( shrink, "min", 0 );
4616 setPreferenceProperty( shrink, "max", 100 );
4618 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4619 setPreferenceProperty( orientGroup, "columns", 1 );
4621 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4622 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4624 setPreferenceProperty( orientScale, "min", 0.05 );
4625 setPreferenceProperty( orientScale, "max", 0.5 );
4626 setPreferenceProperty( orientScale, "step", 0.05 );
4628 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4630 // Selection tab ------------------------------------------------------------------------
4631 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4633 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4634 setPreferenceProperty( selGroup, "columns", 2 );
4636 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4637 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4638 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4640 setPreferenceProperty( selW, "min", 1 );
4641 setPreferenceProperty( selW, "max", 5 );
4643 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4644 setPreferenceProperty( preGroup, "columns", 2 );
4646 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4647 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4649 setPreferenceProperty( preW, "min", 1 );
4650 setPreferenceProperty( preW, "max", 5 );
4652 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4653 setPreferenceProperty( precSelGroup, "columns", 2 );
4655 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4656 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4657 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4659 // Scalar Bar tab ------------------------------------------------------------------------
4660 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4661 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4662 setPreferenceProperty( fontGr, "columns", 2 );
4664 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4665 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4667 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4668 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4670 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4671 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4673 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4674 setPreferenceProperty( numcol, "min", 2 );
4675 setPreferenceProperty( numcol, "max", 256 );
4677 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4678 setPreferenceProperty( numlab, "min", 2 );
4679 setPreferenceProperty( numlab, "max", 65 );
4681 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4682 setPreferenceProperty( orientGr, "columns", 2 );
4683 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4684 QStringList orients;
4685 orients.append( tr( "SMESH_VERTICAL" ) );
4686 orients.append( tr( "SMESH_HORIZONTAL" ) );
4687 indices.clear(); indices.append( 0 ); indices.append( 1 );
4688 setPreferenceProperty( orient, "strings", orients );
4689 setPreferenceProperty( orient, "indexes", indices );
4691 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4692 setPreferenceProperty( posVSizeGr, "columns", 2 );
4693 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4694 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4695 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4696 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4697 setPreferenceProperty( xv, "step", 0.1 );
4698 setPreferenceProperty( xv, "min", 0.0 );
4699 setPreferenceProperty( xv, "max", 1.0 );
4700 setPreferenceProperty( yv, "step", 0.1 );
4701 setPreferenceProperty( yv, "min", 0.0 );
4702 setPreferenceProperty( yv, "max", 1.0 );
4703 setPreferenceProperty( wv, "step", 0.1 );
4704 setPreferenceProperty( wv, "min", 0.0 );
4705 setPreferenceProperty( wv, "max", 1.0 );
4706 setPreferenceProperty( hv, "min", 0.0 );
4707 setPreferenceProperty( hv, "max", 1.0 );
4708 setPreferenceProperty( hv, "step", 0.1 );
4710 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4711 setPreferenceProperty( posHSizeGr, "columns", 2 );
4712 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4713 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4714 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4715 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4716 setPreferenceProperty( xv, "min", 0.0 );
4717 setPreferenceProperty( xv, "max", 1.0 );
4718 setPreferenceProperty( xv, "step", 0.1 );
4719 setPreferenceProperty( xh, "min", 0.0 );
4720 setPreferenceProperty( xh, "max", 1.0 );
4721 setPreferenceProperty( xh, "step", 0.1 );
4722 setPreferenceProperty( yh, "min", 0.0 );
4723 setPreferenceProperty( yh, "max", 1.0 );
4724 setPreferenceProperty( yh, "step", 0.1 );
4725 setPreferenceProperty( wh, "min", 0.0 );
4726 setPreferenceProperty( wh, "max", 1.0 );
4727 setPreferenceProperty( wh, "step", 0.1 );
4728 setPreferenceProperty( hh, "min", 0.0 );
4729 setPreferenceProperty( hh, "max", 1.0 );
4730 setPreferenceProperty( hh, "step", 0.1 );
4732 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4733 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4734 setPreferenceProperty( distributionGr, "columns", 3 );
4736 types.append( tr( "SMESH_MONOCOLOR" ) );
4737 types.append( tr( "SMESH_MULTICOLOR" ) );
4738 indices.clear(); indices.append( 0 ); indices.append( 1 );
4739 setPreferenceProperty( coloringType, "strings", types );
4740 setPreferenceProperty( coloringType, "indexes", indices );
4741 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4745 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4747 if( sect=="SMESH" ) {
4748 float sbX1,sbY1,sbW,sbH;
4749 float aTol = 1.00000009999999;
4750 std::string aWarning;
4751 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4752 if( name=="selection_object_color" || name=="selection_element_color" ||
4753 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4754 name=="selection_precision_node" || name=="selection_precision_element" ||
4755 name=="selection_precision_object")
4756 SMESH::UpdateSelectionProp( this );
4757 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4758 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4759 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4760 if(sbX1+sbW > aTol){
4761 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4764 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4765 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4768 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4769 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4770 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4771 if(sbY1+sbH > aTol){
4772 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4773 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4774 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4777 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4778 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4779 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4780 if(sbX1+sbW > aTol){
4781 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4784 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4785 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4788 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4789 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4790 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4791 if(sbY1+sbH > aTol){
4792 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4795 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4796 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4799 else if ( name == "segmentation" ) {
4800 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4801 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4803 else if ( name == "nb_segments_per_edge" ) {
4804 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4805 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4808 if(aWarning.size() != 0){
4809 aWarning += "The default values are applied instead.";
4810 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4811 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4812 QObject::tr(aWarning.c_str()));
4817 //================================================================================
4819 * \brief Update something in accordance with update flags
4820 * \param theFlags - update flags
4822 * Update viewer or/and object browser etc. in accordance with update flags ( see
4823 * LightApp_UpdateFlags enumeration ).
4825 //================================================================================
4826 void SMESHGUI::update( const int flags )
4828 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4829 SMESH::UpdateView();
4831 SalomeApp_Module::update( flags );
4834 //================================================================================
4836 * \brief Set default selection mode
4838 * SLOT called when operation commited. Sets default selection mode
4840 //================================================================================
4841 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4843 SVTK_ViewWindow* vtkWnd =
4844 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4846 vtkWnd->SetSelectionMode( ActorSelection );
4849 //================================================================================
4851 * \brief Set default selection mode
4853 * SLOT called when operation aborted. Sets default selection mode
4855 //================================================================================
4856 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4858 SVTK_ViewWindow* vtkWnd =
4859 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4861 vtkWnd->SetSelectionMode( ActorSelection );
4864 //================================================================================
4866 * \brief Creates operation with given identifier
4867 * \param id - identifier of operation to be started
4868 * \return Pointer on created operation or NULL if operation is not created
4870 * Virtual method redefined from the base class creates operation with given id.
4871 * It is called called automatically from startOperation method of base class.
4873 //================================================================================
4874 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4876 LightApp_Operation* op = 0;
4877 // to do : create operation here
4880 case 417: //convert to quadratic
4881 op = new SMESHGUI_ConvToQuadOp();
4883 case 418: // create 2D mesh as boundary on 3D
4884 op = new SMESHGUI_Make2DFrom3DOp();
4886 case 701: // Compute mesh
4887 op = new SMESHGUI_ComputeOp();
4889 case 702: // Create mesh
4890 op = new SMESHGUI_MeshOp( true, true );
4892 case 703: // Create sub-mesh
4893 op = new SMESHGUI_MeshOp( true, false );
4895 case 704: // Edit mesh/sub-mesh
4896 op = new SMESHGUI_MeshOp( false );
4898 case 711: // Precompute mesh
4899 op = new SMESHGUI_PrecomputeOp();
4901 case 712: // Evaluate mesh
4902 op = new SMESHGUI_EvaluateOp();
4904 case 713: // Evaluate mesh
4905 op = new SMESHGUI_MeshOrderOp();
4907 case 806: // Create group on geom
4908 op = new SMESHGUI_GroupOnShapeOp();
4910 case 904: // Find element
4911 op = new SMESHGUI_FindElemByPointOp();
4913 case 4067: // make mesh pass through point
4914 op = new SMESHGUI_MakeNodeAtPointOp();
4921 op = SalomeApp_Module::createOperation( id );
4925 //================================================================================
4927 * \brief Stops current operations and starts a given one
4928 * \param id - The id of the operation to start
4930 //================================================================================
4932 void SMESHGUI::switchToOperation(int id)
4934 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4935 activeStudy()->abortAllOperations();
4936 startOperation( id );
4939 LightApp_Displayer* SMESHGUI::displayer()
4942 myDisplayer = new SMESHGUI_Displayer( getApp() );
4946 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4949 int aTolerance = 64;
4950 int anIterations = 0;
4956 if( anIterations % aPeriod == 0 )
4959 if( aTolerance < 1 )
4963 aHue = (int)( 360.0 * rand() / RAND_MAX );
4966 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4967 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4968 for( ; it != itEnd; ++it )
4970 SALOMEDS::Color anAutoColor = *it;
4971 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4974 aQColor.getHsv( &h, &s, &v );
4975 if( abs( h - aHue ) < aTolerance )
4987 aColor.setHsv( aHue, 255, 255 );
4989 SALOMEDS::Color aSColor;
4990 aSColor.R = (double)aColor.red() / 255.0;
4991 aSColor.G = (double)aColor.green() / 255.0;
4992 aSColor.B = (double)aColor.blue() / 255.0;
4997 const char gSeparator = '_'; // character used to separate parameter names
4998 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4999 const char gPathSep = '|'; // character used to separate paths
5002 * \brief Store visual parameters
5004 * This method is called just before the study document is saved.
5005 * Store visual parameters in AttributeParameter attribue(s)
5007 void SMESHGUI::storeVisualParameters (int savePoint)
5009 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5010 if (!appStudy || !appStudy->studyDS())
5012 _PTR(Study) studyDS = appStudy->studyDS();
5014 // componentName is used for encoding of entries when storing them in IParameters
5015 std::string componentName = myComponentSMESH->ComponentDataType();
5016 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5017 //if (!aSComponent) return;
5020 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5021 componentName.c_str(),
5023 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5025 // store map of custom markers
5026 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5027 if( !aMarkerMap.empty() )
5029 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5030 for( ; anIter != aMarkerMap.end(); anIter++ )
5032 int anId = anIter->first;
5033 VTK::MarkerData aMarkerData = anIter->second;
5034 std::string aMarkerFileName = aMarkerData.first;
5035 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5036 if( aMarkerTexture.size() < 3 )
5037 continue; // should contain at least width, height and the first value
5039 QString aPropertyName( "texture" );
5040 aPropertyName += gSeparator;
5041 aPropertyName += QString::number( anId );
5043 QString aPropertyValue = aMarkerFileName.c_str();
5044 aPropertyValue += gPathSep;
5046 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5047 ushort aWidth = *aTextureIter++;
5048 ushort aHeight = *aTextureIter++;
5049 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5050 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5051 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5052 aPropertyValue += QString::number( *aTextureIter );
5054 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5058 // viewers counters are used for storing view_numbers in IParameters
5061 // main cycle to store parameters of displayed objects
5062 QList<SUIT_ViewManager*> lst;
5063 QList<SUIT_ViewManager*>::Iterator it;
5064 getApp()->viewManagers(lst);
5065 for (it = lst.begin(); it != lst.end(); it++)
5067 SUIT_ViewManager* vman = *it;
5068 QString vType = vman->getType();
5070 // saving VTK actors properties
5071 if (vType == SVTK_Viewer::Type())
5073 // store the clipping planes attached to the view manager
5074 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5075 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5076 if( anIter != myClippingPlaneInfoMap.end() )
5077 aClippingPlaneInfoList = anIter->second;
5079 if( !aClippingPlaneInfoList.empty() ) {
5080 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5081 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5083 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5084 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5086 QString aPropertyName( "ClippingPlane" );
5087 aPropertyName += gSeparator;
5088 aPropertyName += QString::number( vtkViewers );
5089 aPropertyName += gSeparator;
5090 aPropertyName += QString::number( anId );
5092 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5093 aPropertyValue += gDigitsSep;
5094 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5095 aPropertyValue += gDigitsSep;
5096 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5097 aPropertyValue += gDigitsSep;
5098 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5100 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5104 QVector<SUIT_ViewWindow*> views = vman->getViews();
5105 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5107 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5109 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5110 vtkActorCollection* allActors = aCopy.GetActors();
5111 allActors->InitTraversal();
5112 while (vtkActor* actor = allActors->GetNextActor())
5114 if (actor->GetVisibility()) // store only visible actors
5116 SMESH_Actor* aSmeshActor = 0;
5117 if (actor->IsA("SMESH_Actor"))
5118 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5119 if (aSmeshActor && aSmeshActor->hasIO())
5121 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5124 // entry is "encoded" = it does NOT contain component adress,
5125 // since it is a subject to change on next component loading
5126 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5128 std::string param, vtkParam = vType.toLatin1().data();
5129 vtkParam += gSeparator;
5130 vtkParam += QString::number(vtkViewers).toLatin1().data();
5131 vtkParam += gSeparator;
5134 param = vtkParam + "Visibility";
5135 ip->setParameter(entry, param, "On");
5138 param = vtkParam + "Representation";
5139 ip->setParameter(entry, param, QString::number
5140 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5143 param = vtkParam + "IsShrunk";
5144 ip->setParameter(entry, param, QString::number
5145 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5147 // Displayed entities
5148 unsigned int aMode = aSmeshActor->GetEntityMode();
5149 bool isE = aMode & SMESH_Actor::eEdges;
5150 bool isF = aMode & SMESH_Actor::eFaces;
5151 bool isV = aMode & SMESH_Actor::eVolumes;
5153 QString modeStr ("e");
5154 modeStr += gDigitsSep; modeStr += QString::number(isE);
5155 modeStr += gDigitsSep; modeStr += "f";
5156 modeStr += gDigitsSep; modeStr += QString::number(isF);
5157 modeStr += gDigitsSep; modeStr += "v";
5158 modeStr += gDigitsSep; modeStr += QString::number(isV);
5160 param = vtkParam + "Entities";
5161 ip->setParameter(entry, param, modeStr.toLatin1().data());
5163 // Colors (surface:edge:)
5164 vtkFloatingPointType r, g, b;
5167 aSmeshActor->GetSufaceColor(r, g, b, delta);
5168 QString colorStr ("surface");
5169 colorStr += gDigitsSep; colorStr += QString::number(r);
5170 colorStr += gDigitsSep; colorStr += QString::number(g);
5171 colorStr += gDigitsSep; colorStr += QString::number(b);
5173 colorStr += gDigitsSep; colorStr += "backsurface";
5174 colorStr += gDigitsSep; colorStr += QString::number(delta);
5177 aSmeshActor->GetEdgeColor(r, g, b);
5178 colorStr += gDigitsSep; colorStr += "edge";
5179 colorStr += gDigitsSep; colorStr += QString::number(r);
5180 colorStr += gDigitsSep; colorStr += QString::number(g);
5181 colorStr += gDigitsSep; colorStr += QString::number(b);
5183 aSmeshActor->GetNodeColor(r, g, b);
5184 colorStr += gDigitsSep; colorStr += "node";
5185 colorStr += gDigitsSep; colorStr += QString::number(r);
5186 colorStr += gDigitsSep; colorStr += QString::number(g);
5187 colorStr += gDigitsSep; colorStr += QString::number(b);
5189 aSmeshActor->GetOutlineColor(r, g, b);
5190 colorStr += gDigitsSep; colorStr += "outline";
5191 colorStr += gDigitsSep; colorStr += QString::number(r);
5192 colorStr += gDigitsSep; colorStr += QString::number(g);
5193 colorStr += gDigitsSep; colorStr += QString::number(b);
5195 param = vtkParam + "Colors";
5196 ip->setParameter(entry, param, colorStr.toLatin1().data());
5198 // Sizes of lines and points
5199 QString sizeStr ("line");
5200 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5201 sizeStr += gDigitsSep; sizeStr += "shrink";
5202 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5204 param = vtkParam + "Sizes";
5205 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5210 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5211 if( aMarkerType == VTK::MT_USER ) {
5212 markerStr += "custom";
5213 markerStr += gDigitsSep;
5214 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5218 markerStr += gDigitsSep;
5219 markerStr += QString::number( (int)aMarkerType );
5220 markerStr += gDigitsSep;
5221 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5224 param = vtkParam + "PointMarker";
5225 ip->setParameter(entry, param, markerStr.toLatin1().data());
5228 param = vtkParam + "Opacity";
5229 ip->setParameter(entry, param,
5230 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5233 param = vtkParam + "ClippingPlane";
5235 if( !aClippingPlaneInfoList.empty() ) {
5236 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5237 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5239 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5240 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5241 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5242 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5243 if( aSmeshActor == *anIter2 ) {
5244 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5245 QString::number( anId ).toLatin1().constData() );
5252 ip->setParameter( entry, param, "Off" );
5253 } // if (io->hasEntry())
5254 } // SMESH_Actor && hasIO
5256 } // while.. actors traversal
5260 } // if (SVTK view model)
5261 } // for (viewManagers)
5264 // data structures for clipping planes processing
5267 vtkIdType Orientation;
5268 vtkFloatingPointType Distance;
5269 vtkFloatingPointType Angle[2];
5271 typedef std::list<TPlaneData> TPlaneDataList;
5272 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5274 typedef std::list<vtkActor*> TActorList;
5277 TActorList ActorList;
5278 SUIT_ViewManager* ViewManager;
5280 typedef std::list<TPlaneInfo> TPlaneInfoList;
5281 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5284 * \brief Restore visual parameters
5286 * This method is called after the study document is opened.
5287 * Restore visual parameters from AttributeParameter attribue(s)
5289 void SMESHGUI::restoreVisualParameters (int savePoint)
5291 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5292 if (!appStudy || !appStudy->studyDS())
5294 _PTR(Study) studyDS = appStudy->studyDS();
5296 // componentName is used for encoding of entries when storing them in IParameters
5297 std::string componentName = myComponentSMESH->ComponentDataType();
5298 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5299 //if (!aSComponent) return;
5302 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5303 componentName.c_str(),
5305 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5307 // restore map of custom markers and map of clipping planes
5308 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5309 TPlaneDataMap aPlaneDataMap;
5311 std::vector<std::string> properties = ip->getProperties();
5312 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5314 std::string property = *propIt;
5315 QString aPropertyName( property.c_str() );
5316 QString aPropertyValue( ip->getProperty( property ).c_str() );
5318 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5319 if( aPropertyNameList.isEmpty() )
5322 QString aPropertyType = aPropertyNameList[0];
5323 if( aPropertyType == "texture" )
5325 if( aPropertyNameList.size() != 2 )
5329 int anId = aPropertyNameList[1].toInt( &ok );
5330 if( !ok || anId < 1 )
5333 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5334 if( aPropertyValueList.size() != 2 )
5337 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5338 QString aMarkerTextureString = aPropertyValueList[1];
5339 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5340 if( aMarkerTextureStringList.size() != 3 )
5344 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5349 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5353 VTK::MarkerTexture aMarkerTexture;
5354 aMarkerTexture.push_back( aWidth );
5355 aMarkerTexture.push_back( aHeight );
5357 QString aMarkerTextureData = aMarkerTextureStringList[2];
5358 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5360 QChar aChar = aMarkerTextureData.at( i );
5361 if( aChar.isDigit() )
5362 aMarkerTexture.push_back( aChar.digitValue() );
5365 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5367 else if( aPropertyType == "ClippingPlane" )
5369 if( aPropertyNameList.size() != 3 )
5373 int aViewId = aPropertyNameList[1].toInt( &ok );
5374 if( !ok || aViewId < 0 )
5378 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5379 if( !ok || aClippingPlaneId < 0 )
5382 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5383 if( aPropertyValueList.size() != 4 )
5386 TPlaneData aPlaneData;
5387 aPlaneData.Id = aClippingPlaneId;
5390 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5395 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5400 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5405 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5409 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5410 aPlaneDataList.push_back( aPlaneData );
5414 TPlaneInfoMap aPlaneInfoMap;
5416 std::vector<std::string> entries = ip->getEntries();
5418 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5420 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5421 QString entry (ip->decodeEntry(*entIt).c_str());
5423 // Check that the entry corresponds to a real object in the Study
5424 // as the object may be deleted or modified after the visual state is saved.
5425 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5426 if (!so) continue; //Skip the not existent entry
5428 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5429 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5431 std::vector<std::string>::iterator namesIt = paramNames.begin();
5432 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5434 // actors are stored in a map after displaying of them for
5435 // quicker access in the future: map < viewID to actor >
5436 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5438 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5440 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5441 // '_' is used as separator and should not be used in viewer type or parameter names.
5442 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5443 if (lst.size() != 3)
5446 QString viewerTypStr = lst[0];
5447 QString viewIndexStr = lst[1];
5448 QString paramNameStr = lst[2];
5451 int viewIndex = viewIndexStr.toUInt(&ok);
5452 if (!ok) // bad conversion of view index to integer
5456 if (viewerTypStr == SVTK_Viewer::Type())
5458 SMESH_Actor* aSmeshActor = 0;
5459 if (vtkActors.IsBound(viewIndex))
5460 aSmeshActor = vtkActors.Find(viewIndex);
5462 QList<SUIT_ViewManager*> lst;
5463 getApp()->viewManagers(viewerTypStr, lst);
5465 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5466 SUIT_ViewManager* vman = NULL;
5467 if (viewIndex >= 0 && viewIndex < lst.count())
5468 vman = lst.at(viewIndex);
5470 if (paramNameStr == "Visibility")
5472 if (!aSmeshActor && displayer() && vman)
5474 SUIT_ViewModel* vmodel = vman->getViewModel();
5475 // SVTK view model can be casted to SALOME_View
5476 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5478 // store displayed actor in a temporary map for quicker
5479 // access later when restoring other parameters
5480 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5481 vtkRenderer* Renderer = vtkView->getRenderer();
5482 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5483 vtkActorCollection* theActors = aCopy.GetActors();
5484 theActors->InitTraversal();
5485 bool isFound = false;
5486 vtkActor *ac = theActors->GetNextActor();
5487 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5488 if (ac->IsA("SMESH_Actor")) {
5489 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5490 if (aGeomAc->hasIO()) {
5491 Handle(SALOME_InteractiveObject) io =
5492 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5493 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5495 vtkActors.Bind(viewIndex, aGeomAc);
5501 } // if (paramNameStr == "Visibility")
5504 // the rest properties "work" with SMESH_Actor
5507 QString val ((*valuesIt).c_str());
5510 if (paramNameStr == "Representation") {
5511 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5514 else if (paramNameStr == "IsShrunk") {
5516 if (!aSmeshActor->IsShrunk())
5517 aSmeshActor->SetShrink();
5520 if (aSmeshActor->IsShrunk())
5521 aSmeshActor->UnShrink();
5524 // Displayed entities
5525 else if (paramNameStr == "Entities") {
5526 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5527 if (mode.count() == 6) {
5528 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5529 MESSAGE("Invalid order of data in Entities, must be: "
5530 "e:0/1:f:0/1:v:0/1");
5533 unsigned int aMode = aSmeshActor->GetEntityMode();
5534 unsigned int aNewMode =
5535 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5536 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5537 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5538 if (aNewMode != aMode)
5539 aSmeshActor->SetEntityMode(aNewMode);
5544 else if (paramNameStr == "Colors") {
5545 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5546 if (colors.count() == 16 || colors.count() == 18 ) {
5547 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5548 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
5549 (colors.count() == 18 && colors[14] != "outline")) {
5550 MESSAGE("Invalid order of data in Colors, must be: "
5551 "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");
5557 vtkFloatingPointType otr,otg,otb;
5558 //Old case backsurface color is independent
5559 if( colors.count() == 16 ) {
5561 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5562 er = colors[9].toFloat();
5563 eg = colors[10].toFloat();
5564 eb = colors[11].toFloat();
5566 nr = colors[13].toFloat();
5567 ng = colors[14].toFloat();
5568 nb = colors[15].toFloat();
5569 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5571 //New case backsurface color depends on surface color
5572 delta = colors[5].toInt();
5574 er = colors[7].toFloat();
5575 eg = colors[8].toFloat();
5576 eb = colors[9].toFloat();
5578 nr = colors[11].toFloat();
5579 ng = colors[12].toFloat();
5580 nb = colors[13].toFloat();
5582 otr = colors[15].toFloat();
5583 otg = colors[16].toFloat();
5584 otb = colors[17].toFloat();
5586 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5587 aSmeshActor->SetEdgeColor(er,eg,eb);
5588 aSmeshActor->SetNodeColor(nr,ng,nb);
5589 aSmeshActor->SetOutlineColor(otr,otg,otb);
5593 // Sizes of lines and points
5594 else if (paramNameStr == "Sizes") {
5595 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5596 if (sizes.count() == 4) {
5597 if (sizes[0] != "line" || sizes[2] != "shrink") {
5598 MESSAGE("Invalid order of data in Sizes, must be: "
5599 "line:int:shrink:float");
5602 aSmeshActor->SetLineWidth(sizes[1].toInt());
5603 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5606 else if (sizes.count() == 6) { // just to support old format
5607 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5608 MESSAGE("Invalid order of data in Sizes, must be: "
5609 "line:int:node:int:shrink:float");
5612 aSmeshActor->SetLineWidth(sizes[1].toInt());
5613 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5614 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5619 else if (paramNameStr == "PointMarker") {
5620 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5621 if( data.count() >= 2 ) {
5623 int aParam1 = data[1].toInt( &ok );
5625 if( data[0] == "std" && data.count() == 3 ) {
5626 int aParam2 = data[2].toInt( &ok );
5627 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5629 else if( data[0] == "custom" ) {
5630 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5631 if( markerIt != aMarkerMap.end() ) {
5632 VTK::MarkerData aMarkerData = markerIt->second;
5633 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5640 else if (paramNameStr == "Opacity") {
5641 aSmeshActor->SetOpacity(val.toFloat());
5644 else if (paramNameStr.startsWith("ClippingPlane")) {
5645 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5646 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5647 // new format - val looks like "Off" or "0" (plane id)
5648 // (note: in new format "Off" value is used only for consistency,
5649 // so it is processed together with values in old format)
5650 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5651 if( anIsOldFormat ) {
5652 if (paramNameStr == "ClippingPlane1" || val == "Off")
5653 aSmeshActor->RemoveAllClippingPlanes();
5655 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5656 double aDistance = vals[1].toFloat();
5657 vtkFloatingPointType anAngle[2];
5658 anAngle[0] = vals[2].toFloat();
5659 anAngle[1] = vals[3].toFloat();
5661 QList<SUIT_ViewManager*> lst;
5662 getApp()->viewManagers(viewerTypStr, lst);
5663 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5664 if (viewIndex >= 0 && viewIndex < lst.count()) {
5665 SUIT_ViewManager* vman = lst.at(viewIndex);
5666 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5668 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5670 SMESH::TActorList anActorList;
5671 anActorList.push_back( aSmeshActor );
5672 SMESH::OrientedPlane* aPlane =
5673 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5675 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5676 aClippingPlaneInfo.Plane = aPlane;
5677 aClippingPlaneInfo.ActorList = anActorList;
5678 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5685 int aPlaneId = val.toInt( &ok );
5686 if( ok && aPlaneId >= 0 ) {
5687 bool anIsDefinedPlane = false;
5688 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5689 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5690 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5691 TPlaneInfo& aPlaneInfo = *anIter;
5692 if( aPlaneInfo.PlaneId == aPlaneId ) {
5693 aPlaneInfo.ActorList.push_back( aSmeshActor );
5694 anIsDefinedPlane = true;
5698 if( !anIsDefinedPlane ) {
5699 TPlaneInfo aPlaneInfo;
5700 aPlaneInfo.PlaneId = aPlaneId;
5701 aPlaneInfo.ActorList.push_back( aSmeshActor );
5702 aPlaneInfo.ViewManager = vman;
5704 // to make the list sorted by plane id
5705 anIter = aPlaneInfoList.begin();
5706 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5707 const TPlaneInfo& aPlaneInfoRef = *anIter;
5708 if( aPlaneInfoRef.PlaneId > aPlaneId )
5711 aPlaneInfoList.insert( anIter, aPlaneInfo );
5716 } // if (aSmeshActor)
5717 } // other parameters than Visibility
5719 } // for names/parameters iterator
5720 } // for entries iterator
5722 // take into account planes with empty list of actors referred to them
5723 QList<SUIT_ViewManager*> aVMList;
5724 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5726 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5727 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5728 int aViewId = aPlaneDataIter->first;
5729 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5730 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5732 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5734 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5735 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5736 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5737 const TPlaneData& aPlaneData = *anIter2;
5738 int aPlaneId = aPlaneData.Id;
5740 bool anIsFound = false;
5741 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5742 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5743 const TPlaneInfo& aPlaneInfo = *anIter3;
5744 if( aPlaneInfo.PlaneId == aPlaneId ) {
5751 TPlaneInfo aPlaneInfo; // ActorList field is empty
5752 aPlaneInfo.PlaneId = aPlaneId;
5753 aPlaneInfo.ViewManager = aViewManager;
5755 // to make the list sorted by plane id
5756 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5757 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5758 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5759 if( aPlaneInfoRef.PlaneId > aPlaneId )
5762 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5768 // add clipping planes to actors according to the restored parameters
5769 // and update the clipping plane map
5770 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5771 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5772 int aViewId = anIter1->first;
5773 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5775 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5776 if( anIter2 == aPlaneDataMap.end() )
5778 const TPlaneDataList& aPlaneDataList = anIter2->second;
5780 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5781 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5782 const TPlaneInfo& aPlaneInfo = *anIter3;
5783 int aPlaneId = aPlaneInfo.PlaneId;
5784 const TActorList& anActorList = aPlaneInfo.ActorList;
5785 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5789 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5793 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5795 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5796 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5797 const TPlaneData& aPlaneData = *anIter4;
5798 if( aPlaneData.Id == aPlaneId ) {
5799 SMESH::OrientedPlane* aPlane =
5800 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5802 (SMESH::Orientation)aPlaneData.Orientation,
5803 aPlaneData.Distance,
5806 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5807 aClippingPlaneInfo.Plane = aPlane;
5808 aClippingPlaneInfo.ActorList = anActorList;
5809 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5817 // update all VTK views
5818 QList<SUIT_ViewManager*> lst;
5819 getApp()->viewManagers(lst);
5820 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5821 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5822 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5823 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5824 vtkView->getRenderer()->ResetCameraClippingRange();
5831 \brief Adds preferences for dfont of VTK viewer
5833 \param pIf group identifier
5834 \param param parameter
5835 \return identifier of preferences
5837 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5839 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5841 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5844 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5845 fam.append( tr( "SMESH_FONT_COURIER" ) );
5846 fam.append( tr( "SMESH_FONT_TIMES" ) );
5848 setPreferenceProperty( tfont, "fonts", fam );
5850 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5851 setPreferenceProperty( tfont, "features", f );
5857 \brief Actions after hypothesis edition
5858 Updates object browser after hypothesis edition
5860 void SMESHGUI::onHypothesisEdit( int result )
5863 SMESHGUI::Modified();
5864 updateObjBrowser( true );
5869 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5870 \param pview view being closed
5872 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5873 #ifndef DISABLE_PLOT2DVIEWER
5874 //Crear all Plot2d Viewers if need.
5875 SMESH::ClearPlot2Viewers(pview);
5880 \brief Connects or disconnects signals about activating and cloning view on the module slots
5881 \param pview view which is connected/disconnected
5883 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5887 SUIT_ViewManager* viewMgr = pview->getViewManager();
5889 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5890 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5892 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5893 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5898 \brief Return \c true if object can be renamed
5900 bool SMESHGUI::renameAllowed( const QString& entry) const {
5901 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5905 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5909 bool appRes = SalomeApp_Module::renameAllowed(entry);
5913 // check type to prevent renaming of inappropriate objects
5914 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5915 if (aType == MESH || aType == GROUP ||
5916 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5917 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5918 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5919 aType == HYPOTHESIS || aType == ALGORITHM)
5926 Rename object by entry.
5927 \param entry entry of the object
5928 \param name new name of the object
5929 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5931 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5933 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5937 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5941 bool appRes = SalomeApp_Module::renameObject(entry,name);
5945 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5946 _PTR(GenericAttribute) anAttr;
5947 _PTR(AttributeName) aName;
5949 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5951 // check type to prevent renaming of inappropriate objects
5952 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5953 if (aType == MESH || aType == GROUP ||
5954 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5955 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5956 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5957 aType == HYPOTHESIS || aType == ALGORITHM) {
5958 if ( !name.isEmpty() ) {
5959 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5961 // update name of group object and its actor
5962 Handle(SALOME_InteractiveObject) IObject =
5963 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5965 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5966 if( !aGroupObject->_is_nil() ) {
5967 aGroupObject->SetName( qPrintable(name) );
5968 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5969 anActor->setName( qPrintable(name) );