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>
102 #include <SalomeApp_DataObject.h>
104 #include <LightApp_DataOwner.h>
105 #include <LightApp_Preferences.h>
106 #include <LightApp_SelectionMgr.h>
107 #include <LightApp_UpdateFlags.h>
108 #include <LightApp_NameDlg.h>
110 #include <SVTK_ViewWindow.h>
111 #include <SVTK_ViewModel.h>
112 #include <SVTK_ViewManager.h>
114 #include <VTKViewer_Algorithm.h>
116 #include <SUIT_MessageBox.h>
117 #include <SUIT_ResourceMgr.h>
118 #include <SUIT_FileDlg.h>
119 #include <SUIT_Desktop.h>
120 #include <SUIT_OverrideCursor.h>
121 #include <SUIT_Session.h>
123 #include <QtxPopupMgr.h>
124 #include <QtxFontEdit.h>
126 #include <SALOME_ListIO.hxx>
127 #include <SALOME_ListIteratorOfListIO.hxx>
129 #ifndef DISABLE_PLOT2DVIEWER
130 #include <SPlot2d_ViewModel.h>
131 #include <SPlot2d_Histogram.h>
135 #include <SALOMEconfig.h>
136 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
137 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
138 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
141 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
142 #include <QApplication>
144 #include <QTextStream>
147 #include <boost/shared_ptr.hpp>
150 #include <vtkCamera.h>
151 #include <vtkRenderer.h>
152 #include <vtkPlane.h>
153 #include <vtkCallbackCommand.h>
154 #include <vtkLookupTable.h>
156 // SALOME KERNEL includes
157 #include <SALOMEDS_Study.hxx>
158 #include <SALOMEDSClient_StudyBuilder.hxx>
159 #include <SALOMEDSClient_SComponent.hxx>
160 #include <SALOMEDSClient_ClientFactory.hxx>
161 #include <SALOMEDSClient_IParameters.hxx>
164 #include <Standard_ErrorHandler.hxx>
165 #include <NCollection_DataMap.hxx>
167 //To disable automatic genericobj management, the following line should be commented.
168 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
169 #define WITHGENERICOBJ
173 //=============================================================
174 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
177 void ExportMeshToFile(int theCommandID);
179 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
181 void SetDisplayEntity(int theCommandID);
183 void Control( int theCommandID );
187 //=============================================================
188 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
192 std::string myExtension;
194 if ( theCommandID == 113 ) {
195 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
196 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
198 else if ( theCommandID == 112 ) {
199 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
201 else if ( theCommandID == 111 ) {
202 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
204 else if ( theCommandID == 115 ) {
205 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
207 else if ( theCommandID == 116 ) {
208 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
210 else if ( theCommandID == 117 ) {
211 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
212 filter.append( QObject::tr( "All files (*)" ) );
215 QString anInitialPath = "";
216 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
217 anInitialPath = QDir::currentPath();
219 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
222 QObject::tr( "SMESH_IMPORT_MESH" ) );
223 if ( filenames.count() > 0 ) {
224 SUIT_OverrideCursor wc;
225 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
228 QStringList anEntryList;
229 bool isEmpty = false;
230 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
231 QString filename = *it;
232 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
234 switch ( theCommandID ) {
237 // DAT format (currently unsupported)
238 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
239 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
245 aMeshes->length( 1 );
246 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
247 if ( aMeshes[0]->_is_nil() )
248 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
249 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
255 SMESH::DriverMED_ReadStatus res;
256 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
257 if ( res != SMESH::DRS_OK ) {
258 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
259 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
266 aMeshes->length( 1 );
267 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
268 if ( aMeshes[0]->_is_nil() ) {
269 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
270 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
277 SMESH::DriverMED_ReadStatus res;
278 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
279 if ( res != SMESH::DRS_OK ) {
280 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
281 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
288 SMESH::DriverMED_ReadStatus res;
289 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
290 if ( res != SMESH::DRS_OK ) {
291 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
292 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
298 catch ( const SALOME::SALOME_Exception& S_ex ) {
299 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
300 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
303 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
304 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
306 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
307 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
308 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
309 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
310 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
312 anEntryList.append( aMeshSO->GetID().c_str() );
314 #ifdef WITHGENERICOBJ
315 // obj has been published in study. Its refcount has been incremented.
316 // It is safe to decrement its refcount
317 // so that it will be destroyed when the entry in study will be removed
318 aMeshes[i]->UnRegister();
327 // update Object browser
328 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
330 // browse to the published meshes
331 if( LightApp_Application* anApp =
332 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
333 anApp->browseObjects( anEntryList );
335 // show Error message box if there were errors
336 if ( errors.count() > 0 ) {
337 SUIT_MessageBox::critical( SMESHGUI::desktop(),
338 QObject::tr( "SMESH_ERROR" ),
339 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
342 // show warning message box, if some imported mesh is empty
344 SUIT_MessageBox::warning( SMESHGUI::desktop(),
345 QObject::tr( "SMESH_WRN_WARNING" ),
346 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
351 //================================================================================
353 * \brief Export selected meshes or groups into a file
355 //================================================================================
357 void ExportMeshToFile( int theCommandID )
359 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
360 SALOME_ListIO selected;
362 aSel->selectedObjects( selected );
364 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
365 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
366 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
367 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
368 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
369 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
371 // actually, the following condition can't be met (added for insurance)
372 if( selected.Extent() == 0 ||
373 ( selected.Extent() > 1 && !isMED && !isSTL ))
376 // get mesh object from selection and check duplication of their names
377 bool hasDuplicatedMeshNames = false;
378 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
379 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
380 SALOME_ListIteratorOfListIO It( selected );
381 for( ; It.More(); It.Next() )
383 Handle(SALOME_InteractiveObject) anIObject = It.Value();
384 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
385 if ( aMeshItem->_is_nil() ) {
386 SUIT_MessageBox::warning( SMESHGUI::desktop(),
387 QObject::tr( "SMESH_WRN_WARNING" ),
388 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
392 QString aMeshName = anIObject->getName();
394 // check for name duplications
395 if ( !hasDuplicatedMeshNames )
396 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
397 if( aMeshName == (*aMeshIter).second ) {
398 hasDuplicatedMeshNames = true;
403 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
406 if( hasDuplicatedMeshNames && isMED ) {
407 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
408 QObject::tr("SMESH_WRN_WARNING"),
409 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
410 QObject::tr("SMESH_BUT_YES"),
411 QObject::tr("SMESH_BUT_NO"), 0, 1);
416 aMeshIter = aMeshList.begin();
417 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
418 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
419 QString aMeshName = (*aMeshIter).second;
421 if ( isMED || isCGNS || isSAUV )
423 // check for equal group names within each mesh
424 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
425 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
426 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
427 int aRet = SUIT_MessageBox::warning
428 (SMESHGUI::desktop(),
429 QObject::tr("SMESH_WRN_WARNING"),
430 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
431 QObject::tr("SMESH_BUT_YES"),
432 QObject::tr("SMESH_BUT_NO"), 0, 1);
440 // warn the user about presence of not supported elements
441 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
442 int nbNotSupported = ( nbElems[ SMESH::Entity_Pyramid ] +
443 nbElems[ SMESH::Entity_Quad_Pyramid ] +
444 nbElems[ SMESH::Entity_Hexagonal_Prism ] +
445 nbElems[ SMESH::Entity_Polygon ] +
446 nbElems[ SMESH::Entity_Polyhedra ] );
447 if ( nbNotSupported > 0 ) {
448 int aRet = SUIT_MessageBox::warning
449 (SMESHGUI::desktop(),
450 QObject::tr("SMESH_WRN_WARNING"),
451 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
452 QObject::tr("SMESH_BUT_YES"),
453 QObject::tr("SMESH_BUT_NO"), 0, 1);
459 // Get parameters of export operation
462 SMESH::MED_VERSION aFormat;
463 // Init the parameters with the default values
464 bool aIsASCII_STL = true;
465 bool toCreateGroups = false;
466 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
468 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
469 bool toOverwrite = true;
471 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
472 QString anInitialPath = "";
473 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
474 anInitialPath = QDir::currentPath();
476 if ( isUNV || isDAT )
479 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
481 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
482 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
483 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
484 anInitialPath + QString("/") + aMeshName,
485 aFilter, aTitle, false);
487 else if ( isCGNS )// Export to CGNS
489 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
490 fd->setWindowTitle( aTitle );
491 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
492 if ( !anInitialPath.isEmpty() )
493 fd->setDirectory( anInitialPath );
494 fd->selectFile(aMeshName);
495 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
496 fd->setValidator( fv );
499 aFilename = fd->selectedFile();
500 toOverwrite = fv->isOverwrite();
504 else if ( isSTL ) // Export to STL
506 QMap<QString, int> aFilterMap;
507 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
508 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
511 QMap<QString, int>::const_iterator it = aFilterMap.begin();
512 for ( ; it != aFilterMap.end(); ++it )
513 filters.push_back( it.key() );
515 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
516 fd->setWindowTitle( aTitle );
517 fd->setNameFilters( filters );
518 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
519 if ( !anInitialPath.isEmpty() )
520 fd->setDirectory( anInitialPath );
521 fd->selectFile(aMeshName);
525 aFilename = fd->selectedFile();
526 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
531 else if ( isMED || isSAUV ) // Export to MED or SAUV
533 QMap<QString, SMESH::MED_VERSION> aFilterMap;
534 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
536 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
537 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
538 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
541 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
542 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
543 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
547 QString aDefaultFilter;
548 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
549 for ( ; it != aFilterMap.end(); ++it ) {
550 filters.push_back( it.key() );
551 if (it.value() == SMESH::MED_V2_2)
552 aDefaultFilter = it.key();
555 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
556 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
557 fd->setWindowTitle( aTitle );
558 fd->setNameFilters( filters );
559 fd->selectNameFilter(aDefaultFilter);
560 fd->SetChecked(toCreateGroups);
561 if ( !anInitialPath.isEmpty() )
562 fd->setDirectory( anInitialPath );
563 fd->selectFile(aMeshName);
565 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
566 fd->setValidator( fv );
571 aFilename = fd->selectedFile();
573 aFilename = QString::null;
576 aFormat = aFilterMap[fd->selectedNameFilter()];
577 toOverwrite = fv->isOverwrite();
579 if ( !aFilename.isEmpty() ) {
580 // med-2.1 does not support poly elements
581 if ( aFormat==SMESH::MED_V2_1 )
582 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
583 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
584 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
585 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
586 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
588 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
589 QObject::tr("SMESH_WRN_WARNING"),
590 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
591 QObject::tr("SMESH_BUT_YES"),
592 QObject::tr("SMESH_BUT_NO"), 0, 1);
600 // can't append to an existing using other format
601 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
602 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
603 if( !isVersionOk || aVersion != aFormat ) {
604 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
605 QObject::tr("SMESH_WRN_WARNING"),
606 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
607 QObject::tr("SMESH_BUT_YES"),
608 QObject::tr("SMESH_BUT_NO"), 0, 1);
615 QStringList aMeshNamesCollisionList;
616 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
617 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
618 QString anExistingMeshName( aMeshNames[ i ] );
619 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
620 QString anExportMeshName = (*aMeshIter).second;
621 if( anExportMeshName == anExistingMeshName ) {
622 aMeshNamesCollisionList.append( anExportMeshName );
627 if( !aMeshNamesCollisionList.isEmpty() ) {
628 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
629 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
630 QObject::tr("SMESH_WRN_WARNING"),
631 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
632 QObject::tr("SMESH_BUT_YES"),
633 QObject::tr("SMESH_BUT_NO"),
634 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
643 toCreateGroups = fd->IsChecked();
653 if ( !aFilename.isEmpty() ) {
654 // Check whether the file already exists and delete it if yes
655 QFile aFile( aFilename );
656 if ( aFile.exists() && toOverwrite )
658 SUIT_OverrideCursor wc;
661 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
662 // bool Renumber = false;
663 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
665 // Renumber= resMgr->booleanValue("SMESH","renumbering");
667 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
668 // aMeshEditor->RenumberNodes();
669 // aMeshEditor->RenumberElements();
670 // if ( SMESHGUI::automaticUpdate() )
671 // SMESH::UpdateView();
675 aMeshIter = aMeshList.begin();
676 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
678 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
679 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
680 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
681 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
682 aFormat, toOverwrite && aMeshIndex == 0 );
684 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
685 aFormat, toOverwrite && aMeshIndex == 0 );
690 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
692 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
693 if( !aMeshItem->_is_nil() )
694 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
699 if ( aMeshOrGroup->_is_equivalent( aMesh ))
700 aMesh->ExportDAT( aFilename.toLatin1().data() );
702 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
706 if ( aMeshOrGroup->_is_equivalent( aMesh ))
707 aMesh->ExportUNV( aFilename.toLatin1().data() );
709 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
713 if ( aMeshOrGroup->_is_equivalent( aMesh ))
714 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
716 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
720 aMeshIter = aMeshList.begin();
721 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
723 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
724 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
725 aMeshItem->ExportCGNS( aMeshOrGroup,
726 aFilename.toLatin1().data(),
727 toOverwrite && aMeshIndex == 0 );
731 catch (const SALOME::SALOME_Exception& S_ex){
733 SUIT_MessageBox::warning(SMESHGUI::desktop(),
734 QObject::tr("SMESH_WRN_WARNING"),
735 QObject::tr("SMESH_EXPORT_FAILED"));
741 inline void InverseEntityMode(unsigned int& theOutputMode,
742 unsigned int theMode)
744 bool anIsNotPresent = ~theOutputMode & theMode;
746 theOutputMode |= theMode;
748 theOutputMode &= ~theMode;
751 void SetDisplayEntity(int theCommandID){
752 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
753 SALOME_ListIO selected;
755 aSel->selectedObjects( selected );
757 if(selected.Extent() >= 1){
758 SALOME_ListIteratorOfListIO It( selected );
759 for( ; It.More(); It.Next()){
760 Handle(SALOME_InteractiveObject) IObject = It.Value();
761 if(IObject->hasEntry()){
762 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
763 unsigned int aMode = anActor->GetEntityMode();
764 switch(theCommandID){
766 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
769 InverseEntityMode(aMode,SMESH_Actor::eEdges);
772 InverseEntityMode(aMode,SMESH_Actor::eFaces);
775 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
778 aMode = SMESH_Actor::eAllEntity;
782 anActor->SetEntityMode(aMode);
790 SALOME_ListIO selected;
791 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
795 LightApp_SelectionMgr* aSel = app->selectionMgr();
796 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
797 if( !aSel || !appStudy )
800 aSel->selectedObjects( selected );
801 if( selected.IsEmpty() )
804 Handle(SALOME_InteractiveObject) anIObject = selected.First();
806 _PTR(Study) aStudy = appStudy->studyDS();
807 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
808 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
809 if( aMainObject->_is_nil() )
812 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
814 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
815 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
817 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
818 SALOMEDS::Color aColor = aGroupObject->GetColor();
819 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
821 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
822 if( aGroupObject->GetType() == SMESH::NODE )
823 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
824 else if( aGroupObject->GetType() == SMESH::EDGE )
825 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
826 else if( aGroupObject->GetType() == SMESH::ELEM0D )
827 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
831 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
832 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
838 SMESH::RepaintCurrentView();
841 QString functorToString( SMESH::Controls::FunctorPtr f )
843 QString type = QObject::tr( "UNKNOWN_CONTROL" );
844 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
845 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
846 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
847 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
848 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
849 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
850 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
851 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
852 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
853 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
854 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
855 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
856 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
857 type = QObject::tr( "WARP_ELEMENTS" );
858 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
859 type = QObject::tr( "TAPER_ELEMENTS" );
860 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
861 type = QObject::tr( "SKEW_ELEMENTS" );
862 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
863 type = QObject::tr( "AREA_ELEMENTS" );
864 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
865 type = QObject::tr( "LENGTH_EDGES" );
866 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
867 type = QObject::tr( "LENGTH2D_EDGES" );
868 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
869 type = QObject::tr( "MULTI_BORDERS" );
870 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
871 type = QObject::tr( "MULTI2D_BORDERS" );
872 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
873 type = QObject::tr( "FREE_NODES" );
874 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
875 type = QObject::tr( "FREE_EDGES" );
876 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
877 type = QObject::tr( "FREE_BORDERS" );
878 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
879 type = QObject::tr( "FREE_FACES" );
880 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
881 type = QObject::tr( "BARE_BORDER_VOLUME" );
882 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
883 type = QObject::tr( "BARE_BORDER_FACE" );
884 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
885 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
886 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
887 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
888 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
889 type = QObject::tr( "EQUAL_NODE" );
890 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
891 type = QObject::tr( "EQUAL_EDGE" );
892 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
893 type = QObject::tr( "EQUAL_FACE" );
894 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
895 type = QObject::tr( "EQUAL_VOLUME" );
899 void SaveDistribution()
901 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
902 SALOME_ListIO selected;
904 aSel->selectedObjects( selected );
906 if ( selected.Extent() == 1 ) {
907 Handle(SALOME_InteractiveObject) anIO = selected.First();
908 if ( anIO->hasEntry() ) {
909 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
910 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
911 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
912 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
913 if ( aScalarBarActor && aFunctor ) {
914 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
916 std::vector<int> elements;
917 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
918 if ( mesh->_is_nil() ) {
919 SMESH::SMESH_IDSource_var idSource =
920 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
921 if ( !idSource->_is_nil() )
923 SMESH::long_array_var ids = idSource->GetIDs();
924 elements.resize( ids->length() );
925 for ( unsigned i = 0; i < elements.size(); ++i )
926 elements[i] = ids[i];
929 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
930 vtkLookupTable* lookupTable =
931 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
932 double * minmax = lookupTable->GetRange();
933 std::vector<int> nbEvents;
934 std::vector<double> funValues;
935 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
936 QString anInitialPath = "";
937 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
938 anInitialPath = QDir::currentPath();
939 QString aMeshName = anIO->getName();
941 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
942 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
943 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
944 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
945 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
948 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
950 if ( !aFilename.isEmpty() ) {
951 QFile f( aFilename );
952 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
953 QTextStream out( &f );
954 out << "# Mesh: " << aMeshName << endl;
955 out << "# Control: " << functorToString( aFunctor ) << endl;
957 out.setFieldWidth( 10 );
958 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
959 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
970 void ShowDistribution() {
971 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
972 SALOME_ListIO selected;
974 aSel->selectedObjects( selected );
976 if ( selected.Extent() == 1 ) {
977 Handle(SALOME_InteractiveObject) anIO = selected.First();
978 if ( anIO->hasEntry() ) {
979 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
980 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
981 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
982 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
988 #ifndef DISABLE_PLOT2DVIEWER
989 void PlotDistribution() {
990 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
994 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
995 SALOME_ListIO selected;
997 aSel->selectedObjects( selected );
999 if ( selected.Extent() == 1 ) {
1000 Handle(SALOME_InteractiveObject) anIO = selected.First();
1001 if ( anIO->hasEntry() ) {
1002 //Find Actor by entry before getting Plot2d viewer,
1003 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1004 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1006 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1011 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1015 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1019 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1020 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1021 QString functorName = functorToString( anActor->GetFunctor());
1022 QString aHistogramName("%1 : %2");
1023 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1024 aHistogram->setName(aHistogramName);
1025 aHistogram->setHorTitle(functorName);
1026 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1027 aPlot->displayObject(aHistogram, true);
1032 #endif //DISABLE_PLOT2DVIEWER
1034 void DisableAutoColor(){
1035 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1036 SALOME_ListIO selected;
1038 aSel->selectedObjects( selected );
1040 if(selected.Extent()){
1041 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1042 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1043 if ( !aMesh->_is_nil() ) {
1044 aMesh->SetAutoColor( false );
1049 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1050 SALOME_ListIO selected;
1051 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1055 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1056 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1057 if( !aSel || !appStudy )
1060 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1061 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1062 aModule->EmitSignalDeactivateDialog();
1063 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1064 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1069 _PTR(Study) aStudy = appStudy->studyDS();
1071 aSel->selectedObjects( selected );
1073 if(selected.Extent() >= 1){
1074 switch(theCommandID){
1076 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1077 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1081 QColor c, e, b, n, c0D, o, outl, selection, preselection;
1085 vtkFloatingPointType Shrink = 0.0;
1086 vtkFloatingPointType faces_orientation_scale = 0.0;
1087 bool faces_orientation_3dvectors = false;
1089 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1090 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1091 int aMarkerTextureCurrent = 0;
1093 SALOME_ListIteratorOfListIO It( selected );
1094 for( ; It.More(); It.Next()){
1095 Handle(SALOME_InteractiveObject) IObject = It.Value();
1096 if(IObject->hasEntry()){
1097 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1098 vtkFloatingPointType color[3];
1099 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1100 int c0 = int (color[0] * 255);
1101 int c1 = int (color[1] * 255);
1102 int c2 = int (color[2] * 255);
1103 c.setRgb(c0, c1, c2);
1105 vtkFloatingPointType edgecolor[3];
1106 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1107 c0 = int (edgecolor[0] * 255);
1108 c1 = int (edgecolor[1] * 255);
1109 c2 = int (edgecolor[2] * 255);
1110 e.setRgb(c0, c1, c2);
1112 vtkFloatingPointType nodecolor[3];
1113 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1114 c0 = int (nodecolor[0] * 255);
1115 c1 = int (nodecolor[1] * 255);
1116 c2 = int (nodecolor[2] * 255);
1117 n.setRgb(c0, c1, c2);
1119 vtkFloatingPointType color0D[3];
1120 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1121 c0 = int (color0D[0] * 255);
1122 c1 = int (color0D[1] * 255);
1123 c2 = int (color0D[2] * 255);
1124 c0D.setRgb(c0, c1, c2);
1126 vtkFloatingPointType outlineColor[3];
1127 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1128 c0 = int (outlineColor[0] * 255);
1129 c1 = int (outlineColor[1] * 255);
1130 c2 = int (outlineColor[2] * 255);
1131 outl.setRgb(c0, c1, c2);
1133 vtkFloatingPointType hColor[3];
1134 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1135 c0 = int (hColor[0] * 255);
1136 c1 = int (hColor[1] * 255);
1137 c2 = int (hColor[2] * 255);
1138 selection.setRgb(c0, c1, c2);
1140 vtkFloatingPointType phColor[3];
1141 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1142 c0 = int (phColor[0] * 255);
1143 c1 = int (phColor[1] * 255);
1144 c2 = int (phColor[2] * 255);
1145 preselection.setRgb(c0, c1, c2);
1147 size0D = (int)anActor->Get0DSize();
1150 Edgewidth = (int)anActor->GetLineWidth();
1153 Shrink = anActor->GetShrinkFactor();
1155 vtkFloatingPointType faces_orientation_color[3];
1156 anActor->GetFacesOrientationColor(faces_orientation_color);
1157 c0 = int (faces_orientation_color[0] * 255);
1158 c1 = int (faces_orientation_color[1] * 255);
1159 c2 = int (faces_orientation_color[2] * 255);
1160 o.setRgb(c0, c1, c2);
1162 faces_orientation_scale = anActor->GetFacesOrientationScale();
1163 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1165 aMarkerTypeCurrent = anActor->GetMarkerType();
1166 aMarkerScaleCurrent = anActor->GetMarkerScale();
1167 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1169 // even if there are multiple objects in the selection,
1170 // we need only the first one to get values for the dialog
1176 SMESHGUI_Preferences_ColorDlg *aDlg =
1177 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1178 aDlg->SetColor(1, c);
1179 aDlg->SetColor(2, e);
1180 aDlg->SetColor(3, n);
1181 aDlg->SetColor(4, outl);
1182 aDlg->SetDeltaBrightness(delta);
1183 aDlg->SetColor(5, c0D);
1184 aDlg->SetColor(6, o);
1185 aDlg->SetIntValue(1, Edgewidth);
1186 aDlg->SetIntValue(2, int(Shrink*100.));
1187 aDlg->SetIntValue(3, size0D);
1188 aDlg->SetDoubleValue(1, faces_orientation_scale);
1189 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1190 aDlg->SetColor(7, selection);
1191 aDlg->SetColor(8, preselection);
1193 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1195 if( aMarkerTypeCurrent != VTK::MT_USER )
1196 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1198 aDlg->setCustomMarker( aMarkerTextureCurrent );
1201 QColor color = aDlg->GetColor(1);
1202 QColor edgecolor = aDlg->GetColor(2);
1203 QColor nodecolor = aDlg->GetColor(3);
1204 QColor outlinecolor = aDlg->GetColor(4);
1205 QColor color0D = aDlg->GetColor(5);
1206 QColor faces_orientation_color = aDlg->GetColor(6);
1207 QColor selectioncolor = aDlg->GetColor(7);
1208 QColor preSelectioncolor = aDlg->GetColor(8);
1209 int delta = aDlg->GetDeltaBrightness();
1212 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1214 SALOME_ListIteratorOfListIO It( selected );
1215 for( ; It.More(); It.Next()){
1216 Handle(SALOME_InteractiveObject) IObject = It.Value();
1217 if(IObject->hasEntry()){
1218 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1219 /* actor color and backface color */
1220 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1221 vtkFloatingPointType (color.green()) / 255.,
1222 vtkFloatingPointType (color.blue()) / 255.,
1225 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1226 vtkFloatingPointType (edgecolor.green()) / 255.,
1227 vtkFloatingPointType (edgecolor.blue()) / 255.);
1229 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1230 vtkFloatingPointType (outlinecolor.green()) / 255.,
1231 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1234 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1235 vtkFloatingPointType (selectioncolor.green()) / 255.,
1236 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1238 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1239 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1240 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1243 /* Shrink factor and size edges */
1244 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1245 anActor->SetLineWidth(aDlg->GetIntValue(1));
1247 /* Nodes color and size */
1248 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1249 vtkFloatingPointType (nodecolor.green()) / 255.,
1250 vtkFloatingPointType (nodecolor.blue()) / 255.);
1253 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1254 vtkFloatingPointType (color0D.green()) / 255.,
1255 vtkFloatingPointType (color0D.blue()) / 255.);
1256 anActor->Set0DSize(aDlg->GetIntValue(3));
1258 /* Faces orientation */
1259 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1260 vtkFloatingPointType(faces_orientation_color.greenF()),
1261 vtkFloatingPointType(faces_orientation_color.blueF())};
1262 anActor->SetFacesOrientationColor(c);
1263 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1264 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1266 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1267 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1268 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1269 if( aMarkerTypeNew != VTK::MT_USER )
1270 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1272 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1273 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1274 if( anIter != aMarkerMap.end() )
1275 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1278 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1279 if( !aGroupObject->_is_nil() )
1281 SMESH::ElementType anElementType = aGroupObject->GetType();
1283 switch( anElementType )
1285 case SMESH::NODE: aColor = nodecolor; break;
1286 case SMESH::EDGE: aColor = edgecolor; break;
1287 default: aColor = color; break;
1290 SALOMEDS::Color aGroupColor;
1291 aGroupColor.R = (float)aColor.red() / 255.0;
1292 aGroupColor.G = (float)aColor.green() / 255.0;
1293 aGroupColor.B = (float)aColor.blue() / 255.0;
1294 aGroupObject->SetColor( aGroupColor );
1299 SMESH::RepaintCurrentView();
1305 SALOME_ListIteratorOfListIO It( selected );
1306 for( ; It.More(); It.Next()){
1307 Handle(SALOME_InteractiveObject) IObject = It.Value();
1308 if(IObject->hasEntry()){
1309 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1310 switch(theCommandID){
1312 anActor->SetRepresentation(SMESH_Actor::eEdge);
1315 anActor->SetRepresentation(SMESH_Actor::eSurface);
1318 if(anActor->IsShrunk())
1319 anActor->UnShrink();
1321 anActor->SetShrink();
1324 anActor->SetRepresentation(SMESH_Actor::ePoint);
1327 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1328 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1331 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1332 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1338 SMESH::RepaintCurrentView();
1342 void Control( int theCommandID )
1344 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1345 SALOME_ListIO selected;
1347 aSel->selectedObjects( selected );
1349 if( !selected.IsEmpty() ){
1350 Handle(SALOME_InteractiveObject) anIO = selected.First();
1352 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1353 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1354 switch ( theCommandID ){
1356 aControl = SMESH_Actor::eLength;
1359 aControl = SMESH_Actor::eLength2D;
1362 aControl = SMESH_Actor::eFreeEdges;
1365 aControl = SMESH_Actor::eFreeBorders;
1368 aControl = SMESH_Actor::eMultiConnection;
1371 aControl = SMESH_Actor::eFreeNodes;
1374 aControl = SMESH_Actor::eMultiConnection2D;
1377 aControl = SMESH_Actor::eArea;
1380 aControl = SMESH_Actor::eTaper;
1383 aControl = SMESH_Actor::eAspectRatio;
1386 aControl = SMESH_Actor::eAspectRatio3D;
1389 aControl = SMESH_Actor::eMinimumAngle;
1392 aControl = SMESH_Actor::eWarping;
1395 aControl = SMESH_Actor::eSkew;
1398 aControl = SMESH_Actor::eVolume3D;
1401 aControl = SMESH_Actor::eFreeFaces;
1404 aControl = SMESH_Actor::eMaxElementLength2D;
1407 aControl = SMESH_Actor::eMaxElementLength3D;
1410 aControl = SMESH_Actor::eBareBorderVolume;
1413 aControl = SMESH_Actor::eBareBorderFace;
1416 aControl = SMESH_Actor::eOverConstrainedVolume;
1419 aControl = SMESH_Actor::eOverConstrainedFace;
1422 aControl = SMESH_Actor::eCoincidentNodes;
1425 aControl = SMESH_Actor::eCoincidentElems1D;
1428 aControl = SMESH_Actor:: eCoincidentElems2D;
1431 aControl = SMESH_Actor::eCoincidentElems3D;
1435 anActor->SetControlMode(aControl);
1436 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1437 SMESH::RepaintCurrentView();
1438 #ifndef DISABLE_PLOT2DVIEWER
1439 if(anActor->GetPlot2Histogram()) {
1440 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1441 QString functorName = functorToString( anActor->GetFunctor());
1442 QString aHistogramName("%1 : %2");
1443 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1444 aHistogram->setName(aHistogramName);
1445 aHistogram->setHorTitle(functorName);
1446 SMESH::ProcessIn2DViewers(anActor);
1455 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1456 MeshObjectType theType,
1457 const QString theInTypeName,
1458 QString & theOutTypeName)
1460 SMESH_TypeFilter aTypeFilter( theType );
1462 if( !theIO.IsNull() )
1464 entry = theIO->getEntry();
1465 LightApp_DataOwner owner( entry );
1466 if ( aTypeFilter.isOk( &owner )) {
1467 theOutTypeName = theInTypeName;
1475 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1477 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1478 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1480 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1481 CORBA::String_var anID = aSComp->GetID().c_str();
1482 if (!strcmp(anID.in(),theIO->getEntry()))
1488 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1489 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1490 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1491 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1492 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1500 QString CheckHomogeneousSelection()
1502 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1503 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1504 SALOME_ListIO selected;
1506 aSel->selectedObjects( selected );
1508 QString RefType = CheckTypeObject(selected.First());
1509 SALOME_ListIteratorOfListIO It(selected);
1510 for ( ; It.More(); It.Next())
1512 Handle(SALOME_InteractiveObject) IObject = It.Value();
1513 QString Type = CheckTypeObject(IObject);
1514 if (Type.compare(RefType) != 0)
1515 return "Heterogeneous Selection";
1522 void SMESHGUI::OnEditDelete()
1524 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1525 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1526 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1528 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1529 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1530 _PTR(GenericAttribute) anAttr;
1531 _PTR(AttributeIOR) anIOR;
1533 int objectCount = 0;
1535 QString aParentComponent = QString::null;
1536 Handle(SALOME_InteractiveObject) anIO;
1537 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1539 anIO = anIt.Value();
1540 QString cur = anIO->getComponentDataType();
1541 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1543 // check if object is reference
1544 _PTR(SObject) aRefSObj;
1545 aNameList.append("\n - ");
1546 if ( aSO->ReferencedObject( aRefSObj ) ) {
1547 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1548 aNameList.append( aRefName );
1549 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1552 aNameList.append(anIO->getName());
1556 if( aParentComponent.isNull() )
1557 aParentComponent = cur;
1558 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1559 aParentComponent = "";
1562 if ( objectCount == 0 )
1563 return; // No Valid Objects Selected
1565 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1566 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1567 QObject::tr("ERR_ERROR"),
1568 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1571 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1572 if (SUIT_MessageBox::warning
1573 (SMESHGUI::desktop(),
1574 QObject::tr("SMESH_WRN_WARNING"),
1575 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1576 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1577 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1580 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1582 SALOME_ListIteratorOfListIO It(selected);
1584 aStudyBuilder->NewCommand(); // There is a transaction
1585 for( ; It.More(); It.Next()){ // loop on selected IO's
1586 Handle(SALOME_InteractiveObject) IObject = It.Value();
1587 if(IObject->hasEntry()) {
1588 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1590 // disable removal of "SMESH" component object
1591 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1593 if ( engineIOR() == anIOR->Value().c_str() )
1596 //Check the referenced object
1597 _PTR(SObject) aRefSObject;
1598 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1599 aSO = aRefSObject; // Delete main Object instead of reference
1601 // put the whole hierarchy of sub-objects of the selected SO into a list and
1602 // then treat them all starting from the deepest objects (at list back)
1604 std::list< _PTR(SObject) > listSO;
1605 listSO.push_back( aSO );
1606 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1607 for ( ; itSO != listSO.end(); ++itSO ) {
1608 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1609 for (it->InitEx(false); it->More(); it->Next())
1610 listSO.push_back( it->Value() );
1613 // treat SO's in the list starting from the back
1615 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1616 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1617 _PTR(SObject) SO = *ritSO;
1618 if ( !SO ) continue;
1619 std::string anEntry = SO->GetID();
1621 /** Erase graphical object **/
1622 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1623 ViewManagerList aViewMenegers = anApp->viewManagers();
1624 ViewManagerList::const_iterator it = aViewMenegers.begin();
1625 for( ; it != aViewMenegers.end(); it++) {
1626 SUIT_ViewManager* vm = *it;
1627 int nbSf = vm ? vm->getViewsCount() : 0;
1629 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1630 for(int i = 0; i < nbSf; i++){
1631 SUIT_ViewWindow *sf = aViews[i];
1632 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1633 SMESH::RemoveActor(sf,anActor);
1639 /** Remove an object from data structures **/
1640 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1641 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1642 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1643 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1644 aMesh->RemoveGroup( aGroup );
1646 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1647 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1648 aMesh->RemoveSubMesh( aSubMesh );
1650 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1652 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1655 IObject = new SALOME_InteractiveObject
1656 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1657 QString objType = CheckTypeObject(IObject);
1658 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1659 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1660 aStudyBuilder->RemoveObjectWithChildren( SO );
1662 else {// default action: remove SObject from the study
1663 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1664 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1666 aStudyBuilder->RemoveObjectWithChildren( SO );
1670 } /* listSO back loop */
1671 } /* IObject->hasEntry() */
1674 aStudyBuilder->CommitCommand();
1676 /* Clear any previous selection */
1678 aSel->setSelectedObjects( l1 );
1680 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1685 SMESHGUI_EXPORT CAM_Module* createModule()
1687 return new SMESHGUI();
1690 SMESHGUI_EXPORT char* getModuleVersion() {
1691 return (char*)SMESH_VERSION_STR;
1695 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1697 //=============================================================================
1701 //=============================================================================
1702 SMESHGUI::SMESHGUI() :
1703 SalomeApp_Module( "SMESH" ),
1704 LightApp_Module( "SMESH" )
1706 if ( CORBA::is_nil( myComponentSMESH ) )
1708 CORBA::Boolean anIsEmbeddedMode;
1709 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1710 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1712 // 0019923: EDF 765 SMESH : default values of hypothesis
1713 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1714 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1715 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1716 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1717 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1719 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1720 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1721 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1723 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1724 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1728 myActiveDialogBox = 0;
1729 myFilterLibraryDlg = 0;
1733 myEventCallbackCommand = vtkCallbackCommand::New();
1734 myEventCallbackCommand->Delete();
1735 myEventCallbackCommand->SetClientData( this );
1736 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1739 SMESH::GetFilterManager();
1740 SMESH::GetPattern();
1741 SMESH::GetMeasurements();
1743 /* load resources for all available meshers */
1744 SMESH::InitAvailableHypotheses();
1747 //=============================================================================
1751 //=============================================================================
1752 SMESHGUI::~SMESHGUI()
1754 #ifdef WITHGENERICOBJ
1755 SMESH::GetFilterManager()->UnRegister();
1756 SMESH::GetMeasurements()->UnRegister();
1758 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1759 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1762 //=============================================================================
1766 //=============================================================================
1767 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1769 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1771 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1776 //=============================================================================
1780 //=============================================================================
1781 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1783 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1787 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1788 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1789 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1790 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1791 return autoUpdate && !exceeded;
1794 //=============================================================================
1798 //=============================================================================
1799 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1801 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1804 //=============================================================================
1808 //=============================================================================
1809 SMESHGUI* SMESHGUI::GetSMESHGUI()
1811 SMESHGUI* smeshMod = 0;
1812 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1815 CAM_Module* module = app->module( "Mesh" );
1816 smeshMod = dynamic_cast<SMESHGUI*>( module );
1819 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1821 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1824 _PTR(Study) aStudy = study->studyDS();
1826 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1835 Standard_EXPORT SMESHGUI* GetComponentGUI()
1837 return SMESHGUI::GetSMESHGUI();
1841 //=============================================================================
1845 //=============================================================================
1846 void SMESHGUI::SetState(int aState)
1851 //=============================================================================
1855 //=============================================================================
1856 void SMESHGUI::ResetState()
1861 //=============================================================================
1865 //=============================================================================
1866 void SMESHGUI::EmitSignalDeactivateDialog()
1868 emit SignalDeactivateActiveDialog();
1871 //=============================================================================
1875 //=============================================================================
1876 void SMESHGUI::EmitSignalStudyFrameChanged()
1878 emit SignalStudyFrameChanged();
1881 //=============================================================================
1885 //=============================================================================
1886 void SMESHGUI::EmitSignalCloseAllDialogs()
1888 emit SignalCloseAllDialogs();
1891 //=============================================================================
1895 //=============================================================================
1896 void SMESHGUI::EmitSignalVisibilityChanged()
1898 emit SignalVisibilityChanged();
1901 //=============================================================================
1905 //=============================================================================
1906 QDialog *SMESHGUI::GetActiveDialogBox()
1908 return myActiveDialogBox;
1911 //=============================================================================
1915 //=============================================================================
1916 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1918 myActiveDialogBox = (QDialog *) aDlg;
1922 //=============================================================================
1926 //=============================================================================
1927 SUIT_Desktop* SMESHGUI::desktop()
1929 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1931 return app->desktop();
1936 //=============================================================================
1940 //=============================================================================
1941 SalomeApp_Study* SMESHGUI::activeStudy()
1943 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1945 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1950 //=============================================================================
1954 //=============================================================================
1955 void SMESHGUI::Modified( bool theIsUpdateActions )
1957 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1958 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1959 appStudy->Modified();
1960 if( theIsUpdateActions )
1961 app->updateActions();
1966 //=============================================================================
1970 //=============================================================================
1971 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1973 /* Here the position is on the bottom right corner - 10 */
1974 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1976 SUIT_Desktop *PP = desktop();
1977 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1978 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1982 //=============================================================================
1986 //=============================================================================
1987 static int isStudyLocked(_PTR(Study) theStudy){
1988 return theStudy->GetProperties()->IsLocked();
1991 static bool checkLock(_PTR(Study) theStudy) {
1992 if (isStudyLocked(theStudy)) {
1993 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1994 QObject::tr("WRN_WARNING"),
1995 QObject::tr("WRN_STUDY_LOCKED") );
2001 //=======================================================================
2002 //function : CheckActiveStudyLocked
2004 //=======================================================================
2006 bool SMESHGUI::isActiveStudyLocked()
2008 _PTR(Study) aStudy = activeStudy()->studyDS();
2009 return checkLock( aStudy );
2012 //=============================================================================
2016 //=============================================================================
2017 bool SMESHGUI::OnGUIEvent( int theCommandID )
2019 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2023 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2024 SUIT_ResourceMgr* mgr = resourceMgr();
2028 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2029 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2032 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2033 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2035 //QAction* act = action( theCommandID );
2037 switch (theCommandID) {
2039 if(checkLock(aStudy)) break;
2050 if(checkLock(aStudy)) break;
2051 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2055 case 150: //MED FILE INFORMATION
2057 SALOME_ListIO selected;
2058 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2060 aSel->selectedObjects( selected );
2061 if( selected.Extent() )
2063 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2064 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2065 if ( !aMesh->_is_nil() )
2067 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2074 case 122: // EXPORT MED
2087 ::ExportMeshToFile(theCommandID);
2091 case 200: // SCALAR BAR
2093 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2094 SALOME_ListIO selected;
2096 aSel->selectedObjects( selected );
2098 if( selected.Extent() ) {
2099 Handle(SALOME_InteractiveObject) anIO = selected.First();
2100 if( anIO->hasEntry() ) {
2101 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2102 anActor->SetControlMode( SMESH_Actor::eNone );
2103 #ifndef DISABLE_PLOT2DVIEWER
2104 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2113 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2118 // dump control distribution data to the text file
2119 ::SaveDistribution();
2125 // show/ distribution
2126 ::ShowDistribution();
2130 #ifndef DISABLE_PLOT2DVIEWER
2133 // plot distribution
2134 ::PlotDistribution();
2145 ::DisableAutoColor();
2148 case 1134: // Clipping
2149 case 1133: // Tranparency
2150 case 1132: // Display preferences (colors, shrink size, line width, ...)
2157 ::SetDisplayMode(theCommandID, myMarkerMap);
2160 //2D quadratic representation
2163 ::SetDisplayMode(theCommandID, myMarkerMap);
2167 case 216: // 0D elements
2170 case 219: // Volumes
2171 case 220: // All Entity
2172 ::SetDisplayEntity(theCommandID);
2175 case 221: // Orientation of faces
2177 LightApp_SelectionMgr* mgr = selectionMgr();
2178 SALOME_ListIO selected; mgr->selectedObjects( selected );
2180 SALOME_ListIteratorOfListIO it(selected);
2181 for( ; it.More(); it.Next()) {
2182 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2183 if(anIObject->hasEntry()) {
2184 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2185 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2194 if(checkLock(aStudy)) break;
2196 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2199 SMESH::UpdateView();
2201 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2202 SMESH::OnVisuException();
2204 catch (...) { // PAL16774 (Crash after display of many groups)
2205 SMESH::OnVisuException();
2209 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2210 aSel->selectedObjects( l );
2211 aSel->setSelectedObjects( l );
2216 case 301: // DISPLAY
2217 case 302: // DISPLAY ONLY
2219 SMESH::EDisplaing anAction;
2220 switch (theCommandID) {
2221 case 300: anAction = SMESH::eErase; break;
2222 case 301: anAction = SMESH::eDisplay; break;
2223 case 302: anAction = SMESH::eDisplayOnly; break;
2226 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2227 SALOME_ListIO sel_objects, to_process;
2229 aSel->selectedObjects( sel_objects );
2231 if( theCommandID==302 )
2233 MESSAGE("anAction = SMESH::eDisplayOnly");
2234 startOperation( myEraseAll );
2237 extractContainers( sel_objects, to_process );
2240 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2244 SALOME_ListIteratorOfListIO It( to_process );
2245 for ( ; It.More(); It.Next()) {
2247 Handle(SALOME_InteractiveObject) IOS = It.Value();
2248 if (IOS->hasEntry()) {
2250 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2251 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2252 break; // PAL16774 (Crash after display of many groups)
2254 if (anAction == SMESH::eDisplayOnly)
2256 MESSAGE("anAction = SMESH::eDisplayOnly");
2257 anAction = SMESH::eDisplay;
2263 // PAL13338 + PAL15161 -->
2264 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2265 MESSAGE("anAction = SMESH::eDisplayOnly");
2266 SMESH::UpdateView();
2267 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2269 // PAL13338 + PAL15161 <--
2271 catch (...) { // PAL16774 (Crash after display of many groups)
2272 SMESH::OnVisuException();
2275 if (anAction == SMESH::eErase) {
2276 MESSAGE("anAction == SMESH::eErase");
2278 aSel->setSelectedObjects( l1 );
2281 aSel->setSelectedObjects( to_process );
2288 if(checkLock(aStudy)) break;
2291 EmitSignalDeactivateDialog();
2293 ( new SMESHGUI_NodesDlg( this ) )->show();
2296 SUIT_MessageBox::warning(desktop(),
2297 tr("SMESH_WRN_WARNING"),
2298 tr("SMESH_WRN_VIEWER_VTK"));
2303 case 2151: // FILTER
2307 EmitSignalDeactivateDialog();
2308 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2313 case 701: // COMPUTE MESH
2314 case 711: // PRECOMPUTE MESH
2315 case 712: // EVALUATE MESH
2316 case 713: // MESH ORDER
2318 if (checkLock(aStudy)) break;
2319 startOperation( theCommandID );
2323 case 702: // Create mesh
2324 case 703: // Create sub-mesh
2325 case 704: // Edit mesh/sub-mesh
2326 startOperation( theCommandID );
2328 case 705: // copy mesh
2330 if (checkLock(aStudy)) break;
2331 EmitSignalDeactivateDialog();
2332 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2335 case 710: // Build compound mesh
2337 if (checkLock(aStudy)) break;
2338 EmitSignalDeactivateDialog();
2339 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2343 case 407: // DIAGONAL INVERSION
2344 case 408: // Delete diagonal
2348 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2349 tr( "NOT_A_VTK_VIEWER" ) );
2353 if ( checkLock( aStudy ) )
2356 /*Standard_Boolean aRes;
2357 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2358 if ( aMesh->_is_nil() )
2360 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2361 tr( "SMESH_BAD_SELECTION" ) );
2365 EmitSignalDeactivateDialog();
2366 if ( theCommandID == 407 )
2367 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2369 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2372 case 409: // Change orientation
2373 case 410: // Union of triangles
2374 case 411: // Cutting of quadrangles
2375 case 419: // Splitting volumes into tetrahedra
2379 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2380 tr( "NOT_A_VTK_VIEWER" ) );
2384 if ( checkLock( aStudy ) )
2387 EmitSignalDeactivateDialog();
2388 SMESHGUI_MultiEditDlg* aDlg = NULL;
2389 if ( theCommandID == 409 )
2390 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2391 else if ( theCommandID == 410 )
2392 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2393 else if ( theCommandID == 419 )
2394 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2396 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2401 case 412: // Smoothing
2403 if(checkLock(aStudy)) break;
2405 EmitSignalDeactivateDialog();
2406 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2409 SUIT_MessageBox::warning(desktop(),
2410 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2414 case 413: // Extrusion
2416 if (checkLock(aStudy)) break;
2418 EmitSignalDeactivateDialog();
2419 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2421 SUIT_MessageBox::warning(desktop(),
2422 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2426 case 414: // Revolution
2428 if(checkLock(aStudy)) break;
2430 EmitSignalDeactivateDialog();
2431 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2434 SUIT_MessageBox::warning(desktop(),
2435 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2439 case 415: // Pattern mapping
2441 if ( checkLock( aStudy ) )
2445 EmitSignalDeactivateDialog();
2446 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2449 SUIT_MessageBox::warning(desktop(),
2450 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2454 case 416: // Extrusion along a path
2456 if (checkLock(aStudy)) break;
2458 EmitSignalDeactivateDialog();
2459 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2461 SUIT_MessageBox::warning(desktop(),
2462 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2466 case 417: // Convert mesh to quadratic
2468 startOperation( 417 );
2469 /* if (checkLock(aStudy)) break;
2471 EmitSignalDeactivateDialog();
2472 new SMESHGUI_ConvToQuadDlg();
2474 SUIT_MessageBox::warning(desktop(),
2475 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2479 case 418: // create 2D mesh from 3D
2481 startOperation( 418 );
2484 case 806: // CREATE GEO GROUP
2486 startOperation( 806 );
2489 case 801: // CREATE GROUP
2493 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2494 tr( "NOT_A_VTK_VIEWER" ) );
2498 if(checkLock(aStudy)) break;
2499 EmitSignalDeactivateDialog();
2500 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2502 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2503 SALOME_ListIO selected;
2505 aSel->selectedObjects( selected );
2507 int nbSel = selected.Extent();
2509 // check if mesh is selected
2510 aMesh = SMESH::GetMeshByIO( selected.First() );
2512 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2517 case 802: // CONSTRUCT GROUP
2521 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2522 tr( "NOT_A_VTK_VIEWER" ) );
2526 if(checkLock(aStudy)) break;
2527 EmitSignalDeactivateDialog();
2529 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2530 SALOME_ListIO selected;
2532 aSel->selectedObjects( selected );
2534 int nbSel = selected.Extent();
2536 // check if submesh is selected
2537 Handle(SALOME_InteractiveObject) IObject = selected.First();
2538 if (IObject->hasEntry()) {
2539 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2541 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2542 if (!aSubMesh->_is_nil()) {
2544 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2545 // get submesh elements list by types
2546 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2547 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2548 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2549 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2550 // create group for each type o elements
2551 QString aName = IObject->getName();
2552 QStringList anEntryList;
2553 if (aNodes->length() > 0) {
2554 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2555 aGroup->Add(aNodes.inout());
2556 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2557 anEntryList.append( aSObject->GetID().c_str() );
2559 if (aEdges->length() > 0) {
2560 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2561 aGroup->Add(aEdges.inout());
2562 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2563 anEntryList.append( aSObject->GetID().c_str() );
2565 if (aFaces->length() > 0) {
2566 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2567 aGroup->Add(aFaces.inout());
2568 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2569 anEntryList.append( aSObject->GetID().c_str() );
2571 if (aVolumes->length() > 0) {
2572 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2573 aGroup->Add(aVolumes.inout());
2574 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2575 anEntryList.append( aSObject->GetID().c_str() );
2578 anApp->browseObjects( anEntryList );
2580 catch(const SALOME::SALOME_Exception & S_ex){
2581 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2588 SUIT_MessageBox::warning(desktop(),
2589 tr("SMESH_WRN_WARNING"),
2590 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2595 case 803: // EDIT GROUP
2599 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2600 tr( "NOT_A_VTK_VIEWER" ) );
2604 if(checkLock(aStudy)) break;
2605 EmitSignalDeactivateDialog();
2607 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2608 SALOME_ListIO selected;
2610 aSel->selectedObjects( selected );
2612 SALOME_ListIteratorOfListIO It (selected);
2613 int nbSelectedGroups = 0;
2614 for ( ; It.More(); It.Next() )
2616 SMESH::SMESH_GroupBase_var aGroup =
2617 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2618 if (!aGroup->_is_nil()) {
2620 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2624 if (nbSelectedGroups == 0)
2626 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2632 case 804: // Add elements to group
2634 if(checkLock(aStudy)) break;
2635 if (myState == 800) {
2636 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2637 if (aDlg) aDlg->onAdd();
2642 case 805: // Remove elements from group
2644 if(checkLock(aStudy)) break;
2645 if (myState == 800) {
2646 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2647 if (aDlg) aDlg->onRemove();
2652 case 815: // Edit GEOM GROUP as standalone
2656 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2657 tr( "NOT_A_VTK_VIEWER" ) );
2661 if(checkLock(aStudy)) break;
2662 EmitSignalDeactivateDialog();
2664 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2665 SALOME_ListIO selected;
2667 aSel->selectedObjects( selected );
2669 SALOME_ListIteratorOfListIO It (selected);
2670 for ( ; It.More(); It.Next() )
2672 SMESH::SMESH_GroupOnGeom_var aGroup =
2673 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2674 if (!aGroup->_is_nil()) {
2675 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2680 SMESH::SMESH_GroupOnFilter_var aGroup =
2681 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2682 if (!aGroup->_is_nil()) {
2683 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2691 case 810: // Union Groups
2692 case 811: // Intersect groups
2693 case 812: // Cut groups
2697 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2698 tr( "NOT_A_VTK_VIEWER" ) );
2702 if ( checkLock( aStudy ) )
2705 EmitSignalDeactivateDialog();
2707 SMESHGUI_GroupOpDlg* aDlg = 0;
2708 if ( theCommandID == 810 )
2709 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2710 else if ( theCommandID == 811 )
2711 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2713 aDlg = new SMESHGUI_CutGroupsDlg( this );
2720 case 814: // Create groups of entities from existing groups of superior dimensions
2722 if ( checkLock( aStudy ) )
2725 EmitSignalDeactivateDialog();
2726 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2732 case 813: // Delete groups with their contents
2736 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2737 tr( "NOT_A_VTK_VIEWER" ) );
2741 if ( checkLock( aStudy ) )
2744 EmitSignalDeactivateDialog();
2746 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2750 case 900: // MESH INFOS
2751 case 903: // WHAT IS
2753 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2754 EmitSignalDeactivateDialog();
2755 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2756 SALOME_ListIO selected;
2758 aSel->selectedObjects( selected );
2760 if ( selected.Extent() > 1 ) { // a dlg for each IO
2761 SALOME_ListIteratorOfListIO It( selected );
2762 for ( ; It.More(); It.Next() ) {
2763 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2764 dlg->showInfo( It.Value() );
2769 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2775 case 904: // FIND ELEM
2777 startOperation( theCommandID );
2781 case 1100: // EDIT HYPOTHESIS
2783 if(checkLock(aStudy)) break;
2785 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2786 SALOME_ListIO selected;
2788 aSel->selectedObjects( selected );
2790 int nbSel = selected.Extent();
2793 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2794 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2796 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2797 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2798 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2799 if ( !aHypothesis->_is_nil() )
2802 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2803 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2805 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2815 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2817 if(checkLock(aStudy)) break;
2818 SUIT_OverrideCursor wc;
2820 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2821 SALOME_ListIO selected;
2823 aSel->selectedObjects( selected, QString::null, false );
2825 SALOME_ListIteratorOfListIO It(selected);
2826 for (int i = 0; It.More(); It.Next(), i++) {
2827 Handle(SALOME_InteractiveObject) IObject = It.Value();
2828 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2831 aSel->setSelectedObjects( l1 );
2836 case 4009: // ELEM0D
2838 case 4021: // TRIANGLE
2840 case 4023: // POLYGON
2844 case 4134: // PYRAMID
2845 case 4135: // OCTA12
2847 if(checkLock(aStudy)) break;
2849 EmitSignalDeactivateDialog();
2850 SMDSAbs_EntityType type = SMDSEntity_Edge;
2851 switch (theCommandID) {
2853 type = SMDSEntity_0D; break;
2855 type = SMDSEntity_Triangle; break;
2857 type = SMDSEntity_Quadrangle; break;
2859 type = SMDSEntity_Tetra; break;
2861 type = SMDSEntity_Polygon; break;
2863 type = SMDSEntity_Hexa; break;
2865 type = SMDSEntity_Penta; break;
2867 type = SMDSEntity_Pyramid; break;
2869 type = SMDSEntity_Hexagonal_Prism; break;
2872 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
2875 SUIT_MessageBox::warning(desktop(),
2876 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2880 case 4033: // POLYHEDRON
2882 if(checkLock(aStudy)) break;
2884 EmitSignalDeactivateDialog();
2885 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2888 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2889 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2893 case 4034: // QUADRATIC EDGE
2894 case 4035: // QUADRATIC TRIANGLE
2895 case 4036: // QUADRATIC QUADRANGLE
2896 case 4136: // BIQUADRATIC QUADRANGLE
2897 case 4037: // QUADRATIC TETRAHEDRON
2898 case 4038: // QUADRATIC PYRAMID
2899 case 4039: // QUADRATIC PENTAHEDRON
2900 case 4040: // QUADRATIC HEXAHEDRON
2901 case 4140: // TRIQUADRATIC HEXAHEDRON
2903 if(checkLock(aStudy)) break;
2905 EmitSignalDeactivateDialog();
2906 SMDSAbs_EntityType type;
2908 switch (theCommandID) {
2910 type = SMDSEntity_Quad_Edge; break;
2912 type = SMDSEntity_Quad_Triangle; break;
2914 type = SMDSEntity_Quad_Quadrangle; break;
2916 type = SMDSEntity_BiQuad_Quadrangle; break;
2918 type = SMDSEntity_Quad_Tetra; break;
2920 type = SMDSEntity_Quad_Pyramid; break;
2922 type = SMDSEntity_Quad_Penta; break;
2924 type = SMDSEntity_Quad_Hexa;
2926 type = SMDSEntity_TriQuad_Hexa;
2930 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2933 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2934 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2938 case 4041: // REMOVES NODES
2940 if(checkLock(aStudy)) break;
2942 EmitSignalDeactivateDialog();
2943 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2946 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2947 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2951 case 4042: // REMOVES ELEMENTS
2953 if(checkLock(aStudy)) break;
2955 EmitSignalDeactivateDialog();
2956 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2960 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2961 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2965 case 4043: { // CLEAR_MESH
2967 if(checkLock(aStudy)) break;
2969 SALOME_ListIO selected;
2970 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2971 aSel->selectedObjects( selected );
2973 SUIT_OverrideCursor wc;
2974 SALOME_ListIteratorOfListIO It (selected);
2975 for ( ; It.More(); It.Next() )
2977 Handle(SALOME_InteractiveObject) IOS = It.Value();
2978 SMESH::SMESH_Mesh_var aMesh =
2979 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2980 if ( aMesh->_is_nil()) continue;
2982 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2984 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2985 SMESH::ModifiedMesh( aMeshSObj, false, true);
2986 // hide groups and submeshes
2987 _PTR(ChildIterator) anIter =
2988 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2989 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2991 _PTR(SObject) so = anIter->Value();
2992 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2995 catch (const SALOME::SALOME_Exception& S_ex){
2997 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3001 SMESH::UpdateView();
3005 case 4044: // REMOVE ORPHAN NODES
3007 if(checkLock(aStudy)) break;
3008 SALOME_ListIO selected;
3009 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3010 aSel->selectedObjects( selected );
3011 if ( selected.Extent() == 1 ) {
3012 Handle(SALOME_InteractiveObject) anIO = selected.First();
3013 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3014 if ( !aMesh->_is_nil() ) {
3015 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3016 tr( "SMESH_WARNING" ),
3017 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3018 SUIT_MessageBox::Yes |
3019 SUIT_MessageBox::No,
3020 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3023 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3024 int removed = aMeshEditor->RemoveOrphanNodes();
3025 SUIT_MessageBox::information(SMESHGUI::desktop(),
3026 tr("SMESH_INFORMATION"),
3027 tr("NB_NODES_REMOVED").arg(removed));
3028 if ( removed > 0 ) {
3029 SMESH::UpdateView();
3030 SMESHGUI::Modified();
3033 catch (const SALOME::SALOME_Exception& S_ex) {
3034 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3043 case 4051: // RENUMBERING NODES
3045 if(checkLock(aStudy)) break;
3047 EmitSignalDeactivateDialog();
3048 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3052 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3053 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3057 case 4052: // RENUMBERING ELEMENTS
3059 if(checkLock(aStudy)) break;
3061 EmitSignalDeactivateDialog();
3062 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3066 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3067 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3071 case 4061: // TRANSLATION
3073 if(checkLock(aStudy)) break;
3075 EmitSignalDeactivateDialog();
3076 ( new SMESHGUI_TranslationDlg( this ) )->show();
3079 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3080 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3084 case 4062: // ROTATION
3086 if(checkLock(aStudy)) break;
3088 EmitSignalDeactivateDialog();
3089 ( new SMESHGUI_RotationDlg( this ) )->show();
3092 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3093 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3097 case 4063: // SYMMETRY
3099 if(checkLock(aStudy)) break;
3101 EmitSignalDeactivateDialog();
3102 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3105 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3106 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3110 case 4064: // SEWING
3112 if(checkLock(aStudy)) break;
3114 EmitSignalDeactivateDialog();
3115 ( new SMESHGUI_SewingDlg( this ) )->show();
3118 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3119 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3123 case 4065: // MERGE NODES
3125 if(checkLock(aStudy)) break;
3127 EmitSignalDeactivateDialog();
3128 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3131 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3132 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3136 case 4066: // MERGE EQUAL ELEMENTS
3138 if (checkLock(aStudy)) break;
3140 EmitSignalDeactivateDialog();
3141 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3143 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3144 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3149 case 4067: // MAKE MESH PASS THROUGH POINT
3150 startOperation( 4067 );
3155 if(checkLock(aStudy)) break;
3157 EmitSignalDeactivateDialog();
3158 ( new SMESHGUI_ScaleDlg( this ) )->show();
3161 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3162 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3167 case 4069: // DUPLICATE NODES
3169 if(checkLock(aStudy)) break;
3171 EmitSignalDeactivateDialog();
3172 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3175 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3176 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3181 case 5105: // Library of selection filters
3183 static QList<int> aTypes;
3184 if ( aTypes.isEmpty() )
3186 aTypes.append( SMESH::NODE );
3187 aTypes.append( SMESH::EDGE );
3188 aTypes.append( SMESH::FACE );
3189 aTypes.append( SMESH::VOLUME );
3191 if (!myFilterLibraryDlg)
3192 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3193 else if (myFilterLibraryDlg->isHidden())
3194 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3195 myFilterLibraryDlg->raise();
3199 case 6017: // CONTROLS
3227 LightApp_SelectionMgr* mgr = selectionMgr();
3228 SALOME_ListIO selected; mgr->selectedObjects( selected );
3230 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3231 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3233 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3234 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3235 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3236 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3237 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3238 ::Control( theCommandID );
3243 SUIT_MessageBox::warning(desktop(),
3244 tr( "SMESH_WRN_WARNING" ),
3245 tr( "SMESH_BAD_SELECTION" ) );
3249 SUIT_MessageBox::warning(desktop(),
3250 tr( "SMESH_WRN_WARNING" ),
3251 tr( "NOT_A_VTK_VIEWER" ) );
3256 LightApp_SelectionMgr* mgr = selectionMgr();
3257 SALOME_ListIO selected; mgr->selectedObjects( selected );
3259 SALOME_ListIteratorOfListIO it(selected);
3260 for( ; it.More(); it.Next()) {
3261 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3262 if(anIObject->hasEntry()) {
3263 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3264 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3272 LightApp_SelectionMgr* mgr = selectionMgr();
3273 SALOME_ListIO selected; mgr->selectedObjects( selected );
3275 SALOME_ListIteratorOfListIO it(selected);
3276 for( ; it.More(); it.Next()) {
3277 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3278 if(anIObject->hasEntry())
3279 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3280 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3288 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3289 EmitSignalDeactivateDialog();
3290 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3296 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3297 //updateObjBrowser();
3301 //=============================================================================
3305 //=============================================================================
3306 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3311 //=============================================================================
3315 //=============================================================================
3316 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3321 //=============================================================================
3325 //=============================================================================
3326 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3331 //=============================================================================
3332 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3333 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3335 //=============================================================================
3336 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3337 SUIT_ViewWindow* wnd )
3339 if(theIO->hasEntry()){
3340 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3341 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3345 //=======================================================================
3346 // function : createSMESHAction
3348 //=======================================================================
3349 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3350 const int key, const bool toggle, const QString& shortcutAction )
3353 QWidget* parent = application()->desktop();
3354 SUIT_ResourceMgr* resMgr = resourceMgr();
3356 if ( !icon_id.isEmpty() )
3357 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3359 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3360 if ( !pix.isNull() )
3361 icon = QIcon( pix );
3363 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3364 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3365 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3367 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3368 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3371 //=======================================================================
3372 // function : createPopupItem
3374 //=======================================================================
3375 void SMESHGUI::createPopupItem( const int id,
3376 const QString& clients,
3377 const QString& types,
3378 const QString& theRule,
3383 parentId = popupMgr()->actionId( action( pId ) );
3385 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3386 popupMgr()->insert( action( id ), parentId, 0 );
3388 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3389 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3390 QString rule = "(%1) and (%2) and (%3)";
3391 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3392 if( clients.isEmpty() )
3393 rule = rule.arg( QString( "true" ) );
3395 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3396 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3399 bool cont = myRules.contains( id );
3401 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3403 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3404 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3407 //=======================================================================
3408 // function : initialize
3410 //=======================================================================
3411 void SMESHGUI::initialize( CAM_Application* app )
3413 SalomeApp_Module::initialize( app );
3415 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3417 /* Automatic Update flag */
3418 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3420 // ----- create actions --------------
3422 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3423 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3424 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3425 createSMESHAction( 114, "NUM" );
3426 createSMESHAction( 115, "STL" );
3427 createSMESHAction( 116, "CGNS" );
3428 createSMESHAction( 117, "SAUV" );
3429 createSMESHAction( 121, "DAT" );
3430 createSMESHAction( 122, "MED" );
3431 createSMESHAction( 123, "UNV" );
3432 createSMESHAction( 140, "STL" );
3433 createSMESHAction( 142, "CGNS" );
3434 createSMESHAction( 144, "SAUV" );
3435 createSMESHAction( 124, "EXPORT_DAT" );
3436 createSMESHAction( 125, "EXPORT_MED" );
3437 createSMESHAction( 126, "EXPORT_UNV" );
3438 createSMESHAction( 141, "EXPORT_STL" );
3439 createSMESHAction( 143, "EXPORT_CGNS" );
3440 createSMESHAction( 145, "EXPORT_SAUV" );
3441 createSMESHAction( 150, "FILE_INFO" );
3442 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3443 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3444 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3445 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3446 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3447 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3448 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3449 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3450 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3451 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3452 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3453 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3454 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3455 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3456 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3457 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3458 createSMESHAction( 804, "ADD" );
3459 createSMESHAction( 805, "REMOVE" );
3460 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3461 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3462 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3463 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3464 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3465 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3466 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3467 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3468 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3469 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3470 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3471 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3472 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3473 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3474 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3475 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3476 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3477 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3478 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3479 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3480 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3481 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3482 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3483 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3484 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3485 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3486 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3487 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3488 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3489 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3490 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3491 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3492 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3493 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3494 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3495 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3496 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3497 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3498 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3499 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3500 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3501 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3502 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3503 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3504 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3505 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3506 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3507 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3508 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3509 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3510 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3511 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3512 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3513 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3514 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3515 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3516 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3517 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3518 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3519 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3520 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3521 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3522 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3523 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3524 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3525 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3526 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3527 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3528 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3529 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3530 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3531 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3532 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3533 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3534 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3535 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3536 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3537 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3538 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3539 createSMESHAction( 415, "MAP", "ICON_MAP" );
3540 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3541 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3542 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3543 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3544 createSMESHAction( 200, "RESET" );
3545 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3546 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3547 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3548 #ifndef DISABLE_PLOT2DVIEWER
3549 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3551 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3552 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3553 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3554 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3555 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3556 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3557 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3558 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3559 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3560 createSMESHAction( 220, "ALL" );
3561 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3563 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3564 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3566 createSMESHAction( 1100, "EDIT_HYPO" );
3567 createSMESHAction( 1102, "UNASSIGN" );
3568 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3569 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3570 createSMESHAction( 1131, "DISPMODE" );
3571 createSMESHAction( 1132, "COLORS" );
3572 createSMESHAction( 1133, "TRANSP" );
3573 createSMESHAction( 1134, "CLIP" );
3574 createSMESHAction( 1135, "DISP_ENT" );
3575 createSMESHAction( 1136, "AUTO_COLOR" );
3576 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3577 createSMESHAction( 2000, "CTRL" );
3579 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3580 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3582 createSMESHAction( 300, "ERASE" );
3583 createSMESHAction( 301, "DISPLAY" );
3584 createSMESHAction( 302, "DISPLAY_ONLY" );
3586 // ----- create menu --------------
3587 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3588 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3589 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3590 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3591 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3592 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3593 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3594 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3596 createMenu( separator(), fileId );
3598 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3599 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3600 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3601 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3602 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3603 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3604 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3605 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3606 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3607 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3609 createMenu( 111, importId, -1 );
3610 createMenu( 112, importId, -1 );
3611 createMenu( 113, importId, -1 );
3612 createMenu( 115, importId, -1 );
3614 createMenu( 116, importId, -1 );
3616 createMenu( 117, importId, -1 );
3617 createMenu( 121, exportId, -1 );
3618 createMenu( 122, exportId, -1 );
3619 createMenu( 123, exportId, -1 );
3620 createMenu( 140, exportId, -1 ); // export to STL
3622 createMenu( 142, exportId, -1 ); // export to CGNS
3624 createMenu( 144, exportId, -1 ); // export to SAUV
3625 createMenu( separator(), fileId, 10 );
3627 createMenu( 33, editId, -1 );
3629 createMenu( 5105, toolsId, -1 );
3631 createMenu( 702, meshId, -1 ); // "Mesh" menu
3632 createMenu( 703, meshId, -1 );
3633 createMenu( 704, meshId, -1 );
3634 createMenu( 710, meshId, -1 );
3635 createMenu( 705, meshId, -1 );
3636 createMenu( separator(), meshId, -1 );
3637 createMenu( 701, meshId, -1 );
3638 createMenu( 711, meshId, -1 );
3639 createMenu( 712, meshId, -1 );
3640 createMenu( 713, meshId, -1 );
3641 createMenu( separator(), meshId, -1 );
3642 createMenu( 801, meshId, -1 );
3643 createMenu( 806, meshId, -1 );
3644 createMenu( 802, meshId, -1 );
3645 createMenu( 803, meshId, -1 );
3646 createMenu( 815, meshId, -1 );
3647 createMenu( separator(), meshId, -1 );
3648 createMenu( 810, meshId, -1 );
3649 createMenu( 811, meshId, -1 );
3650 createMenu( 812, meshId, -1 );
3651 createMenu( separator(), meshId, -1 );
3652 createMenu( 814, meshId, -1 );
3653 createMenu( separator(), meshId, -1 );
3654 createMenu( 900, meshId, -1 );
3655 //createMenu( 902, meshId, -1 );
3656 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3657 createMenu( 904, meshId, -1 );
3658 createMenu( separator(), meshId, -1 );
3660 createMenu( 6005, nodeId, -1 );
3661 createMenu( 6028, nodeId, -1 );
3662 createMenu( 6002, edgeId, -1 );
3663 createMenu( 6003, edgeId, -1 );
3664 createMenu( 6001, edgeId, -1 );
3665 createMenu( 6004, edgeId, -1 );
3666 createMenu( 6029, edgeId, -1 );
3667 createMenu( 6021, faceId, -1 );
3668 createMenu( 6025, faceId, -1 );
3669 createMenu( 6027, faceId, -1 );
3670 createMenu( 6018, faceId, -1 );
3671 createMenu( 6019, faceId, -1 );
3672 createMenu( 6011, faceId, -1 );
3673 createMenu( 6012, faceId, -1 );
3674 createMenu( 6013, faceId, -1 );
3675 createMenu( 6014, faceId, -1 );
3676 createMenu( 6015, faceId, -1 );
3677 createMenu( 6016, faceId, -1 );
3678 createMenu( 6022, faceId, -1 );
3679 createMenu( 6030, faceId, -1 );
3680 createMenu( 6017, volumeId, -1 );
3681 createMenu( 6009, volumeId, -1 );
3682 createMenu( 6023, volumeId, -1 );
3683 createMenu( 6024, volumeId, -1 );
3684 createMenu( 6026, volumeId, -1 );
3685 createMenu( 6031, volumeId, -1 );
3687 createMenu( 4000, addId, -1 );
3688 createMenu( 4009, addId, -1 );
3689 createMenu( 4010, addId, -1 );
3690 createMenu( 4021, addId, -1 );
3691 createMenu( 4022, addId, -1 );
3692 createMenu( 4023, addId, -1 );
3693 createMenu( 4031, addId, -1 );
3694 createMenu( 4032, addId, -1 );
3695 createMenu( 4133, addId, -1 );
3696 createMenu( 4134, addId, -1 );
3697 createMenu( 4135, addId, -1 );
3698 createMenu( 4033, addId, -1 );
3699 createMenu( separator(), addId, -1 );
3700 createMenu( 4034, addId, -1 );
3701 createMenu( 4035, addId, -1 );
3702 createMenu( 4036, addId, -1 );
3703 createMenu( 4136, addId, -1 );
3704 createMenu( 4037, addId, -1 );
3705 createMenu( 4038, addId, -1 );
3706 createMenu( 4039, addId, -1 );
3707 createMenu( 4040, addId, -1 );
3708 createMenu( 4140, addId, -1 );
3710 createMenu( 4041, removeId, -1 );
3711 createMenu( 4042, removeId, -1 );
3712 createMenu( 4044, removeId, -1 );
3713 createMenu( separator(), removeId, -1 );
3714 createMenu( 813, removeId, -1 );
3715 createMenu( separator(), removeId, -1 );
3716 createMenu( 4043, removeId, -1 );
3718 createMenu( 4051, renumId, -1 );
3719 createMenu( 4052, renumId, -1 );
3721 createMenu( 4061, transfId, -1 );
3722 createMenu( 4062, transfId, -1 );
3723 createMenu( 4063, transfId, -1 );
3724 createMenu( 4068, transfId, -1 );
3725 createMenu( 4064, transfId, -1 );
3726 createMenu( 4065, transfId, -1 );
3727 createMenu( 4066, transfId, -1 );
3728 createMenu( 4069, transfId, -1 );
3730 createMenu( 4067,modifyId, -1 );
3731 createMenu( 407, modifyId, -1 );
3732 createMenu( 408, modifyId, -1 );
3733 createMenu( 409, modifyId, -1 );
3734 createMenu( 410, modifyId, -1 );
3735 createMenu( 411, modifyId, -1 );
3736 createMenu( 419, modifyId, -1 );
3737 createMenu( 412, modifyId, -1 );
3738 createMenu( 413, modifyId, -1 );
3739 createMenu( 416, modifyId, -1 );
3740 createMenu( 414, modifyId, -1 );
3741 createMenu( 415, modifyId, -1 );
3742 createMenu( 417, modifyId, -1 );
3743 createMenu( 418, modifyId, -1 );
3745 createMenu( 501, measureId, -1 );
3746 createMenu( 502, measureId, -1 );
3747 createMenu( 214, viewId, -1 );
3749 // ----- create toolbars --------------
3750 int meshTb = createTool( tr( "TB_MESH" ) ),
3751 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3752 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3753 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3754 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3756 createTool( 702, meshTb );
3757 createTool( 703, meshTb );
3758 createTool( 704, meshTb );
3759 createTool( 710, meshTb );
3760 createTool( 705, meshTb );
3761 createTool( separator(), meshTb );
3762 createTool( 701, meshTb );
3763 createTool( 711, meshTb );
3764 createTool( 712, meshTb );
3765 createTool( 713, meshTb );
3766 createTool( separator(), meshTb );
3767 createTool( 801, meshTb );
3768 createTool( 806, meshTb );
3769 createTool( 802, meshTb );
3770 createTool( 803, meshTb );
3771 //createTool( 815, meshTb );
3772 createTool( separator(), meshTb );
3773 createTool( 900, meshTb );
3774 //createTool( 902, meshTb );
3775 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3776 createTool( 904, meshTb );
3777 createTool( separator(), meshTb );
3779 createTool( 6005, ctrlTb );
3780 createTool( 6028, ctrlTb );
3781 createTool( separator(), ctrlTb );
3782 createTool( 6002, ctrlTb );
3783 createTool( 6003, ctrlTb );
3784 createTool( 6001, ctrlTb );
3785 createTool( 6004, ctrlTb );
3786 createTool( 6029, ctrlTb );
3787 createTool( separator(), ctrlTb );
3788 createTool( 6021, ctrlTb );
3789 createTool( 6025, ctrlTb );
3790 createTool( 6027, ctrlTb );
3791 createTool( 6018, ctrlTb );
3792 createTool( 6019, ctrlTb );
3793 createTool( 6011, ctrlTb );
3794 createTool( 6012, ctrlTb );
3795 createTool( 6013, ctrlTb );
3796 createTool( 6014, ctrlTb );
3797 createTool( 6015, ctrlTb );
3798 createTool( 6016, ctrlTb );
3799 createTool( 6022, ctrlTb );
3800 createTool( 6030, ctrlTb );
3801 createTool( separator(), ctrlTb );
3802 createTool( 6017, ctrlTb );
3803 createTool( 6009, ctrlTb );
3804 createTool( 6023, ctrlTb );
3805 createTool( 6024, ctrlTb );
3806 createTool( 6026, ctrlTb );
3807 createTool( 6031, ctrlTb );
3808 createTool( separator(), ctrlTb );
3810 createTool( 4000, addRemTb );
3811 createTool( 4009, addRemTb );
3812 createTool( 4010, addRemTb );
3813 createTool( 4021, addRemTb );
3814 createTool( 4022, addRemTb );
3815 createTool( 4023, addRemTb );
3816 createTool( 4031, addRemTb );
3817 createTool( 4032, addRemTb );
3818 createTool( 4133, addRemTb );
3819 createTool( 4134, addRemTb );
3820 createTool( 4135, addRemTb );
3821 createTool( 4033, addRemTb );
3822 createTool( separator(), addRemTb );
3823 createTool( 4034, addRemTb );
3824 createTool( 4035, addRemTb );
3825 createTool( 4036, addRemTb );
3826 createTool( 4136, addRemTb );
3827 createTool( 4037, addRemTb );
3828 createTool( 4038, addRemTb );
3829 createTool( 4039, addRemTb );
3830 createTool( 4040, addRemTb );
3831 createTool( 4140, addRemTb );
3832 createTool( separator(), addRemTb );
3833 createTool( 4041, addRemTb );
3834 createTool( 4042, addRemTb );
3835 createTool( 4044, addRemTb );
3836 createTool( 4043, addRemTb );
3837 createTool( separator(), addRemTb );
3838 createTool( 4051, addRemTb );
3839 createTool( 4052, addRemTb );
3840 createTool( separator(), addRemTb );
3841 createTool( 4061, addRemTb );
3842 createTool( 4062, addRemTb );
3843 createTool( 4063, addRemTb );
3844 createTool( 4068, addRemTb );
3845 createTool( 4064, addRemTb );
3846 createTool( 4065, addRemTb );
3847 createTool( 4066, addRemTb );
3848 createTool( 4069, addRemTb );
3849 createTool( separator(), addRemTb );
3851 createTool( 4067,modifyTb );
3852 createTool( 407, modifyTb );
3853 createTool( 408, modifyTb );
3854 createTool( 409, modifyTb );
3855 createTool( 410, modifyTb );
3856 createTool( 411, modifyTb );
3857 createTool( 419, modifyTb );
3858 createTool( 412, modifyTb );
3859 createTool( 413, modifyTb );
3860 createTool( 416, modifyTb );
3861 createTool( 414, modifyTb );
3862 createTool( 415, modifyTb );
3863 createTool( 417, modifyTb );
3864 createTool( 418, modifyTb );
3866 createTool( 214, dispModeTb );
3868 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3869 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3872 QString OB = "'ObjectBrowser'",
3873 View = "'" + SVTK_Viewer::Type() + "'",
3875 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3876 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3877 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3878 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3879 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3880 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3881 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3882 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3883 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3884 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3885 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3887 mesh_part = mesh + " " + subMesh + " " + group,
3888 mesh_group = mesh + " " + group,
3889 hyp_alg = hypo + " " + algo;
3891 // popup for object browser
3893 isInvisible("not( isVisible )"),
3894 isEmpty("numberOfNodes = 0"),
3895 isNotEmpty("numberOfNodes <> 0"),
3897 // has nodes, edges, etc in VISIBLE! actor
3898 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3899 hasElems("(count( elemTypes ) > 0)"),
3900 hasDifferentElems("(count( elemTypes ) > 1)"),
3901 hasElems0d("({'Elem0d'} in elemTypes)"),
3902 hasEdges("({'Edge'} in elemTypes)"),
3903 hasFaces("({'Face'} in elemTypes)"),
3904 hasVolumes("({'Volume'} in elemTypes)");
3906 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3907 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3908 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3909 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3910 createPopupItem( 803, OB, group ); // EDIT_GROUP
3911 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3913 popupMgr()->insert( separator(), -1, 0 );
3914 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3915 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3916 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3917 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3918 createPopupItem( 214, OB, mesh_part ); // UPDATE
3919 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3920 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3921 popupMgr()->insert( separator(), -1, 0 );
3922 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3923 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3924 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3925 popupMgr()->insert( separator(), -1, 0 );
3926 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3927 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3928 popupMgr()->insert( separator(), -1, 0 );
3929 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3930 popupMgr()->insert( separator(), -1, 0 );
3931 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3932 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3934 popupMgr()->insert( separator(), -1, 0 );
3936 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3937 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3938 QString only_one_2D = only_one_non_empty + " && dim>1";
3940 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3941 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3942 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3944 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3946 createPopupItem( 145, OB, mesh_group, multiple_non_empty ); // EXPORT_SAUV
3947 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3948 popupMgr()->insert( separator(), -1, 0 );
3951 createPopupItem( 803, View, group ); // EDIT_GROUP
3952 createPopupItem( 804, View, elems ); // ADD
3953 createPopupItem( 805, View, elems ); // REMOVE
3955 popupMgr()->insert( separator(), -1, 0 );
3956 createPopupItem( 214, View, mesh_part ); // UPDATE
3957 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3958 createPopupItem( 904, View, mesh ); // FIND_ELEM
3959 popupMgr()->insert( separator(), -1, 0 );
3961 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3962 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3963 popupMgr()->insert( separator(), -1, 0 );
3966 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3967 QString aType = QString( "%1type in {%2}" ).arg( lc );
3968 aType = aType.arg( mesh_part );
3969 QString aMeshInVTK = aClient + "&&" + aType;
3971 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3972 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3973 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3975 //-------------------------------------------------
3977 //-------------------------------------------------
3978 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3980 popupMgr()->insert( action( 9010 ), anId, -1 );
3981 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3982 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3984 popupMgr()->insert( action( 9011 ), anId, -1 );
3985 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3986 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3988 popupMgr()->insert( separator(), -1, -1 );
3990 //-------------------------------------------------
3992 //-------------------------------------------------
3993 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3995 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3996 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3997 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3999 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4000 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4001 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4003 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4004 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4005 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4007 popupMgr()->insert( separator(), anId, -1 );
4009 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4010 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4011 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4013 //-------------------------------------------------
4015 //-------------------------------------------------
4016 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4018 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4020 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4021 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4022 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4024 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4025 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4026 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4028 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4029 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4030 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4032 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4033 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4034 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4036 popupMgr()->insert( separator(), anId, -1 );
4038 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4039 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4042 //-------------------------------------------------
4043 // Representation of the 2D Quadratic elements
4044 //-------------------------------------------------
4045 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4046 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4047 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4048 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4050 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4051 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4052 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4054 //-------------------------------------------------
4055 // Orientation of faces
4056 //-------------------------------------------------
4057 popupMgr()->insert( action( 221 ), -1, -1 );
4058 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4059 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4061 //-------------------------------------------------
4063 //-------------------------------------------------
4064 popupMgr()->insert( action( 1132 ), -1, -1 );
4065 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4067 //-------------------------------------------------
4069 //-------------------------------------------------
4070 popupMgr()->insert( action( 1133 ), -1, -1 );
4071 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4073 //-------------------------------------------------
4075 //-------------------------------------------------
4077 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4078 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4079 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4080 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4082 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4084 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4085 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4087 popupMgr()->insert( separator(), anId, -1 );
4089 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4091 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4092 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4093 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4095 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4096 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4097 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4099 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4101 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4102 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4103 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4105 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4106 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4107 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4109 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4110 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4111 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4113 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4114 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4115 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4116 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4117 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4118 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4120 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4122 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4123 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4124 QtxPopupMgr::VisibleRule );
4125 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4127 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4128 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4129 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4131 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4132 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4133 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4135 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4136 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4137 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4139 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4140 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4141 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4143 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4144 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4145 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4147 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4148 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4149 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4151 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4152 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4153 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4155 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4156 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4157 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4159 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4160 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4161 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4163 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4164 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4165 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4167 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4168 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4169 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4170 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4171 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4172 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4174 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4176 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4177 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4178 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4180 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4181 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4182 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4184 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4185 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4186 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4188 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4189 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4190 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4192 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4193 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4194 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4196 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4197 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4198 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4200 popupMgr()->insert( separator(), anId, -1 );
4202 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4203 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4205 popupMgr()->insert( separator(), anId, -1 );
4207 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4209 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4210 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4212 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4213 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4214 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4216 #ifndef DISABLE_PLOT2DVIEWER
4217 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4218 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4221 //-------------------------------------------------
4223 //-------------------------------------------------
4224 popupMgr()->insert( separator(), -1, -1 );
4225 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4226 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4227 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4228 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4230 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4231 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4233 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4234 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4236 popupMgr()->insert( separator(), -1, -1 );
4238 //-------------------------------------------------
4240 //-------------------------------------------------
4241 popupMgr()->insert( action( 1134 ), -1, -1 );
4242 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4244 popupMgr()->insert( separator(), -1, -1 );
4246 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4247 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4249 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4250 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4253 //================================================================================
4255 * \brief Return true if SMESH or GEOM objects are selected.
4256 * Is called form LightApp_Module::activateModule() which clear selection if
4257 * not isSelectionCompatible()
4259 //================================================================================
4261 bool SMESHGUI::isSelectionCompatible()
4263 bool isCompatible = true;
4264 SALOME_ListIO selected;
4265 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4266 Sel->selectedObjects( selected );
4268 SALOME_ListIteratorOfListIO It( selected );
4269 for ( ; isCompatible && It.More(); It.Next())
4271 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4272 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4274 return isCompatible;
4278 bool SMESHGUI::reusableOperation( const int id )
4280 // compute, evaluate and precompute are not reusable operations
4281 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4284 bool SMESHGUI::activateModule( SUIT_Study* study )
4286 bool res = SalomeApp_Module::activateModule( study );
4288 setMenuShown( true );
4289 setToolShown( true );
4291 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4292 PyGILState_STATE gstate = PyGILState_Ensure();
4293 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4294 if(pluginsmanager==NULL)
4298 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4303 PyGILState_Release(gstate);
4304 // end of GEOM plugins loading
4306 // Reset actions accelerator keys
4307 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4308 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4309 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4311 action( 33)->setEnabled(true); // Delete: Key_Delete
4313 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4314 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4315 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4316 if ( _PTR(Study) aStudy = s->studyDS()) {
4317 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4318 updateObjBrowser(); // objects can be removed
4321 // get all view currently opened in the study and connect their signals to
4322 // the corresponding slots of the class.
4323 SUIT_Desktop* aDesk = study->application()->desktop();
4325 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4326 SUIT_ViewWindow* wnd;
4327 foreach ( wnd, wndList )
4334 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4336 setMenuShown( false );
4337 setToolShown( false );
4339 EmitSignalCloseAllDialogs();
4341 // Unset actions accelerator keys
4342 action(111)->setShortcut(QKeySequence()); // Import DAT
4343 action(112)->setShortcut(QKeySequence()); // Import UNV
4344 action(113)->setShortcut(QKeySequence()); // Import MED
4346 action( 33)->setEnabled(false); // Delete: Key_Delete
4348 return SalomeApp_Module::deactivateModule( study );
4351 void SMESHGUI::studyClosed( SUIT_Study* s )
4353 SMESH::RemoveVisuData( s->id() );
4354 SalomeApp_Module::studyClosed( s );
4357 void SMESHGUI::OnGUIEvent()
4359 const QObject* obj = sender();
4360 if ( !obj || !obj->inherits( "QAction" ) )
4362 int id = actionId((QAction*)obj);
4367 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4369 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4370 if ( CORBA::is_nil( myComponentSMESH ) )
4372 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4374 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4375 return aGUI.myComponentSMESH;
4378 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4379 return myComponentSMESH;
4382 QString SMESHGUI::engineIOR() const
4384 CORBA::ORB_var anORB = getApp()->orb();
4385 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4386 return QString( anIOR.in() );
4389 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4391 SalomeApp_Module::contextMenuPopup( client, menu, title );
4393 selectionMgr()->selectedObjects( lst );
4394 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4395 Handle(SALOME_InteractiveObject) io = lst.First();
4396 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4397 _PTR(Study) study = appStudy->studyDS();
4398 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4400 QString aName = QString( obj->GetName().c_str() );
4401 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4402 aName.remove( (aName.length() - 1), 1 );
4408 LightApp_Selection* SMESHGUI::createSelection() const
4410 return new SMESHGUI_Selection();
4413 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4415 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4416 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4419 void SMESHGUI::viewManagers( QStringList& list ) const
4421 list.append( SVTK_Viewer::Type() );
4424 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4426 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4427 SMESH::UpdateSelectionProp( this );
4429 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4430 for(int i = 0; i < aViews.count() ; i++){
4431 SUIT_ViewWindow *sf = aViews[i];
4437 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4439 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4440 myClippingPlaneInfoMap.erase( theViewManager );
4443 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4445 theActor->AddObserver( SMESH::DeleteActorEvent,
4446 myEventCallbackCommand.GetPointer(),
4450 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4451 unsigned long theEvent,
4452 void* theClientData,
4455 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4456 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4457 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4458 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4459 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4460 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4461 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4462 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4463 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4464 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4465 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4466 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4467 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4468 if( anActor == *anIter3 ) {
4469 anActorList.erase( anIter3 );
4480 void SMESHGUI::createPreferences()
4482 // General tab ------------------------------------------------------------------------
4483 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4485 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4486 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4487 setPreferenceProperty( lim, "min", 0 );
4488 setPreferenceProperty( lim, "max", 100000000 );
4489 setPreferenceProperty( lim, "step", 1000 );
4490 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4492 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4493 setPreferenceProperty( qaGroup, "columns", 2 );
4494 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4495 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4496 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4497 setPreferenceProperty( prec, "min", 0 );
4498 setPreferenceProperty( prec, "max", 16 );
4499 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4500 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4501 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4502 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4503 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4505 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4506 setPreferenceProperty( dispgroup, "columns", 2 );
4507 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4509 modes.append( tr("MEN_WIRE") );
4510 modes.append( tr("MEN_SHADE") );
4511 modes.append( tr("MEN_NODES") );
4512 modes.append( tr("MEN_SHRINK") );
4513 QList<QVariant> indices;
4514 indices.append( 0 );
4515 indices.append( 1 );
4516 indices.append( 2 );
4517 indices.append( 3 );
4518 setPreferenceProperty( dispmode, "strings", modes );
4519 setPreferenceProperty( dispmode, "indexes", indices );
4521 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4522 setPreferenceProperty( arcgroup, "columns", 2 );
4523 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4524 QStringList quadraticModes;
4525 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4526 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4528 indices.append( 0 );
4529 indices.append( 1 );
4530 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4531 setPreferenceProperty( quadraticmode, "indexes", indices );
4533 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4534 "SMESH", "max_angle" );
4535 setPreferenceProperty( maxAngle, "min", 1 );
4536 setPreferenceProperty( maxAngle, "max", 90 );
4540 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4541 setPreferenceProperty( exportgroup, "columns", 2 );
4542 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4543 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4545 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4546 setPreferenceProperty( computeGroup, "columns", 2 );
4547 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4549 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4550 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4551 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4553 indices.append( 0 );
4554 indices.append( 1 );
4555 indices.append( 2 );
4556 setPreferenceProperty( notifyMode, "strings", modes );
4557 setPreferenceProperty( notifyMode, "indexes", indices );
4559 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4560 setPreferenceProperty( infoGroup, "columns", 4 );
4561 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4563 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4564 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4566 indices.append( 0 );
4567 indices.append( 1 );
4568 setPreferenceProperty( elemInfo, "strings", modes );
4569 setPreferenceProperty( elemInfo, "indexes", indices );
4570 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4571 setPreferenceProperty( nodesLim, "min", 0 );
4572 setPreferenceProperty( nodesLim, "max", 10000000 );
4573 setPreferenceProperty( nodesLim, "step", 10000 );
4574 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4576 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4577 setPreferenceProperty( segGroup, "columns", 2 );
4578 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4579 "SMESH", "segmentation" );
4580 setPreferenceProperty( segLen, "min", 1 );
4581 setPreferenceProperty( segLen, "max", 10000000 );
4582 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4583 "SMESH", "nb_segments_per_edge" );
4584 setPreferenceProperty( nbSeg, "min", 1 );
4585 setPreferenceProperty( nbSeg, "max", 10000000 );
4587 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4588 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4589 "SMESH", "forget_mesh_on_hyp_modif" );
4592 // Quantities with individual precision settings
4593 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4594 setPreferenceProperty( precGroup, "columns", 2 );
4596 const int nbQuantities = 6;
4597 int precs[nbQuantities], ii = 0;
4598 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4599 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4600 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4601 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4602 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4603 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4604 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4605 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4606 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4607 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4608 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4609 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4611 // Set property for precision value for spinboxes
4612 for ( ii = 0; ii < nbQuantities; ii++ ){
4613 setPreferenceProperty( precs[ii], "min", -14 );
4614 setPreferenceProperty( precs[ii], "max", 14 );
4615 setPreferenceProperty( precs[ii], "precision", 2 );
4618 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4619 setPreferenceProperty( previewGroup, "columns", 2 );
4620 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4621 setPreferenceProperty( chunkSize, "min", 0 );
4622 setPreferenceProperty( chunkSize, "max", 1000 );
4623 setPreferenceProperty( chunkSize, "step", 50 );
4625 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4626 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4628 // Mesh tab ------------------------------------------------------------------------
4629 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4630 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4631 setPreferenceProperty( nodeGroup, "columns", 3 );
4633 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4635 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4637 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4638 QList<QVariant> aMarkerTypeIndicesList;
4639 QList<QVariant> aMarkerTypeIconsList;
4640 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4641 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4642 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4643 aMarkerTypeIndicesList << i;
4644 aMarkerTypeIconsList << pixmap;
4646 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4647 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4649 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4651 QList<QVariant> aMarkerScaleIndicesList;
4652 QStringList aMarkerScaleValuesList;
4653 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4654 aMarkerScaleIndicesList << i;
4655 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4657 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4658 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4660 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4661 setPreferenceProperty( elemGroup, "columns", 2 );
4663 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4664 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4666 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4667 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4669 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4671 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4672 setPreferenceProperty( grpGroup, "columns", 2 );
4674 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4676 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4677 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4678 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4679 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4680 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4681 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4683 setPreferenceProperty( size0d, "min", 1 );
4684 setPreferenceProperty( size0d, "max", 10 );
4686 setPreferenceProperty( elemW, "min", 1 );
4687 setPreferenceProperty( elemW, "max", 5 );
4689 setPreferenceProperty( shrink, "min", 0 );
4690 setPreferenceProperty( shrink, "max", 100 );
4692 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4693 setPreferenceProperty( orientGroup, "columns", 1 );
4695 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4696 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4698 setPreferenceProperty( orientScale, "min", 0.05 );
4699 setPreferenceProperty( orientScale, "max", 0.5 );
4700 setPreferenceProperty( orientScale, "step", 0.05 );
4702 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4704 // Selection tab ------------------------------------------------------------------------
4705 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4707 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4708 setPreferenceProperty( selGroup, "columns", 2 );
4710 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4711 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4713 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4714 setPreferenceProperty( preGroup, "columns", 2 );
4716 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4718 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4719 setPreferenceProperty( precSelGroup, "columns", 2 );
4721 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4722 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4723 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4725 // Scalar Bar tab ------------------------------------------------------------------------
4726 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4727 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4728 setPreferenceProperty( fontGr, "columns", 2 );
4730 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4731 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4733 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4734 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4736 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4737 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4739 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4740 setPreferenceProperty( numcol, "min", 2 );
4741 setPreferenceProperty( numcol, "max", 256 );
4743 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4744 setPreferenceProperty( numlab, "min", 2 );
4745 setPreferenceProperty( numlab, "max", 65 );
4747 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4748 setPreferenceProperty( orientGr, "columns", 2 );
4749 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4750 QStringList orients;
4751 orients.append( tr( "SMESH_VERTICAL" ) );
4752 orients.append( tr( "SMESH_HORIZONTAL" ) );
4753 indices.clear(); indices.append( 0 ); indices.append( 1 );
4754 setPreferenceProperty( orient, "strings", orients );
4755 setPreferenceProperty( orient, "indexes", indices );
4757 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4758 setPreferenceProperty( posVSizeGr, "columns", 2 );
4759 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4760 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4761 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4762 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4763 setPreferenceProperty( xv, "step", 0.1 );
4764 setPreferenceProperty( xv, "min", 0.0 );
4765 setPreferenceProperty( xv, "max", 1.0 );
4766 setPreferenceProperty( yv, "step", 0.1 );
4767 setPreferenceProperty( yv, "min", 0.0 );
4768 setPreferenceProperty( yv, "max", 1.0 );
4769 setPreferenceProperty( wv, "step", 0.1 );
4770 setPreferenceProperty( wv, "min", 0.0 );
4771 setPreferenceProperty( wv, "max", 1.0 );
4772 setPreferenceProperty( hv, "min", 0.0 );
4773 setPreferenceProperty( hv, "max", 1.0 );
4774 setPreferenceProperty( hv, "step", 0.1 );
4776 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4777 setPreferenceProperty( posHSizeGr, "columns", 2 );
4778 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4779 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4780 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4781 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4782 setPreferenceProperty( xv, "min", 0.0 );
4783 setPreferenceProperty( xv, "max", 1.0 );
4784 setPreferenceProperty( xv, "step", 0.1 );
4785 setPreferenceProperty( xh, "min", 0.0 );
4786 setPreferenceProperty( xh, "max", 1.0 );
4787 setPreferenceProperty( xh, "step", 0.1 );
4788 setPreferenceProperty( yh, "min", 0.0 );
4789 setPreferenceProperty( yh, "max", 1.0 );
4790 setPreferenceProperty( yh, "step", 0.1 );
4791 setPreferenceProperty( wh, "min", 0.0 );
4792 setPreferenceProperty( wh, "max", 1.0 );
4793 setPreferenceProperty( wh, "step", 0.1 );
4794 setPreferenceProperty( hh, "min", 0.0 );
4795 setPreferenceProperty( hh, "max", 1.0 );
4796 setPreferenceProperty( hh, "step", 0.1 );
4798 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4799 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4800 setPreferenceProperty( distributionGr, "columns", 3 );
4802 types.append( tr( "SMESH_MONOCOLOR" ) );
4803 types.append( tr( "SMESH_MULTICOLOR" ) );
4804 indices.clear(); indices.append( 0 ); indices.append( 1 );
4805 setPreferenceProperty( coloringType, "strings", types );
4806 setPreferenceProperty( coloringType, "indexes", indices );
4807 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4811 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4813 if( sect=="SMESH" ) {
4814 float sbX1,sbY1,sbW,sbH;
4815 float aTol = 1.00000009999999;
4816 std::string aWarning;
4817 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4818 if( name=="selection_object_color" || name=="selection_element_color" ||
4819 name=="highlight_color" ||
4820 name=="selection_precision_node" || name=="selection_precision_element" ||
4821 name=="selection_precision_object")
4822 SMESH::UpdateSelectionProp( this );
4823 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4824 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4825 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4826 if(sbX1+sbW > aTol){
4827 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4830 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4831 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4834 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4835 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4836 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4837 if(sbY1+sbH > aTol){
4838 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4839 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4840 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4843 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4844 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4845 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4846 if(sbX1+sbW > aTol){
4847 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4850 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4851 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4854 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4855 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4856 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4857 if(sbY1+sbH > aTol){
4858 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4861 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4862 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4865 else if ( name == "segmentation" ) {
4866 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4867 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4869 else if ( name == "nb_segments_per_edge" ) {
4870 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4871 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4873 else if ( name == "historical_python_dump" ||
4874 name == "forget_mesh_on_hyp_modif") {
4875 QString val = aResourceMgr->stringValue( "SMESH", name );
4876 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
4879 if(aWarning.size() != 0){
4880 aWarning += "The default values are applied instead.";
4881 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4882 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4883 QObject::tr(aWarning.c_str()));
4888 //================================================================================
4890 * \brief Update something in accordance with update flags
4891 * \param theFlags - update flags
4893 * Update viewer or/and object browser etc. in accordance with update flags ( see
4894 * LightApp_UpdateFlags enumeration ).
4896 //================================================================================
4897 void SMESHGUI::update( const int flags )
4899 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4900 SMESH::UpdateView();
4902 SalomeApp_Module::update( flags );
4905 //================================================================================
4907 * \brief Set default selection mode
4909 * SLOT called when operation commited. Sets default selection mode
4911 //================================================================================
4912 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4914 SVTK_ViewWindow* vtkWnd =
4915 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4917 vtkWnd->SetSelectionMode( ActorSelection );
4920 //================================================================================
4922 * \brief Set default selection mode
4924 * SLOT called when operation aborted. Sets default selection mode
4926 //================================================================================
4927 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4929 SVTK_ViewWindow* vtkWnd =
4930 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4932 vtkWnd->SetSelectionMode( ActorSelection );
4935 //================================================================================
4937 * \brief Creates operation with given identifier
4938 * \param id - identifier of operation to be started
4939 * \return Pointer on created operation or NULL if operation is not created
4941 * Virtual method redefined from the base class creates operation with given id.
4942 * It is called called automatically from startOperation method of base class.
4944 //================================================================================
4945 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4947 LightApp_Operation* op = 0;
4948 // to do : create operation here
4951 case 417: //convert to quadratic
4952 op = new SMESHGUI_ConvToQuadOp();
4954 case 418: // create 2D mesh as boundary on 3D
4955 op = new SMESHGUI_Make2DFrom3DOp();
4957 case 701: // Compute mesh
4958 op = new SMESHGUI_ComputeOp();
4960 case 702: // Create mesh
4961 op = new SMESHGUI_MeshOp( true, true );
4963 case 703: // Create sub-mesh
4964 op = new SMESHGUI_MeshOp( true, false );
4966 case 704: // Edit mesh/sub-mesh
4967 op = new SMESHGUI_MeshOp( false );
4969 case 711: // Precompute mesh
4970 op = new SMESHGUI_PrecomputeOp();
4972 case 712: // Evaluate mesh
4973 op = new SMESHGUI_EvaluateOp();
4975 case 713: // Evaluate mesh
4976 op = new SMESHGUI_MeshOrderOp();
4978 case 806: // Create group on geom
4979 op = new SMESHGUI_GroupOnShapeOp();
4981 case 904: // Find element
4982 op = new SMESHGUI_FindElemByPointOp();
4984 case 4067: // make mesh pass through point
4985 op = new SMESHGUI_MakeNodeAtPointOp();
4992 op = SalomeApp_Module::createOperation( id );
4996 //================================================================================
4998 * \brief Stops current operations and starts a given one
4999 * \param id - The id of the operation to start
5001 //================================================================================
5003 void SMESHGUI::switchToOperation(int id)
5005 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5006 activeStudy()->abortAllOperations();
5007 startOperation( id );
5010 LightApp_Displayer* SMESHGUI::displayer()
5013 myDisplayer = new SMESHGUI_Displayer( getApp() );
5017 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5020 int aTolerance = 64;
5021 int anIterations = 0;
5027 if( anIterations % aPeriod == 0 )
5030 if( aTolerance < 1 )
5034 aHue = (int)( 360.0 * rand() / RAND_MAX );
5037 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5038 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5039 for( ; it != itEnd; ++it )
5041 SALOMEDS::Color anAutoColor = *it;
5042 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5045 aQColor.getHsv( &h, &s, &v );
5046 if( abs( h - aHue ) < aTolerance )
5058 aColor.setHsv( aHue, 255, 255 );
5060 SALOMEDS::Color aSColor;
5061 aSColor.R = (double)aColor.red() / 255.0;
5062 aSColor.G = (double)aColor.green() / 255.0;
5063 aSColor.B = (double)aColor.blue() / 255.0;
5068 const char gSeparator = '_'; // character used to separate parameter names
5069 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
5070 const char gPathSep = '|'; // character used to separate paths
5073 * \brief Store visual parameters
5075 * This method is called just before the study document is saved.
5076 * Store visual parameters in AttributeParameter attribue(s)
5078 void SMESHGUI::storeVisualParameters (int savePoint)
5080 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5081 if (!appStudy || !appStudy->studyDS())
5083 _PTR(Study) studyDS = appStudy->studyDS();
5085 // componentName is used for encoding of entries when storing them in IParameters
5086 std::string componentName = myComponentSMESH->ComponentDataType();
5087 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5088 //if (!aSComponent) return;
5091 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5092 componentName.c_str(),
5094 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5096 // store map of custom markers
5097 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5098 if( !aMarkerMap.empty() )
5100 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5101 for( ; anIter != aMarkerMap.end(); anIter++ )
5103 int anId = anIter->first;
5104 VTK::MarkerData aMarkerData = anIter->second;
5105 std::string aMarkerFileName = aMarkerData.first;
5106 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5107 if( aMarkerTexture.size() < 3 )
5108 continue; // should contain at least width, height and the first value
5110 QString aPropertyName( "texture" );
5111 aPropertyName += gSeparator;
5112 aPropertyName += QString::number( anId );
5114 QString aPropertyValue = aMarkerFileName.c_str();
5115 aPropertyValue += gPathSep;
5117 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5118 ushort aWidth = *aTextureIter++;
5119 ushort aHeight = *aTextureIter++;
5120 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5121 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5122 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5123 aPropertyValue += QString::number( *aTextureIter );
5125 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5129 // viewers counters are used for storing view_numbers in IParameters
5132 // main cycle to store parameters of displayed objects
5133 QList<SUIT_ViewManager*> lst;
5134 QList<SUIT_ViewManager*>::Iterator it;
5135 getApp()->viewManagers(lst);
5136 for (it = lst.begin(); it != lst.end(); it++)
5138 SUIT_ViewManager* vman = *it;
5139 QString vType = vman->getType();
5141 // saving VTK actors properties
5142 if (vType == SVTK_Viewer::Type())
5144 // store the clipping planes attached to the view manager
5145 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5146 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5147 if( anIter != myClippingPlaneInfoMap.end() )
5148 aClippingPlaneInfoList = anIter->second;
5150 if( !aClippingPlaneInfoList.empty() ) {
5151 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5152 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5154 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5155 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5157 QString aPropertyName( "ClippingPlane" );
5158 aPropertyName += gSeparator;
5159 aPropertyName += QString::number( vtkViewers );
5160 aPropertyName += gSeparator;
5161 aPropertyName += QString::number( anId );
5163 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5164 aPropertyValue += gDigitsSep;
5165 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5166 aPropertyValue += gDigitsSep;
5167 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5168 aPropertyValue += gDigitsSep;
5169 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5171 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5175 QVector<SUIT_ViewWindow*> views = vman->getViews();
5176 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5178 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5180 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5181 vtkActorCollection* allActors = aCopy.GetActors();
5182 allActors->InitTraversal();
5183 while (vtkActor* actor = allActors->GetNextActor())
5185 if (actor->GetVisibility()) // store only visible actors
5187 SMESH_Actor* aSmeshActor = 0;
5188 if (actor->IsA("SMESH_Actor"))
5189 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5190 if (aSmeshActor && aSmeshActor->hasIO())
5192 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5195 // entry is "encoded" = it does NOT contain component adress,
5196 // since it is a subject to change on next component loading
5197 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5199 std::string param, vtkParam = vType.toLatin1().data();
5200 vtkParam += gSeparator;
5201 vtkParam += QString::number(vtkViewers).toLatin1().data();
5202 vtkParam += gSeparator;
5205 param = vtkParam + "Visibility";
5206 ip->setParameter(entry, param, "On");
5209 param = vtkParam + "Representation";
5210 ip->setParameter(entry, param, QString::number
5211 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5214 param = vtkParam + "IsShrunk";
5215 ip->setParameter(entry, param, QString::number
5216 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5218 // Displayed entities
5219 unsigned int aMode = aSmeshActor->GetEntityMode();
5220 bool isE = aMode & SMESH_Actor::eEdges;
5221 bool isF = aMode & SMESH_Actor::eFaces;
5222 bool isV = aMode & SMESH_Actor::eVolumes;
5224 QString modeStr ("e");
5225 modeStr += gDigitsSep; modeStr += QString::number(isE);
5226 modeStr += gDigitsSep; modeStr += "f";
5227 modeStr += gDigitsSep; modeStr += QString::number(isF);
5228 modeStr += gDigitsSep; modeStr += "v";
5229 modeStr += gDigitsSep; modeStr += QString::number(isV);
5231 param = vtkParam + "Entities";
5232 ip->setParameter(entry, param, modeStr.toLatin1().data());
5234 // Colors (surface:edge:)
5235 vtkFloatingPointType r, g, b;
5238 aSmeshActor->GetSufaceColor(r, g, b, delta);
5239 QString colorStr ("surface");
5240 colorStr += gDigitsSep; colorStr += QString::number(r);
5241 colorStr += gDigitsSep; colorStr += QString::number(g);
5242 colorStr += gDigitsSep; colorStr += QString::number(b);
5244 colorStr += gDigitsSep; colorStr += "backsurface";
5245 colorStr += gDigitsSep; colorStr += QString::number(delta);
5248 aSmeshActor->GetEdgeColor(r, g, b);
5249 colorStr += gDigitsSep; colorStr += "edge";
5250 colorStr += gDigitsSep; colorStr += QString::number(r);
5251 colorStr += gDigitsSep; colorStr += QString::number(g);
5252 colorStr += gDigitsSep; colorStr += QString::number(b);
5254 aSmeshActor->GetNodeColor(r, g, b);
5255 colorStr += gDigitsSep; colorStr += "node";
5256 colorStr += gDigitsSep; colorStr += QString::number(r);
5257 colorStr += gDigitsSep; colorStr += QString::number(g);
5258 colorStr += gDigitsSep; colorStr += QString::number(b);
5260 aSmeshActor->GetOutlineColor(r, g, b);
5261 colorStr += gDigitsSep; colorStr += "outline";
5262 colorStr += gDigitsSep; colorStr += QString::number(r);
5263 colorStr += gDigitsSep; colorStr += QString::number(g);
5264 colorStr += gDigitsSep; colorStr += QString::number(b);
5266 param = vtkParam + "Colors";
5267 ip->setParameter(entry, param, colorStr.toLatin1().data());
5269 // Sizes of lines and points
5270 QString sizeStr ("line");
5271 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5272 sizeStr += gDigitsSep; sizeStr += "shrink";
5273 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5275 param = vtkParam + "Sizes";
5276 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5281 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5282 if( aMarkerType == VTK::MT_USER ) {
5283 markerStr += "custom";
5284 markerStr += gDigitsSep;
5285 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5289 markerStr += gDigitsSep;
5290 markerStr += QString::number( (int)aMarkerType );
5291 markerStr += gDigitsSep;
5292 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5295 param = vtkParam + "PointMarker";
5296 ip->setParameter(entry, param, markerStr.toLatin1().data());
5299 param = vtkParam + "Opacity";
5300 ip->setParameter(entry, param,
5301 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5304 param = vtkParam + "ClippingPlane";
5306 if( !aClippingPlaneInfoList.empty() ) {
5307 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5308 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5310 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5311 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5312 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5313 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5314 if( aSmeshActor == *anIter2 ) {
5315 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5316 QString::number( anId ).toLatin1().constData() );
5323 ip->setParameter( entry, param, "Off" );
5324 } // if (io->hasEntry())
5325 } // SMESH_Actor && hasIO
5327 } // while.. actors traversal
5331 } // if (SVTK view model)
5332 } // for (viewManagers)
5335 // data structures for clipping planes processing
5338 vtkIdType Orientation;
5339 vtkFloatingPointType Distance;
5340 vtkFloatingPointType Angle[2];
5342 typedef std::list<TPlaneData> TPlaneDataList;
5343 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5345 typedef std::list<vtkActor*> TActorList;
5348 TActorList ActorList;
5349 SUIT_ViewManager* ViewManager;
5351 typedef std::list<TPlaneInfo> TPlaneInfoList;
5352 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5355 * \brief Restore visual parameters
5357 * This method is called after the study document is opened.
5358 * Restore visual parameters from AttributeParameter attribue(s)
5360 void SMESHGUI::restoreVisualParameters (int savePoint)
5362 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5363 if (!appStudy || !appStudy->studyDS())
5365 _PTR(Study) studyDS = appStudy->studyDS();
5367 // componentName is used for encoding of entries when storing them in IParameters
5368 std::string componentName = myComponentSMESH->ComponentDataType();
5369 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5370 //if (!aSComponent) return;
5373 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5374 componentName.c_str(),
5376 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5378 // restore map of custom markers and map of clipping planes
5379 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5380 TPlaneDataMap aPlaneDataMap;
5382 std::vector<std::string> properties = ip->getProperties();
5383 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5385 std::string property = *propIt;
5386 QString aPropertyName( property.c_str() );
5387 QString aPropertyValue( ip->getProperty( property ).c_str() );
5389 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5390 if( aPropertyNameList.isEmpty() )
5393 QString aPropertyType = aPropertyNameList[0];
5394 if( aPropertyType == "texture" )
5396 if( aPropertyNameList.size() != 2 )
5400 int anId = aPropertyNameList[1].toInt( &ok );
5401 if( !ok || anId < 1 )
5404 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5405 if( aPropertyValueList.size() != 2 )
5408 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5409 QString aMarkerTextureString = aPropertyValueList[1];
5410 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5411 if( aMarkerTextureStringList.size() != 3 )
5415 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5420 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5424 VTK::MarkerTexture aMarkerTexture;
5425 aMarkerTexture.push_back( aWidth );
5426 aMarkerTexture.push_back( aHeight );
5428 QString aMarkerTextureData = aMarkerTextureStringList[2];
5429 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5431 QChar aChar = aMarkerTextureData.at( i );
5432 if( aChar.isDigit() )
5433 aMarkerTexture.push_back( aChar.digitValue() );
5436 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5438 else if( aPropertyType == "ClippingPlane" )
5440 if( aPropertyNameList.size() != 3 )
5444 int aViewId = aPropertyNameList[1].toInt( &ok );
5445 if( !ok || aViewId < 0 )
5449 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5450 if( !ok || aClippingPlaneId < 0 )
5453 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5454 if( aPropertyValueList.size() != 4 )
5457 TPlaneData aPlaneData;
5458 aPlaneData.Id = aClippingPlaneId;
5461 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5466 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5471 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5476 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5480 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5481 aPlaneDataList.push_back( aPlaneData );
5485 TPlaneInfoMap aPlaneInfoMap;
5487 std::vector<std::string> entries = ip->getEntries();
5489 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5491 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5492 QString entry (ip->decodeEntry(*entIt).c_str());
5494 // Check that the entry corresponds to a real object in the Study
5495 // as the object may be deleted or modified after the visual state is saved.
5496 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5497 if (!so) continue; //Skip the not existent entry
5499 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5500 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5502 std::vector<std::string>::iterator namesIt = paramNames.begin();
5503 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5505 // actors are stored in a map after displaying of them for
5506 // quicker access in the future: map < viewID to actor >
5507 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5509 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5511 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5512 // '_' is used as separator and should not be used in viewer type or parameter names.
5513 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5514 if (lst.size() != 3)
5517 QString viewerTypStr = lst[0];
5518 QString viewIndexStr = lst[1];
5519 QString paramNameStr = lst[2];
5522 int viewIndex = viewIndexStr.toUInt(&ok);
5523 if (!ok) // bad conversion of view index to integer
5527 if (viewerTypStr == SVTK_Viewer::Type())
5529 SMESH_Actor* aSmeshActor = 0;
5530 if (vtkActors.IsBound(viewIndex))
5531 aSmeshActor = vtkActors.Find(viewIndex);
5533 QList<SUIT_ViewManager*> lst;
5534 getApp()->viewManagers(viewerTypStr, lst);
5536 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5537 SUIT_ViewManager* vman = NULL;
5538 if (viewIndex >= 0 && viewIndex < lst.count())
5539 vman = lst.at(viewIndex);
5541 if (paramNameStr == "Visibility")
5543 if (!aSmeshActor && displayer() && vman)
5545 SUIT_ViewModel* vmodel = vman->getViewModel();
5546 // SVTK view model can be casted to SALOME_View
5547 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5549 // store displayed actor in a temporary map for quicker
5550 // access later when restoring other parameters
5551 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5552 vtkRenderer* Renderer = vtkView->getRenderer();
5553 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5554 vtkActorCollection* theActors = aCopy.GetActors();
5555 theActors->InitTraversal();
5556 bool isFound = false;
5557 vtkActor *ac = theActors->GetNextActor();
5558 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5559 if (ac->IsA("SMESH_Actor")) {
5560 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5561 if (aGeomAc->hasIO()) {
5562 Handle(SALOME_InteractiveObject) io =
5563 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5564 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5566 vtkActors.Bind(viewIndex, aGeomAc);
5572 } // if (paramNameStr == "Visibility")
5575 // the rest properties "work" with SMESH_Actor
5578 QString val ((*valuesIt).c_str());
5581 if (paramNameStr == "Representation") {
5582 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5585 else if (paramNameStr == "IsShrunk") {
5587 if (!aSmeshActor->IsShrunk())
5588 aSmeshActor->SetShrink();
5591 if (aSmeshActor->IsShrunk())
5592 aSmeshActor->UnShrink();
5595 // Displayed entities
5596 else if (paramNameStr == "Entities") {
5597 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5598 if (mode.count() == 6) {
5599 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5600 MESSAGE("Invalid order of data in Entities, must be: "
5601 "e:0/1:f:0/1:v:0/1");
5604 unsigned int aMode = aSmeshActor->GetEntityMode();
5605 unsigned int aNewMode =
5606 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5607 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5608 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5609 if (aNewMode != aMode)
5610 aSmeshActor->SetEntityMode(aNewMode);
5615 else if (paramNameStr == "Colors") {
5616 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5617 if (colors.count() == 16 || colors.count() == 18 ) {
5618 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5619 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
5620 (colors.count() == 18 && colors[14] != "outline")) {
5621 MESSAGE("Invalid order of data in Colors, must be: "
5622 "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");
5628 vtkFloatingPointType otr,otg,otb;
5629 //Old case backsurface color is independent
5630 if( colors.count() == 16 ) {
5632 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5633 er = colors[9].toFloat();
5634 eg = colors[10].toFloat();
5635 eb = colors[11].toFloat();
5637 nr = colors[13].toFloat();
5638 ng = colors[14].toFloat();
5639 nb = colors[15].toFloat();
5640 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5642 //New case backsurface color depends on surface color
5643 delta = colors[5].toInt();
5645 er = colors[7].toFloat();
5646 eg = colors[8].toFloat();
5647 eb = colors[9].toFloat();
5649 nr = colors[11].toFloat();
5650 ng = colors[12].toFloat();
5651 nb = colors[13].toFloat();
5653 otr = colors[15].toFloat();
5654 otg = colors[16].toFloat();
5655 otb = colors[17].toFloat();
5657 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5658 aSmeshActor->SetEdgeColor(er,eg,eb);
5659 aSmeshActor->SetNodeColor(nr,ng,nb);
5660 aSmeshActor->SetOutlineColor(otr,otg,otb);
5664 // Sizes of lines and points
5665 else if (paramNameStr == "Sizes") {
5666 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5667 if (sizes.count() == 4) {
5668 if (sizes[0] != "line" || sizes[2] != "shrink") {
5669 MESSAGE("Invalid order of data in Sizes, must be: "
5670 "line:int:shrink:float");
5673 aSmeshActor->SetLineWidth(sizes[1].toInt());
5674 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5677 else if (sizes.count() == 6) { // just to support old format
5678 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5679 MESSAGE("Invalid order of data in Sizes, must be: "
5680 "line:int:node:int:shrink:float");
5683 aSmeshActor->SetLineWidth(sizes[1].toInt());
5684 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5685 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5690 else if (paramNameStr == "PointMarker") {
5691 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5692 if( data.count() >= 2 ) {
5694 int aParam1 = data[1].toInt( &ok );
5696 if( data[0] == "std" && data.count() == 3 ) {
5697 int aParam2 = data[2].toInt( &ok );
5698 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5700 else if( data[0] == "custom" ) {
5701 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5702 if( markerIt != aMarkerMap.end() ) {
5703 VTK::MarkerData aMarkerData = markerIt->second;
5704 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5711 else if (paramNameStr == "Opacity") {
5712 aSmeshActor->SetOpacity(val.toFloat());
5715 else if (paramNameStr.startsWith("ClippingPlane")) {
5716 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5717 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5718 // new format - val looks like "Off" or "0" (plane id)
5719 // (note: in new format "Off" value is used only for consistency,
5720 // so it is processed together with values in old format)
5721 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5722 if( anIsOldFormat ) {
5723 if (paramNameStr == "ClippingPlane1" || val == "Off")
5724 aSmeshActor->RemoveAllClippingPlanes();
5726 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5727 double aDistance = vals[1].toFloat();
5728 vtkFloatingPointType anAngle[2];
5729 anAngle[0] = vals[2].toFloat();
5730 anAngle[1] = vals[3].toFloat();
5732 QList<SUIT_ViewManager*> lst;
5733 getApp()->viewManagers(viewerTypStr, lst);
5734 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5735 if (viewIndex >= 0 && viewIndex < lst.count()) {
5736 SUIT_ViewManager* vman = lst.at(viewIndex);
5737 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5739 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5741 SMESH::TActorList anActorList;
5742 anActorList.push_back( aSmeshActor );
5743 SMESH::OrientedPlane* aPlane =
5744 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5746 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5747 aClippingPlaneInfo.Plane = aPlane;
5748 aClippingPlaneInfo.ActorList = anActorList;
5749 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5756 int aPlaneId = val.toInt( &ok );
5757 if( ok && aPlaneId >= 0 ) {
5758 bool anIsDefinedPlane = false;
5759 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5760 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5761 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5762 TPlaneInfo& aPlaneInfo = *anIter;
5763 if( aPlaneInfo.PlaneId == aPlaneId ) {
5764 aPlaneInfo.ActorList.push_back( aSmeshActor );
5765 anIsDefinedPlane = true;
5769 if( !anIsDefinedPlane ) {
5770 TPlaneInfo aPlaneInfo;
5771 aPlaneInfo.PlaneId = aPlaneId;
5772 aPlaneInfo.ActorList.push_back( aSmeshActor );
5773 aPlaneInfo.ViewManager = vman;
5775 // to make the list sorted by plane id
5776 anIter = aPlaneInfoList.begin();
5777 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5778 const TPlaneInfo& aPlaneInfoRef = *anIter;
5779 if( aPlaneInfoRef.PlaneId > aPlaneId )
5782 aPlaneInfoList.insert( anIter, aPlaneInfo );
5787 } // if (aSmeshActor)
5788 } // other parameters than Visibility
5790 } // for names/parameters iterator
5791 } // for entries iterator
5793 // take into account planes with empty list of actors referred to them
5794 QList<SUIT_ViewManager*> aVMList;
5795 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5797 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5798 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5799 int aViewId = aPlaneDataIter->first;
5800 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5801 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5803 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5805 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5806 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5807 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5808 const TPlaneData& aPlaneData = *anIter2;
5809 int aPlaneId = aPlaneData.Id;
5811 bool anIsFound = false;
5812 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5813 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5814 const TPlaneInfo& aPlaneInfo = *anIter3;
5815 if( aPlaneInfo.PlaneId == aPlaneId ) {
5822 TPlaneInfo aPlaneInfo; // ActorList field is empty
5823 aPlaneInfo.PlaneId = aPlaneId;
5824 aPlaneInfo.ViewManager = aViewManager;
5826 // to make the list sorted by plane id
5827 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5828 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5829 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5830 if( aPlaneInfoRef.PlaneId > aPlaneId )
5833 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5839 // add clipping planes to actors according to the restored parameters
5840 // and update the clipping plane map
5841 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5842 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5843 int aViewId = anIter1->first;
5844 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5846 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5847 if( anIter2 == aPlaneDataMap.end() )
5849 const TPlaneDataList& aPlaneDataList = anIter2->second;
5851 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5852 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5853 const TPlaneInfo& aPlaneInfo = *anIter3;
5854 int aPlaneId = aPlaneInfo.PlaneId;
5855 const TActorList& anActorList = aPlaneInfo.ActorList;
5856 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5860 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5864 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5866 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5867 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5868 const TPlaneData& aPlaneData = *anIter4;
5869 if( aPlaneData.Id == aPlaneId ) {
5870 SMESH::OrientedPlane* aPlane =
5871 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5873 (SMESH::Orientation)aPlaneData.Orientation,
5874 aPlaneData.Distance,
5877 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5878 aClippingPlaneInfo.Plane = aPlane;
5879 aClippingPlaneInfo.ActorList = anActorList;
5880 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5888 // update all VTK views
5889 QList<SUIT_ViewManager*> lst;
5890 getApp()->viewManagers(lst);
5891 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5892 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5893 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5894 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5895 vtkView->getRenderer()->ResetCameraClippingRange();
5902 \brief Adds preferences for dfont of VTK viewer
5904 \param pIf group identifier
5905 \param param parameter
5906 \return identifier of preferences
5908 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5910 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5912 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5915 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5916 fam.append( tr( "SMESH_FONT_COURIER" ) );
5917 fam.append( tr( "SMESH_FONT_TIMES" ) );
5919 setPreferenceProperty( tfont, "fonts", fam );
5921 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5922 setPreferenceProperty( tfont, "features", f );
5928 \brief Actions after hypothesis edition
5929 Updates object browser after hypothesis edition
5931 void SMESHGUI::onHypothesisEdit( int result )
5934 SMESHGUI::Modified();
5935 updateObjBrowser( true );
5940 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5941 \param pview view being closed
5943 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5944 #ifndef DISABLE_PLOT2DVIEWER
5945 //Crear all Plot2d Viewers if need.
5946 SMESH::ClearPlot2Viewers(pview);
5950 void SMESHGUI::message( const QString& msg )
5953 QStringList data = msg.split("/");
5954 if ( data.count() > 0 ) {
5955 if ( data.first() == "mesh_loading" ) {
5957 QString entry = data.count() > 1 ? data[1] : QString();
5958 if ( entry.isEmpty() )
5961 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
5963 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
5966 name = obj->GetName().c_str();
5967 if ( name.isEmpty() )
5970 if ( data.last() == "stop" )
5971 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
5973 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
5974 QApplication::processEvents();
5980 \brief Connects or disconnects signals about activating and cloning view on the module slots
5981 \param pview view which is connected/disconnected
5983 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5987 SUIT_ViewManager* viewMgr = pview->getViewManager();
5989 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5990 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5992 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5993 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5998 \brief Return \c true if object can be renamed
6000 bool SMESHGUI::renameAllowed( const QString& entry) const {
6001 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6005 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6009 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6014 if(appStudy->isComponent(entry) || obj->isReference())
6017 // check type to prevent renaming of inappropriate objects
6018 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6019 if (aType == MESH || aType == GROUP ||
6020 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
6021 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
6022 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
6023 aType == HYPOTHESIS || aType == ALGORITHM)
6030 Rename object by entry.
6031 \param entry entry of the object
6032 \param name new name of the object
6033 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6035 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6037 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6041 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6046 _PTR(Study) aStudy = appStudy->studyDS();
6051 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6053 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6058 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6059 _PTR(GenericAttribute) anAttr;
6060 _PTR(AttributeName) aName;
6062 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6064 // check type to prevent renaming of inappropriate objects
6065 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6066 if (aType == MESH || aType == GROUP ||
6067 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
6068 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
6069 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
6070 aType == HYPOTHESIS || aType == ALGORITHM) {
6071 if ( !name.isEmpty() ) {
6072 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6074 // update name of group object and its actor
6075 Handle(SALOME_InteractiveObject) IObject =
6076 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6078 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6079 if( !aGroupObject->_is_nil() ) {
6080 aGroupObject->SetName( qPrintable(name) );
6081 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6082 anActor->setName( qPrintable(name) );