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 ????????
143 #include <QTextStream>
146 #include <boost/shared_ptr.hpp>
149 #include <vtkCamera.h>
150 #include <vtkRenderer.h>
151 #include <vtkPlane.h>
152 #include <vtkCallbackCommand.h>
153 #include <vtkLookupTable.h>
155 // SALOME KERNEL includes
156 #include <SALOMEDS_Study.hxx>
157 #include <SALOMEDSClient_StudyBuilder.hxx>
158 #include <SALOMEDSClient_SComponent.hxx>
159 #include <SALOMEDSClient_ClientFactory.hxx>
160 #include <SALOMEDSClient_IParameters.hxx>
163 #include <Standard_ErrorHandler.hxx>
164 #include <NCollection_DataMap.hxx>
166 //To disable automatic genericobj management, the following line should be commented.
167 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
168 #define WITHGENERICOBJ
172 //=============================================================
173 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
176 void ExportMeshToFile(int theCommandID);
178 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
180 void SetDisplayEntity(int theCommandID);
182 void Control( int theCommandID );
186 //=============================================================
187 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
191 std::string myExtension;
193 if ( theCommandID == 113 ) {
194 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
195 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
197 else if ( theCommandID == 112 ) {
198 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
200 else if ( theCommandID == 111 ) {
201 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
203 else if ( theCommandID == 115 ) {
204 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
206 else if ( theCommandID == 116 ) {
207 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
209 else if ( theCommandID == 117 ) {
210 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
211 filter.append( QObject::tr( "All files (*)" ) );
214 QString anInitialPath = "";
215 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
216 anInitialPath = QDir::currentPath();
218 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
221 QObject::tr( "SMESH_IMPORT_MESH" ) );
222 if ( filenames.count() > 0 ) {
223 SUIT_OverrideCursor wc;
224 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
227 QStringList anEntryList;
228 bool isEmpty = false;
229 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
230 QString filename = *it;
231 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
233 switch ( theCommandID ) {
236 // DAT format (currently unsupported)
237 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
238 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
244 aMeshes->length( 1 );
245 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
246 if ( aMeshes[0]->_is_nil() )
247 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
248 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
254 SMESH::DriverMED_ReadStatus res;
255 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
256 if ( res != SMESH::DRS_OK ) {
257 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
258 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
265 aMeshes->length( 1 );
266 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
267 if ( aMeshes[0]->_is_nil() ) {
268 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
269 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
276 SMESH::DriverMED_ReadStatus res;
277 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
278 if ( res != SMESH::DRS_OK ) {
279 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
280 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
287 SMESH::DriverMED_ReadStatus res;
288 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
289 if ( res != SMESH::DRS_OK ) {
290 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
291 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
297 catch ( const SALOME::SALOME_Exception& S_ex ) {
298 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
299 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
302 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
303 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
305 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
306 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
307 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
308 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
309 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
311 anEntryList.append( aMeshSO->GetID().c_str() );
313 #ifdef WITHGENERICOBJ
314 // obj has been published in study. Its refcount has been incremented.
315 // It is safe to decrement its refcount
316 // so that it will be destroyed when the entry in study will be removed
317 aMeshes[i]->UnRegister();
326 // update Object browser
327 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
329 // browse to the published meshes
330 if( LightApp_Application* anApp =
331 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
332 anApp->browseObjects( anEntryList );
334 // show Error message box if there were errors
335 if ( errors.count() > 0 ) {
336 SUIT_MessageBox::critical( SMESHGUI::desktop(),
337 QObject::tr( "SMESH_ERROR" ),
338 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
341 // show warning message box, if some imported mesh is empty
343 SUIT_MessageBox::warning( SMESHGUI::desktop(),
344 QObject::tr( "SMESH_WRN_WARNING" ),
345 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
350 //================================================================================
352 * \brief Export selected meshes or groups into a file
354 //================================================================================
356 void ExportMeshToFile( int theCommandID )
358 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
359 SALOME_ListIO selected;
361 aSel->selectedObjects( selected );
363 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
364 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
365 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
366 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
367 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
368 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
370 // actually, the following condition can't be met (added for insurance)
371 if( selected.Extent() == 0 ||
372 ( selected.Extent() > 1 && !isMED && !isSTL ))
375 // get mesh object from selection and check duplication of their names
376 bool hasDuplicatedMeshNames = false;
377 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
378 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
379 SALOME_ListIteratorOfListIO It( selected );
380 for( ; It.More(); It.Next() )
382 Handle(SALOME_InteractiveObject) anIObject = It.Value();
383 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
384 if ( aMeshItem->_is_nil() ) {
385 SUIT_MessageBox::warning( SMESHGUI::desktop(),
386 QObject::tr( "SMESH_WRN_WARNING" ),
387 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
391 QString aMeshName = anIObject->getName();
393 // check for name duplications
394 if ( !hasDuplicatedMeshNames )
395 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
396 if( aMeshName == (*aMeshIter).second ) {
397 hasDuplicatedMeshNames = true;
402 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
405 if( hasDuplicatedMeshNames && isMED ) {
406 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
407 QObject::tr("SMESH_WRN_WARNING"),
408 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
409 QObject::tr("SMESH_BUT_YES"),
410 QObject::tr("SMESH_BUT_NO"), 0, 1);
415 aMeshIter = aMeshList.begin();
416 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
417 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
418 QString aMeshName = (*aMeshIter).second;
420 if ( isMED || isCGNS || isSAUV )
422 // check for equal group names within each mesh
423 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
424 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
425 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
426 int aRet = SUIT_MessageBox::warning
427 (SMESHGUI::desktop(),
428 QObject::tr("SMESH_WRN_WARNING"),
429 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
430 QObject::tr("SMESH_BUT_YES"),
431 QObject::tr("SMESH_BUT_NO"), 0, 1);
439 // warn the user about presence of not supported elements
440 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
441 int nbNotSupported = ( nbElems[ SMESH::Entity_Pyramid ] +
442 nbElems[ SMESH::Entity_Quad_Pyramid ] +
443 nbElems[ SMESH::Entity_Hexagonal_Prism ] +
444 nbElems[ SMESH::Entity_Polygon ] +
445 nbElems[ SMESH::Entity_Polyhedra ] );
446 if ( nbNotSupported > 0 ) {
447 int aRet = SUIT_MessageBox::warning
448 (SMESHGUI::desktop(),
449 QObject::tr("SMESH_WRN_WARNING"),
450 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
451 QObject::tr("SMESH_BUT_YES"),
452 QObject::tr("SMESH_BUT_NO"), 0, 1);
458 // Get parameters of export operation
461 SMESH::MED_VERSION aFormat;
462 // Init the parameters with the default values
463 bool aIsASCII_STL = true;
464 bool toCreateGroups = false;
465 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
467 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
468 bool toOverwrite = true;
470 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
471 QString anInitialPath = "";
472 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
473 anInitialPath = QDir::currentPath();
475 if ( isUNV || isDAT )
478 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
480 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
481 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
482 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
483 anInitialPath + QString("/") + aMeshName,
484 aFilter, aTitle, false);
486 else if ( isCGNS )// Export to CGNS
488 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
489 fd->setWindowTitle( aTitle );
490 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
491 if ( !anInitialPath.isEmpty() )
492 fd->setDirectory( anInitialPath );
493 fd->selectFile(aMeshName);
494 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
495 fd->setValidator( fv );
498 aFilename = fd->selectedFile();
499 toOverwrite = fv->isOverwrite();
503 else if ( isSTL ) // Export to STL
505 QMap<QString, int> aFilterMap;
506 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
507 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
510 QMap<QString, int>::const_iterator it = aFilterMap.begin();
511 for ( ; it != aFilterMap.end(); ++it )
512 filters.push_back( it.key() );
514 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
515 fd->setWindowTitle( aTitle );
516 fd->setNameFilters( filters );
517 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
518 if ( !anInitialPath.isEmpty() )
519 fd->setDirectory( anInitialPath );
520 fd->selectFile(aMeshName);
524 aFilename = fd->selectedFile();
525 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
530 else if ( isMED || isSAUV ) // Export to MED or SAUV
532 QMap<QString, SMESH::MED_VERSION> aFilterMap;
533 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
535 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
536 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
537 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
540 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
541 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
542 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
546 QString aDefaultFilter;
547 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
548 for ( ; it != aFilterMap.end(); ++it ) {
549 filters.push_back( it.key() );
550 if (it.value() == SMESH::MED_V2_2)
551 aDefaultFilter = it.key();
554 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
555 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
556 fd->setWindowTitle( aTitle );
557 fd->setNameFilters( filters );
558 fd->selectNameFilter(aDefaultFilter);
559 fd->SetChecked(toCreateGroups);
560 if ( !anInitialPath.isEmpty() )
561 fd->setDirectory( anInitialPath );
562 fd->selectFile(aMeshName);
564 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
565 fd->setValidator( fv );
570 aFilename = fd->selectedFile();
572 aFilename = QString::null;
575 aFormat = aFilterMap[fd->selectedNameFilter()];
576 toOverwrite = fv->isOverwrite();
578 if ( !aFilename.isEmpty() ) {
579 // med-2.1 does not support poly elements
580 if ( aFormat==SMESH::MED_V2_1 )
581 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
582 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
583 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
584 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
585 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
587 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
588 QObject::tr("SMESH_WRN_WARNING"),
589 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
590 QObject::tr("SMESH_BUT_YES"),
591 QObject::tr("SMESH_BUT_NO"), 0, 1);
599 // can't append to an existing using other format
600 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
601 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
602 if( !isVersionOk || aVersion != aFormat ) {
603 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
604 QObject::tr("SMESH_WRN_WARNING"),
605 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
606 QObject::tr("SMESH_BUT_YES"),
607 QObject::tr("SMESH_BUT_NO"), 0, 1);
614 QStringList aMeshNamesCollisionList;
615 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
616 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
617 QString anExistingMeshName( aMeshNames[ i ] );
618 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
619 QString anExportMeshName = (*aMeshIter).second;
620 if( anExportMeshName == anExistingMeshName ) {
621 aMeshNamesCollisionList.append( anExportMeshName );
626 if( !aMeshNamesCollisionList.isEmpty() ) {
627 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
628 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
629 QObject::tr("SMESH_WRN_WARNING"),
630 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
631 QObject::tr("SMESH_BUT_YES"),
632 QObject::tr("SMESH_BUT_NO"),
633 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
642 toCreateGroups = fd->IsChecked();
652 if ( !aFilename.isEmpty() ) {
653 // Check whether the file already exists and delete it if yes
654 QFile aFile( aFilename );
655 if ( aFile.exists() && toOverwrite )
657 SUIT_OverrideCursor wc;
660 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
661 // bool Renumber = false;
662 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
664 // Renumber= resMgr->booleanValue("SMESH","renumbering");
666 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
667 // aMeshEditor->RenumberNodes();
668 // aMeshEditor->RenumberElements();
669 // if ( SMESHGUI::automaticUpdate() )
670 // SMESH::UpdateView();
674 aMeshIter = aMeshList.begin();
675 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
677 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
678 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
679 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
680 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
681 aFormat, toOverwrite && aMeshIndex == 0 );
683 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
684 aFormat, toOverwrite && aMeshIndex == 0 );
689 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
691 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
692 if( !aMeshItem->_is_nil() )
693 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
698 if ( aMeshOrGroup->_is_equivalent( aMesh ))
699 aMesh->ExportDAT( aFilename.toLatin1().data() );
701 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
705 if ( aMeshOrGroup->_is_equivalent( aMesh ))
706 aMesh->ExportUNV( aFilename.toLatin1().data() );
708 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
712 if ( aMeshOrGroup->_is_equivalent( aMesh ))
713 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
715 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
719 aMeshIter = aMeshList.begin();
720 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
722 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
723 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
724 aMeshItem->ExportCGNS( aMeshOrGroup,
725 aFilename.toLatin1().data(),
726 toOverwrite && aMeshIndex == 0 );
730 catch (const SALOME::SALOME_Exception& S_ex){
732 SUIT_MessageBox::warning(SMESHGUI::desktop(),
733 QObject::tr("SMESH_WRN_WARNING"),
734 QObject::tr("SMESH_EXPORT_FAILED"));
740 inline void InverseEntityMode(unsigned int& theOutputMode,
741 unsigned int theMode)
743 bool anIsNotPresent = ~theOutputMode & theMode;
745 theOutputMode |= theMode;
747 theOutputMode &= ~theMode;
750 void SetDisplayEntity(int theCommandID){
751 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
752 SALOME_ListIO selected;
754 aSel->selectedObjects( selected );
756 if(selected.Extent() >= 1){
757 SALOME_ListIteratorOfListIO It( selected );
758 for( ; It.More(); It.Next()){
759 Handle(SALOME_InteractiveObject) IObject = It.Value();
760 if(IObject->hasEntry()){
761 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
762 unsigned int aMode = anActor->GetEntityMode();
763 switch(theCommandID){
765 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
768 InverseEntityMode(aMode,SMESH_Actor::eEdges);
771 InverseEntityMode(aMode,SMESH_Actor::eFaces);
774 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
777 aMode = SMESH_Actor::eAllEntity;
781 anActor->SetEntityMode(aMode);
789 SALOME_ListIO selected;
790 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
794 LightApp_SelectionMgr* aSel = app->selectionMgr();
795 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
796 if( !aSel || !appStudy )
799 aSel->selectedObjects( selected );
800 if( selected.IsEmpty() )
803 Handle(SALOME_InteractiveObject) anIObject = selected.First();
805 _PTR(Study) aStudy = appStudy->studyDS();
806 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
807 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
808 if( aMainObject->_is_nil() )
811 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
813 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
814 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
816 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
817 SALOMEDS::Color aColor = aGroupObject->GetColor();
818 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
820 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
821 if( aGroupObject->GetType() == SMESH::NODE )
822 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
823 else if( aGroupObject->GetType() == SMESH::EDGE )
824 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
825 else if( aGroupObject->GetType() == SMESH::ELEM0D )
826 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
830 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
831 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
837 SMESH::RepaintCurrentView();
840 QString functorToString( SMESH::Controls::FunctorPtr f )
842 QString type = QObject::tr( "UNKNOWN_CONTROL" );
843 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
844 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
845 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
846 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
847 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
848 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
849 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
850 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
851 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
852 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
853 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
854 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
855 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
856 type = QObject::tr( "WARP_ELEMENTS" );
857 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
858 type = QObject::tr( "TAPER_ELEMENTS" );
859 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
860 type = QObject::tr( "SKEW_ELEMENTS" );
861 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
862 type = QObject::tr( "AREA_ELEMENTS" );
863 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
864 type = QObject::tr( "LENGTH_EDGES" );
865 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
866 type = QObject::tr( "LENGTH2D_EDGES" );
867 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
868 type = QObject::tr( "MULTI_BORDERS" );
869 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
870 type = QObject::tr( "MULTI2D_BORDERS" );
871 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
872 type = QObject::tr( "FREE_NODES" );
873 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
874 type = QObject::tr( "FREE_EDGES" );
875 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
876 type = QObject::tr( "FREE_BORDERS" );
877 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
878 type = QObject::tr( "FREE_FACES" );
879 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
880 type = QObject::tr( "BARE_BORDER_VOLUME" );
881 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
882 type = QObject::tr( "BARE_BORDER_FACE" );
883 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
884 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
885 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
886 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
887 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
888 type = QObject::tr( "EQUAL_NODE" );
889 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
890 type = QObject::tr( "EQUAL_EDGE" );
891 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
892 type = QObject::tr( "EQUAL_FACE" );
893 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
894 type = QObject::tr( "EQUAL_VOLUME" );
898 void SaveDistribution()
900 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
901 SALOME_ListIO selected;
903 aSel->selectedObjects( selected );
905 if ( selected.Extent() == 1 ) {
906 Handle(SALOME_InteractiveObject) anIO = selected.First();
907 if ( anIO->hasEntry() ) {
908 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
909 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
910 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
911 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
912 if ( aScalarBarActor && aFunctor ) {
913 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
915 std::vector<int> elements;
916 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
917 if ( mesh->_is_nil() ) {
918 SMESH::SMESH_IDSource_var idSource =
919 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
920 if ( !idSource->_is_nil() )
922 SMESH::long_array_var ids = idSource->GetIDs();
923 elements.resize( ids->length() );
924 for ( unsigned i = 0; i < elements.size(); ++i )
925 elements[i] = ids[i];
928 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
929 vtkLookupTable* lookupTable =
930 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
931 double * minmax = lookupTable->GetRange();
932 std::vector<int> nbEvents;
933 std::vector<double> funValues;
934 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
935 QString anInitialPath = "";
936 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
937 anInitialPath = QDir::currentPath();
938 QString aMeshName = anIO->getName();
940 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
941 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
942 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
943 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
944 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
947 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
949 if ( !aFilename.isEmpty() ) {
950 QFile f( aFilename );
951 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
952 QTextStream out( &f );
953 out << "# Mesh: " << aMeshName << endl;
954 out << "# Control: " << functorToString( aFunctor ) << endl;
956 out.setFieldWidth( 10 );
957 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
958 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
969 void ShowDistribution() {
970 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
971 SALOME_ListIO selected;
973 aSel->selectedObjects( selected );
975 if ( selected.Extent() == 1 ) {
976 Handle(SALOME_InteractiveObject) anIO = selected.First();
977 if ( anIO->hasEntry() ) {
978 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
979 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
980 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
981 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
987 #ifndef DISABLE_PLOT2DVIEWER
988 void PlotDistribution() {
989 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
993 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
994 SALOME_ListIO selected;
996 aSel->selectedObjects( selected );
998 if ( selected.Extent() == 1 ) {
999 Handle(SALOME_InteractiveObject) anIO = selected.First();
1000 if ( anIO->hasEntry() ) {
1001 //Find Actor by entry before getting Plot2d viewer,
1002 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1003 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1005 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1010 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1014 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1018 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1019 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1020 QString functorName = functorToString( anActor->GetFunctor());
1021 QString aHistogramName("%1 : %2");
1022 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1023 aHistogram->setName(aHistogramName);
1024 aHistogram->setHorTitle(functorName);
1025 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1026 aPlot->displayObject(aHistogram, true);
1031 #endif //DISABLE_PLOT2DVIEWER
1033 void DisableAutoColor(){
1034 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1035 SALOME_ListIO selected;
1037 aSel->selectedObjects( selected );
1039 if(selected.Extent()){
1040 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1041 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1042 if ( !aMesh->_is_nil() ) {
1043 aMesh->SetAutoColor( false );
1048 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1049 SALOME_ListIO selected;
1050 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1054 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1055 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1056 if( !aSel || !appStudy )
1059 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1060 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1061 aModule->EmitSignalDeactivateDialog();
1062 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1063 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1068 _PTR(Study) aStudy = appStudy->studyDS();
1070 aSel->selectedObjects( selected );
1072 if(selected.Extent() >= 1){
1073 switch(theCommandID){
1075 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1076 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1080 QColor c, e, b, n, c0D, o, outl, selection, preselection;
1084 vtkFloatingPointType Shrink = 0.0;
1085 vtkFloatingPointType faces_orientation_scale = 0.0;
1086 bool faces_orientation_3dvectors = false;
1088 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1089 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1090 int aMarkerTextureCurrent = 0;
1092 SALOME_ListIteratorOfListIO It( selected );
1093 for( ; It.More(); It.Next()){
1094 Handle(SALOME_InteractiveObject) IObject = It.Value();
1095 if(IObject->hasEntry()){
1096 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1097 vtkFloatingPointType color[3];
1098 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1099 int c0 = int (color[0] * 255);
1100 int c1 = int (color[1] * 255);
1101 int c2 = int (color[2] * 255);
1102 c.setRgb(c0, c1, c2);
1104 vtkFloatingPointType edgecolor[3];
1105 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1106 c0 = int (edgecolor[0] * 255);
1107 c1 = int (edgecolor[1] * 255);
1108 c2 = int (edgecolor[2] * 255);
1109 e.setRgb(c0, c1, c2);
1111 vtkFloatingPointType nodecolor[3];
1112 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1113 c0 = int (nodecolor[0] * 255);
1114 c1 = int (nodecolor[1] * 255);
1115 c2 = int (nodecolor[2] * 255);
1116 n.setRgb(c0, c1, c2);
1118 vtkFloatingPointType color0D[3];
1119 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1120 c0 = int (color0D[0] * 255);
1121 c1 = int (color0D[1] * 255);
1122 c2 = int (color0D[2] * 255);
1123 c0D.setRgb(c0, c1, c2);
1125 vtkFloatingPointType outlineColor[3];
1126 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1127 c0 = int (outlineColor[0] * 255);
1128 c1 = int (outlineColor[1] * 255);
1129 c2 = int (outlineColor[2] * 255);
1130 outl.setRgb(c0, c1, c2);
1132 vtkFloatingPointType hColor[3];
1133 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1134 c0 = int (hColor[0] * 255);
1135 c1 = int (hColor[1] * 255);
1136 c2 = int (hColor[2] * 255);
1137 selection.setRgb(c0, c1, c2);
1139 vtkFloatingPointType phColor[3];
1140 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1141 c0 = int (phColor[0] * 255);
1142 c1 = int (phColor[1] * 255);
1143 c2 = int (phColor[2] * 255);
1144 preselection.setRgb(c0, c1, c2);
1146 size0D = (int)anActor->Get0DSize();
1149 Edgewidth = (int)anActor->GetLineWidth();
1152 Shrink = anActor->GetShrinkFactor();
1154 vtkFloatingPointType faces_orientation_color[3];
1155 anActor->GetFacesOrientationColor(faces_orientation_color);
1156 c0 = int (faces_orientation_color[0] * 255);
1157 c1 = int (faces_orientation_color[1] * 255);
1158 c2 = int (faces_orientation_color[2] * 255);
1159 o.setRgb(c0, c1, c2);
1161 faces_orientation_scale = anActor->GetFacesOrientationScale();
1162 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1164 aMarkerTypeCurrent = anActor->GetMarkerType();
1165 aMarkerScaleCurrent = anActor->GetMarkerScale();
1166 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1168 // even if there are multiple objects in the selection,
1169 // we need only the first one to get values for the dialog
1175 SMESHGUI_Preferences_ColorDlg *aDlg =
1176 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1177 aDlg->SetColor(1, c);
1178 aDlg->SetColor(2, e);
1179 aDlg->SetColor(3, n);
1180 aDlg->SetColor(4, outl);
1181 aDlg->SetDeltaBrightness(delta);
1182 aDlg->SetColor(5, c0D);
1183 aDlg->SetColor(6, o);
1184 aDlg->SetIntValue(1, Edgewidth);
1185 aDlg->SetIntValue(2, int(Shrink*100.));
1186 aDlg->SetIntValue(3, size0D);
1187 aDlg->SetDoubleValue(1, faces_orientation_scale);
1188 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1189 aDlg->SetColor(7, selection);
1190 aDlg->SetColor(8, preselection);
1192 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1194 if( aMarkerTypeCurrent != VTK::MT_USER )
1195 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1197 aDlg->setCustomMarker( aMarkerTextureCurrent );
1200 QColor color = aDlg->GetColor(1);
1201 QColor edgecolor = aDlg->GetColor(2);
1202 QColor nodecolor = aDlg->GetColor(3);
1203 QColor outlinecolor = aDlg->GetColor(4);
1204 QColor color0D = aDlg->GetColor(5);
1205 QColor faces_orientation_color = aDlg->GetColor(6);
1206 QColor selectioncolor = aDlg->GetColor(7);
1207 QColor preSelectioncolor = aDlg->GetColor(8);
1208 int delta = aDlg->GetDeltaBrightness();
1211 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1213 SALOME_ListIteratorOfListIO It( selected );
1214 for( ; It.More(); It.Next()){
1215 Handle(SALOME_InteractiveObject) IObject = It.Value();
1216 if(IObject->hasEntry()){
1217 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1218 /* actor color and backface color */
1219 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1220 vtkFloatingPointType (color.green()) / 255.,
1221 vtkFloatingPointType (color.blue()) / 255.,
1224 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1225 vtkFloatingPointType (edgecolor.green()) / 255.,
1226 vtkFloatingPointType (edgecolor.blue()) / 255.);
1228 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1229 vtkFloatingPointType (outlinecolor.green()) / 255.,
1230 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1233 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1234 vtkFloatingPointType (selectioncolor.green()) / 255.,
1235 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1237 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1238 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1239 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1242 /* Shrink factor and size edges */
1243 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1244 anActor->SetLineWidth(aDlg->GetIntValue(1));
1246 /* Nodes color and size */
1247 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1248 vtkFloatingPointType (nodecolor.green()) / 255.,
1249 vtkFloatingPointType (nodecolor.blue()) / 255.);
1252 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1253 vtkFloatingPointType (color0D.green()) / 255.,
1254 vtkFloatingPointType (color0D.blue()) / 255.);
1255 anActor->Set0DSize(aDlg->GetIntValue(3));
1257 /* Faces orientation */
1258 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1259 vtkFloatingPointType(faces_orientation_color.greenF()),
1260 vtkFloatingPointType(faces_orientation_color.blueF())};
1261 anActor->SetFacesOrientationColor(c);
1262 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1263 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1265 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1266 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1267 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1268 if( aMarkerTypeNew != VTK::MT_USER )
1269 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1271 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1272 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1273 if( anIter != aMarkerMap.end() )
1274 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1277 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1278 if( !aGroupObject->_is_nil() )
1280 SMESH::ElementType anElementType = aGroupObject->GetType();
1282 switch( anElementType )
1284 case SMESH::NODE: aColor = nodecolor; break;
1285 case SMESH::EDGE: aColor = edgecolor; break;
1286 default: aColor = color; break;
1289 SALOMEDS::Color aGroupColor;
1290 aGroupColor.R = (float)aColor.red() / 255.0;
1291 aGroupColor.G = (float)aColor.green() / 255.0;
1292 aGroupColor.B = (float)aColor.blue() / 255.0;
1293 aGroupObject->SetColor( aGroupColor );
1298 SMESH::RepaintCurrentView();
1304 SALOME_ListIteratorOfListIO It( selected );
1305 for( ; It.More(); It.Next()){
1306 Handle(SALOME_InteractiveObject) IObject = It.Value();
1307 if(IObject->hasEntry()){
1308 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1309 switch(theCommandID){
1311 anActor->SetRepresentation(SMESH_Actor::eEdge);
1314 anActor->SetRepresentation(SMESH_Actor::eSurface);
1317 if(anActor->IsShrunk())
1318 anActor->UnShrink();
1320 anActor->SetShrink();
1323 anActor->SetRepresentation(SMESH_Actor::ePoint);
1326 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1327 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1330 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1331 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1337 SMESH::RepaintCurrentView();
1341 void Control( int theCommandID )
1343 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1344 SALOME_ListIO selected;
1346 aSel->selectedObjects( selected );
1348 if( !selected.IsEmpty() ){
1349 Handle(SALOME_InteractiveObject) anIO = selected.First();
1351 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1352 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1353 switch ( theCommandID ){
1355 aControl = SMESH_Actor::eLength;
1358 aControl = SMESH_Actor::eLength2D;
1361 aControl = SMESH_Actor::eFreeEdges;
1364 aControl = SMESH_Actor::eFreeBorders;
1367 aControl = SMESH_Actor::eMultiConnection;
1370 aControl = SMESH_Actor::eFreeNodes;
1373 aControl = SMESH_Actor::eMultiConnection2D;
1376 aControl = SMESH_Actor::eArea;
1379 aControl = SMESH_Actor::eTaper;
1382 aControl = SMESH_Actor::eAspectRatio;
1385 aControl = SMESH_Actor::eAspectRatio3D;
1388 aControl = SMESH_Actor::eMinimumAngle;
1391 aControl = SMESH_Actor::eWarping;
1394 aControl = SMESH_Actor::eSkew;
1397 aControl = SMESH_Actor::eVolume3D;
1400 aControl = SMESH_Actor::eFreeFaces;
1403 aControl = SMESH_Actor::eMaxElementLength2D;
1406 aControl = SMESH_Actor::eMaxElementLength3D;
1409 aControl = SMESH_Actor::eBareBorderVolume;
1412 aControl = SMESH_Actor::eBareBorderFace;
1415 aControl = SMESH_Actor::eOverConstrainedVolume;
1418 aControl = SMESH_Actor::eOverConstrainedFace;
1421 aControl = SMESH_Actor::eCoincidentNodes;
1424 aControl = SMESH_Actor::eCoincidentElems1D;
1427 aControl = SMESH_Actor:: eCoincidentElems2D;
1430 aControl = SMESH_Actor::eCoincidentElems3D;
1434 anActor->SetControlMode(aControl);
1435 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1436 SMESH::RepaintCurrentView();
1437 #ifndef DISABLE_PLOT2DVIEWER
1438 if(anActor->GetPlot2Histogram()) {
1439 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1440 QString functorName = functorToString( anActor->GetFunctor());
1441 QString aHistogramName("%1 : %2");
1442 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1443 aHistogram->setName(aHistogramName);
1444 aHistogram->setHorTitle(functorName);
1445 SMESH::ProcessIn2DViewers(anActor);
1454 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1455 MeshObjectType theType,
1456 const QString theInTypeName,
1457 QString & theOutTypeName)
1459 SMESH_TypeFilter aTypeFilter( theType );
1461 if( !theIO.IsNull() )
1463 entry = theIO->getEntry();
1464 LightApp_DataOwner owner( entry );
1465 if ( aTypeFilter.isOk( &owner )) {
1466 theOutTypeName = theInTypeName;
1474 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1476 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1477 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1479 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1480 CORBA::String_var anID = aSComp->GetID().c_str();
1481 if (!strcmp(anID.in(),theIO->getEntry()))
1487 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1488 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1489 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1490 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1491 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1499 QString CheckHomogeneousSelection()
1501 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1502 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1503 SALOME_ListIO selected;
1505 aSel->selectedObjects( selected );
1507 QString RefType = CheckTypeObject(selected.First());
1508 SALOME_ListIteratorOfListIO It(selected);
1509 for ( ; It.More(); It.Next())
1511 Handle(SALOME_InteractiveObject) IObject = It.Value();
1512 QString Type = CheckTypeObject(IObject);
1513 if (Type.compare(RefType) != 0)
1514 return "Heterogeneous Selection";
1521 void SMESHGUI::OnEditDelete()
1523 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1524 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1525 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1527 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1528 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1529 _PTR(GenericAttribute) anAttr;
1530 _PTR(AttributeIOR) anIOR;
1532 int objectCount = 0;
1534 QString aParentComponent = QString::null;
1535 Handle(SALOME_InteractiveObject) anIO;
1536 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1538 anIO = anIt.Value();
1539 QString cur = anIO->getComponentDataType();
1540 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1542 // check if object is reference
1543 _PTR(SObject) aRefSObj;
1544 aNameList.append("\n - ");
1545 if ( aSO->ReferencedObject( aRefSObj ) ) {
1546 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1547 aNameList.append( aRefName );
1548 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1551 aNameList.append(anIO->getName());
1555 if( aParentComponent.isNull() )
1556 aParentComponent = cur;
1557 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1558 aParentComponent = "";
1561 if ( objectCount == 0 )
1562 return; // No Valid Objects Selected
1564 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1565 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1566 QObject::tr("ERR_ERROR"),
1567 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1570 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1571 if (SUIT_MessageBox::warning
1572 (SMESHGUI::desktop(),
1573 QObject::tr("SMESH_WRN_WARNING"),
1574 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1575 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1576 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1579 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1581 SALOME_ListIteratorOfListIO It(selected);
1583 aStudyBuilder->NewCommand(); // There is a transaction
1584 for( ; It.More(); It.Next()){ // loop on selected IO's
1585 Handle(SALOME_InteractiveObject) IObject = It.Value();
1586 if(IObject->hasEntry()) {
1587 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1589 // disable removal of "SMESH" component object
1590 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1592 if ( engineIOR() == anIOR->Value().c_str() )
1595 //Check the referenced object
1596 _PTR(SObject) aRefSObject;
1597 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1598 aSO = aRefSObject; // Delete main Object instead of reference
1600 // put the whole hierarchy of sub-objects of the selected SO into a list and
1601 // then treat them all starting from the deepest objects (at list back)
1603 std::list< _PTR(SObject) > listSO;
1604 listSO.push_back( aSO );
1605 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1606 for ( ; itSO != listSO.end(); ++itSO ) {
1607 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1608 for (it->InitEx(false); it->More(); it->Next())
1609 listSO.push_back( it->Value() );
1612 // treat SO's in the list starting from the back
1614 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1615 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1616 _PTR(SObject) SO = *ritSO;
1617 if ( !SO ) continue;
1618 std::string anEntry = SO->GetID();
1620 /** Erase graphical object **/
1621 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1622 ViewManagerList aViewMenegers = anApp->viewManagers();
1623 ViewManagerList::const_iterator it = aViewMenegers.begin();
1624 for( ; it != aViewMenegers.end(); it++) {
1625 SUIT_ViewManager* vm = *it;
1626 int nbSf = vm ? vm->getViewsCount() : 0;
1628 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1629 for(int i = 0; i < nbSf; i++){
1630 SUIT_ViewWindow *sf = aViews[i];
1631 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1632 SMESH::RemoveActor(sf,anActor);
1638 /** Remove an object from data structures **/
1639 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1640 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1641 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1642 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1643 aMesh->RemoveGroup( aGroup );
1645 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1646 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1647 aMesh->RemoveSubMesh( aSubMesh );
1649 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1651 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1654 IObject = new SALOME_InteractiveObject
1655 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1656 QString objType = CheckTypeObject(IObject);
1657 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1658 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1659 aStudyBuilder->RemoveObjectWithChildren( SO );
1661 else {// default action: remove SObject from the study
1662 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1663 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1665 aStudyBuilder->RemoveObjectWithChildren( SO );
1669 } /* listSO back loop */
1670 } /* IObject->hasEntry() */
1673 aStudyBuilder->CommitCommand();
1675 /* Clear any previous selection */
1677 aSel->setSelectedObjects( l1 );
1679 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1684 SMESHGUI_EXPORT CAM_Module* createModule()
1686 return new SMESHGUI();
1689 SMESHGUI_EXPORT char* getModuleVersion() {
1690 return (char*)SMESH_VERSION_STR;
1694 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1696 //=============================================================================
1700 //=============================================================================
1701 SMESHGUI::SMESHGUI() :
1702 SalomeApp_Module( "SMESH" ),
1703 LightApp_Module( "SMESH" )
1705 if ( CORBA::is_nil( myComponentSMESH ) )
1707 CORBA::Boolean anIsEmbeddedMode;
1708 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1709 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1711 // 0019923: EDF 765 SMESH : default values of hypothesis
1712 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1713 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1714 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1715 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1716 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1718 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1719 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1720 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1722 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1723 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1727 myActiveDialogBox = 0;
1728 myFilterLibraryDlg = 0;
1732 myEventCallbackCommand = vtkCallbackCommand::New();
1733 myEventCallbackCommand->Delete();
1734 myEventCallbackCommand->SetClientData( this );
1735 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1738 SMESH::GetFilterManager();
1739 SMESH::GetPattern();
1740 SMESH::GetMeasurements();
1742 /* load resources for all available meshers */
1743 SMESH::InitAvailableHypotheses();
1746 //=============================================================================
1750 //=============================================================================
1751 SMESHGUI::~SMESHGUI()
1753 #ifdef WITHGENERICOBJ
1754 SMESH::GetFilterManager()->UnRegister();
1755 SMESH::GetMeasurements()->UnRegister();
1757 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1758 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1761 //=============================================================================
1765 //=============================================================================
1766 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1768 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1770 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1775 //=============================================================================
1779 //=============================================================================
1780 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1782 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1786 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1787 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1788 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1789 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1790 return autoUpdate && !exceeded;
1793 //=============================================================================
1797 //=============================================================================
1798 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1800 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1803 //=============================================================================
1807 //=============================================================================
1808 SMESHGUI* SMESHGUI::GetSMESHGUI()
1810 SMESHGUI* smeshMod = 0;
1811 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1814 CAM_Module* module = app->module( "Mesh" );
1815 smeshMod = dynamic_cast<SMESHGUI*>( module );
1818 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1820 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1823 _PTR(Study) aStudy = study->studyDS();
1825 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1834 Standard_EXPORT SMESHGUI* GetComponentGUI()
1836 return SMESHGUI::GetSMESHGUI();
1840 //=============================================================================
1844 //=============================================================================
1845 void SMESHGUI::SetState(int aState)
1850 //=============================================================================
1854 //=============================================================================
1855 void SMESHGUI::ResetState()
1860 //=============================================================================
1864 //=============================================================================
1865 void SMESHGUI::EmitSignalDeactivateDialog()
1867 emit SignalDeactivateActiveDialog();
1870 //=============================================================================
1874 //=============================================================================
1875 void SMESHGUI::EmitSignalStudyFrameChanged()
1877 emit SignalStudyFrameChanged();
1880 //=============================================================================
1884 //=============================================================================
1885 void SMESHGUI::EmitSignalCloseAllDialogs()
1887 emit SignalCloseAllDialogs();
1890 //=============================================================================
1894 //=============================================================================
1895 void SMESHGUI::EmitSignalVisibilityChanged()
1897 emit SignalVisibilityChanged();
1900 //=============================================================================
1904 //=============================================================================
1905 QDialog *SMESHGUI::GetActiveDialogBox()
1907 return myActiveDialogBox;
1910 //=============================================================================
1914 //=============================================================================
1915 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1917 myActiveDialogBox = (QDialog *) aDlg;
1921 //=============================================================================
1925 //=============================================================================
1926 SUIT_Desktop* SMESHGUI::desktop()
1928 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1930 return app->desktop();
1935 //=============================================================================
1939 //=============================================================================
1940 SalomeApp_Study* SMESHGUI::activeStudy()
1942 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1944 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1949 //=============================================================================
1953 //=============================================================================
1954 void SMESHGUI::Modified( bool theIsUpdateActions )
1956 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1957 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1958 appStudy->Modified();
1959 if( theIsUpdateActions )
1960 app->updateActions();
1965 //=============================================================================
1969 //=============================================================================
1970 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1972 /* Here the position is on the bottom right corner - 10 */
1973 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1975 SUIT_Desktop *PP = desktop();
1976 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1977 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1981 //=============================================================================
1985 //=============================================================================
1986 static int isStudyLocked(_PTR(Study) theStudy){
1987 return theStudy->GetProperties()->IsLocked();
1990 static bool checkLock(_PTR(Study) theStudy) {
1991 if (isStudyLocked(theStudy)) {
1992 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1993 QObject::tr("WRN_WARNING"),
1994 QObject::tr("WRN_STUDY_LOCKED") );
2000 //=======================================================================
2001 //function : CheckActiveStudyLocked
2003 //=======================================================================
2005 bool SMESHGUI::isActiveStudyLocked()
2007 _PTR(Study) aStudy = activeStudy()->studyDS();
2008 return checkLock( aStudy );
2011 //=============================================================================
2015 //=============================================================================
2016 bool SMESHGUI::OnGUIEvent( int theCommandID )
2018 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2022 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2023 SUIT_ResourceMgr* mgr = resourceMgr();
2027 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2028 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2031 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2032 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2034 //QAction* act = action( theCommandID );
2036 switch (theCommandID) {
2038 if(checkLock(aStudy)) break;
2049 if(checkLock(aStudy)) break;
2050 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2054 case 150: //MED FILE INFORMATION
2056 SALOME_ListIO selected;
2057 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2059 aSel->selectedObjects( selected );
2060 if( selected.Extent() )
2062 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2063 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2064 if ( !aMesh->_is_nil() )
2066 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2073 case 122: // EXPORT MED
2086 ::ExportMeshToFile(theCommandID);
2090 case 200: // SCALAR BAR
2092 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2093 SALOME_ListIO selected;
2095 aSel->selectedObjects( selected );
2097 if( selected.Extent() ) {
2098 Handle(SALOME_InteractiveObject) anIO = selected.First();
2099 if( anIO->hasEntry() ) {
2100 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2101 anActor->SetControlMode( SMESH_Actor::eNone );
2102 #ifndef DISABLE_PLOT2DVIEWER
2103 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2112 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2117 // dump control distribution data to the text file
2118 ::SaveDistribution();
2124 // show/ distribution
2125 ::ShowDistribution();
2129 #ifndef DISABLE_PLOT2DVIEWER
2132 // plot distribution
2133 ::PlotDistribution();
2144 ::DisableAutoColor();
2147 case 1134: // Clipping
2148 case 1133: // Tranparency
2149 case 1132: // Display preferences (colors, shrink size, line width, ...)
2156 ::SetDisplayMode(theCommandID, myMarkerMap);
2159 //2D quadratic representation
2162 ::SetDisplayMode(theCommandID, myMarkerMap);
2166 case 216: // 0D elements
2169 case 219: // Volumes
2170 case 220: // All Entity
2171 ::SetDisplayEntity(theCommandID);
2174 case 221: // Orientation of faces
2176 LightApp_SelectionMgr* mgr = selectionMgr();
2177 SALOME_ListIO selected; mgr->selectedObjects( selected );
2179 SALOME_ListIteratorOfListIO it(selected);
2180 for( ; it.More(); it.Next()) {
2181 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2182 if(anIObject->hasEntry()) {
2183 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2184 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2193 if(checkLock(aStudy)) break;
2195 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2198 SMESH::UpdateView();
2200 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2201 SMESH::OnVisuException();
2203 catch (...) { // PAL16774 (Crash after display of many groups)
2204 SMESH::OnVisuException();
2208 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2209 aSel->selectedObjects( l );
2210 aSel->setSelectedObjects( l );
2215 case 301: // DISPLAY
2216 case 302: // DISPLAY ONLY
2218 SMESH::EDisplaing anAction;
2219 switch (theCommandID) {
2220 case 300: anAction = SMESH::eErase; break;
2221 case 301: anAction = SMESH::eDisplay; break;
2222 case 302: anAction = SMESH::eDisplayOnly; break;
2225 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2226 SALOME_ListIO sel_objects, to_process;
2228 aSel->selectedObjects( sel_objects );
2230 if( theCommandID==302 )
2232 MESSAGE("anAction = SMESH::eDisplayOnly");
2233 startOperation( myEraseAll );
2236 extractContainers( sel_objects, to_process );
2239 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2243 SALOME_ListIteratorOfListIO It( to_process );
2244 for ( ; It.More(); It.Next()) {
2246 Handle(SALOME_InteractiveObject) IOS = It.Value();
2247 if (IOS->hasEntry()) {
2249 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2250 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2251 break; // PAL16774 (Crash after display of many groups)
2253 if (anAction == SMESH::eDisplayOnly)
2255 MESSAGE("anAction = SMESH::eDisplayOnly");
2256 anAction = SMESH::eDisplay;
2262 // PAL13338 + PAL15161 -->
2263 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2264 MESSAGE("anAction = SMESH::eDisplayOnly");
2265 SMESH::UpdateView();
2266 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2268 // PAL13338 + PAL15161 <--
2270 catch (...) { // PAL16774 (Crash after display of many groups)
2271 SMESH::OnVisuException();
2274 if (anAction == SMESH::eErase) {
2275 MESSAGE("anAction == SMESH::eErase");
2277 aSel->setSelectedObjects( l1 );
2280 aSel->setSelectedObjects( to_process );
2287 if(checkLock(aStudy)) break;
2290 EmitSignalDeactivateDialog();
2292 ( new SMESHGUI_NodesDlg( this ) )->show();
2295 SUIT_MessageBox::warning(desktop(),
2296 tr("SMESH_WRN_WARNING"),
2297 tr("SMESH_WRN_VIEWER_VTK"));
2302 case 2151: // FILTER
2306 EmitSignalDeactivateDialog();
2307 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2312 case 701: // COMPUTE MESH
2313 case 711: // PRECOMPUTE MESH
2314 case 712: // EVALUATE MESH
2315 case 713: // MESH ORDER
2317 if (checkLock(aStudy)) break;
2318 startOperation( theCommandID );
2322 case 702: // Create mesh
2323 case 703: // Create sub-mesh
2324 case 704: // Edit mesh/sub-mesh
2325 startOperation( theCommandID );
2327 case 705: // copy mesh
2329 if (checkLock(aStudy)) break;
2330 EmitSignalDeactivateDialog();
2331 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2334 case 710: // Build compound mesh
2336 if (checkLock(aStudy)) break;
2337 EmitSignalDeactivateDialog();
2338 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2342 case 407: // DIAGONAL INVERSION
2343 case 408: // Delete diagonal
2347 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2348 tr( "NOT_A_VTK_VIEWER" ) );
2352 if ( checkLock( aStudy ) )
2355 /*Standard_Boolean aRes;
2356 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2357 if ( aMesh->_is_nil() )
2359 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2360 tr( "SMESH_BAD_SELECTION" ) );
2364 EmitSignalDeactivateDialog();
2365 if ( theCommandID == 407 )
2366 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2368 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2371 case 409: // Change orientation
2372 case 410: // Union of triangles
2373 case 411: // Cutting of quadrangles
2374 case 419: // Splitting volumes into tetrahedra
2378 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2379 tr( "NOT_A_VTK_VIEWER" ) );
2383 if ( checkLock( aStudy ) )
2386 EmitSignalDeactivateDialog();
2387 SMESHGUI_MultiEditDlg* aDlg = NULL;
2388 if ( theCommandID == 409 )
2389 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2390 else if ( theCommandID == 410 )
2391 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2392 else if ( theCommandID == 419 )
2393 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2395 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2400 case 412: // Smoothing
2402 if(checkLock(aStudy)) break;
2404 EmitSignalDeactivateDialog();
2405 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2408 SUIT_MessageBox::warning(desktop(),
2409 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2413 case 413: // Extrusion
2415 if (checkLock(aStudy)) break;
2417 EmitSignalDeactivateDialog();
2418 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2420 SUIT_MessageBox::warning(desktop(),
2421 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2425 case 414: // Revolution
2427 if(checkLock(aStudy)) break;
2429 EmitSignalDeactivateDialog();
2430 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2433 SUIT_MessageBox::warning(desktop(),
2434 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2438 case 415: // Pattern mapping
2440 if ( checkLock( aStudy ) )
2444 EmitSignalDeactivateDialog();
2445 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2448 SUIT_MessageBox::warning(desktop(),
2449 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2453 case 416: // Extrusion along a path
2455 if (checkLock(aStudy)) break;
2457 EmitSignalDeactivateDialog();
2458 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2460 SUIT_MessageBox::warning(desktop(),
2461 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2465 case 417: // Convert mesh to quadratic
2467 startOperation( 417 );
2468 /* if (checkLock(aStudy)) break;
2470 EmitSignalDeactivateDialog();
2471 new SMESHGUI_ConvToQuadDlg();
2473 SUIT_MessageBox::warning(desktop(),
2474 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2478 case 418: // create 2D mesh from 3D
2480 startOperation( 418 );
2483 case 806: // CREATE GEO GROUP
2485 startOperation( 806 );
2488 case 801: // CREATE GROUP
2492 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2493 tr( "NOT_A_VTK_VIEWER" ) );
2497 if(checkLock(aStudy)) break;
2498 EmitSignalDeactivateDialog();
2499 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2501 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2502 SALOME_ListIO selected;
2504 aSel->selectedObjects( selected );
2506 int nbSel = selected.Extent();
2508 // check if mesh is selected
2509 aMesh = SMESH::GetMeshByIO( selected.First() );
2511 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2516 case 802: // CONSTRUCT GROUP
2520 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2521 tr( "NOT_A_VTK_VIEWER" ) );
2525 if(checkLock(aStudy)) break;
2526 EmitSignalDeactivateDialog();
2528 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2529 SALOME_ListIO selected;
2531 aSel->selectedObjects( selected );
2533 int nbSel = selected.Extent();
2535 // check if submesh is selected
2536 Handle(SALOME_InteractiveObject) IObject = selected.First();
2537 if (IObject->hasEntry()) {
2538 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2540 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2541 if (!aSubMesh->_is_nil()) {
2543 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2544 // get submesh elements list by types
2545 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2546 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2547 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2548 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2549 // create group for each type o elements
2550 QString aName = IObject->getName();
2551 QStringList anEntryList;
2552 if (aNodes->length() > 0) {
2553 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2554 aGroup->Add(aNodes.inout());
2555 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2556 anEntryList.append( aSObject->GetID().c_str() );
2558 if (aEdges->length() > 0) {
2559 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2560 aGroup->Add(aEdges.inout());
2561 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2562 anEntryList.append( aSObject->GetID().c_str() );
2564 if (aFaces->length() > 0) {
2565 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2566 aGroup->Add(aFaces.inout());
2567 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2568 anEntryList.append( aSObject->GetID().c_str() );
2570 if (aVolumes->length() > 0) {
2571 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2572 aGroup->Add(aVolumes.inout());
2573 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2574 anEntryList.append( aSObject->GetID().c_str() );
2577 anApp->browseObjects( anEntryList );
2579 catch(const SALOME::SALOME_Exception & S_ex){
2580 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2587 SUIT_MessageBox::warning(desktop(),
2588 tr("SMESH_WRN_WARNING"),
2589 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2594 case 803: // EDIT GROUP
2598 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2599 tr( "NOT_A_VTK_VIEWER" ) );
2603 if(checkLock(aStudy)) break;
2604 EmitSignalDeactivateDialog();
2606 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2607 SALOME_ListIO selected;
2609 aSel->selectedObjects( selected );
2611 SALOME_ListIteratorOfListIO It (selected);
2612 int nbSelectedGroups = 0;
2613 for ( ; It.More(); It.Next() )
2615 SMESH::SMESH_GroupBase_var aGroup =
2616 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2617 if (!aGroup->_is_nil()) {
2619 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2623 if (nbSelectedGroups == 0)
2625 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2631 case 804: // Add elements to group
2633 if(checkLock(aStudy)) break;
2634 if (myState == 800) {
2635 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2636 if (aDlg) aDlg->onAdd();
2641 case 805: // Remove elements from group
2643 if(checkLock(aStudy)) break;
2644 if (myState == 800) {
2645 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2646 if (aDlg) aDlg->onRemove();
2651 case 815: // Edit GEOM GROUP as standalone
2655 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2656 tr( "NOT_A_VTK_VIEWER" ) );
2660 if(checkLock(aStudy)) break;
2661 EmitSignalDeactivateDialog();
2663 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2664 SALOME_ListIO selected;
2666 aSel->selectedObjects( selected );
2668 SALOME_ListIteratorOfListIO It (selected);
2669 for ( ; It.More(); It.Next() )
2671 SMESH::SMESH_GroupOnGeom_var aGroup =
2672 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2673 if (!aGroup->_is_nil()) {
2674 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2679 SMESH::SMESH_GroupOnFilter_var aGroup =
2680 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2681 if (!aGroup->_is_nil()) {
2682 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2690 case 810: // Union Groups
2691 case 811: // Intersect groups
2692 case 812: // Cut groups
2696 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2697 tr( "NOT_A_VTK_VIEWER" ) );
2701 if ( checkLock( aStudy ) )
2704 EmitSignalDeactivateDialog();
2706 SMESHGUI_GroupOpDlg* aDlg = 0;
2707 if ( theCommandID == 810 )
2708 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2709 else if ( theCommandID == 811 )
2710 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2712 aDlg = new SMESHGUI_CutGroupsDlg( this );
2719 case 814: // Create groups of entities from existing groups of superior dimensions
2721 if ( checkLock( aStudy ) )
2724 EmitSignalDeactivateDialog();
2725 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2731 case 813: // Delete groups with their contents
2735 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2736 tr( "NOT_A_VTK_VIEWER" ) );
2740 if ( checkLock( aStudy ) )
2743 EmitSignalDeactivateDialog();
2745 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2749 case 900: // MESH INFOS
2750 case 903: // WHAT IS
2752 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2753 EmitSignalDeactivateDialog();
2754 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2755 SALOME_ListIO selected;
2757 aSel->selectedObjects( selected );
2759 if ( selected.Extent() > 1 ) { // a dlg for each IO
2760 SALOME_ListIteratorOfListIO It( selected );
2761 for ( ; It.More(); It.Next() ) {
2762 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2763 dlg->showInfo( It.Value() );
2768 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2774 case 904: // FIND ELEM
2776 startOperation( theCommandID );
2780 case 1100: // EDIT HYPOTHESIS
2782 if(checkLock(aStudy)) break;
2784 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2785 SALOME_ListIO selected;
2787 aSel->selectedObjects( selected );
2789 int nbSel = selected.Extent();
2792 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2793 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2795 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2796 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2797 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2798 if ( !aHypothesis->_is_nil() )
2801 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2802 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2804 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2814 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2816 if(checkLock(aStudy)) break;
2817 SUIT_OverrideCursor wc;
2819 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2820 SALOME_ListIO selected;
2822 aSel->selectedObjects( selected, QString::null, false );
2824 SALOME_ListIteratorOfListIO It(selected);
2825 for (int i = 0; It.More(); It.Next(), i++) {
2826 Handle(SALOME_InteractiveObject) IObject = It.Value();
2827 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2830 aSel->setSelectedObjects( l1 );
2835 case 4009: // ELEM0D
2837 case 4021: // TRIANGLE
2839 case 4023: // POLYGON
2843 case 4134: // PYRAMID
2844 case 4135: // OCTA12
2846 if(checkLock(aStudy)) break;
2848 EmitSignalDeactivateDialog();
2849 SMDSAbs_EntityType type = SMDSEntity_Edge;
2850 switch (theCommandID) {
2852 type = SMDSEntity_0D; break;
2854 type = SMDSEntity_Triangle; break;
2856 type = SMDSEntity_Quadrangle; break;
2858 type = SMDSEntity_Tetra; break;
2860 type = SMDSEntity_Polygon; break;
2862 type = SMDSEntity_Hexa; break;
2864 type = SMDSEntity_Penta; break;
2866 type = SMDSEntity_Pyramid; break;
2868 type = SMDSEntity_Hexagonal_Prism; break;
2871 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
2874 SUIT_MessageBox::warning(desktop(),
2875 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2879 case 4033: // POLYHEDRON
2881 if(checkLock(aStudy)) break;
2883 EmitSignalDeactivateDialog();
2884 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2887 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2888 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2892 case 4034: // QUADRATIC EDGE
2893 case 4035: // QUADRATIC TRIANGLE
2894 case 4036: // QUADRATIC QUADRANGLE
2895 case 4136: // BIQUADRATIC QUADRANGLE
2896 case 4037: // QUADRATIC TETRAHEDRON
2897 case 4038: // QUADRATIC PYRAMID
2898 case 4039: // QUADRATIC PENTAHEDRON
2899 case 4040: // QUADRATIC HEXAHEDRON
2900 case 4140: // TRIQUADRATIC HEXAHEDRON
2902 if(checkLock(aStudy)) break;
2904 EmitSignalDeactivateDialog();
2905 SMDSAbs_EntityType type;
2907 switch (theCommandID) {
2909 type = SMDSEntity_Quad_Edge; break;
2911 type = SMDSEntity_Quad_Triangle; break;
2913 type = SMDSEntity_Quad_Quadrangle; break;
2915 type = SMDSEntity_BiQuad_Quadrangle; break;
2917 type = SMDSEntity_Quad_Tetra; break;
2919 type = SMDSEntity_Quad_Pyramid; break;
2921 type = SMDSEntity_Quad_Penta; break;
2923 type = SMDSEntity_Quad_Hexa;
2925 type = SMDSEntity_TriQuad_Hexa;
2929 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2932 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2933 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2937 case 4041: // REMOVES NODES
2939 if(checkLock(aStudy)) break;
2941 EmitSignalDeactivateDialog();
2942 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2945 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2946 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2950 case 4042: // REMOVES ELEMENTS
2952 if(checkLock(aStudy)) break;
2954 EmitSignalDeactivateDialog();
2955 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2959 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2960 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2964 case 4043: { // CLEAR_MESH
2966 if(checkLock(aStudy)) break;
2968 SALOME_ListIO selected;
2969 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2970 aSel->selectedObjects( selected );
2972 SUIT_OverrideCursor wc;
2973 SALOME_ListIteratorOfListIO It (selected);
2974 for ( ; It.More(); It.Next() )
2976 Handle(SALOME_InteractiveObject) IOS = It.Value();
2977 SMESH::SMESH_Mesh_var aMesh =
2978 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2979 if ( aMesh->_is_nil()) continue;
2981 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2983 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2984 SMESH::ModifiedMesh( aMeshSObj, false, true);
2985 // hide groups and submeshes
2986 _PTR(ChildIterator) anIter =
2987 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2988 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2990 _PTR(SObject) so = anIter->Value();
2991 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2994 catch (const SALOME::SALOME_Exception& S_ex){
2996 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3000 SMESH::UpdateView();
3004 case 4044: // REMOVE ORPHAN NODES
3006 if(checkLock(aStudy)) break;
3007 SALOME_ListIO selected;
3008 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3009 aSel->selectedObjects( selected );
3010 if ( selected.Extent() == 1 ) {
3011 Handle(SALOME_InteractiveObject) anIO = selected.First();
3012 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3013 if ( !aMesh->_is_nil() ) {
3014 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3015 tr( "SMESH_WARNING" ),
3016 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3017 SUIT_MessageBox::Yes |
3018 SUIT_MessageBox::No,
3019 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3022 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3023 int removed = aMeshEditor->RemoveOrphanNodes();
3024 SUIT_MessageBox::information(SMESHGUI::desktop(),
3025 tr("SMESH_INFORMATION"),
3026 tr("NB_NODES_REMOVED").arg(removed));
3027 if ( removed > 0 ) {
3028 SMESH::UpdateView();
3029 SMESHGUI::Modified();
3032 catch (const SALOME::SALOME_Exception& S_ex) {
3033 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3042 case 4051: // RENUMBERING NODES
3044 if(checkLock(aStudy)) break;
3046 EmitSignalDeactivateDialog();
3047 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3051 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3052 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3056 case 4052: // RENUMBERING ELEMENTS
3058 if(checkLock(aStudy)) break;
3060 EmitSignalDeactivateDialog();
3061 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3065 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3066 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3070 case 4061: // TRANSLATION
3072 if(checkLock(aStudy)) break;
3074 EmitSignalDeactivateDialog();
3075 ( new SMESHGUI_TranslationDlg( this ) )->show();
3078 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3079 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3083 case 4062: // ROTATION
3085 if(checkLock(aStudy)) break;
3087 EmitSignalDeactivateDialog();
3088 ( new SMESHGUI_RotationDlg( this ) )->show();
3091 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3092 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3096 case 4063: // SYMMETRY
3098 if(checkLock(aStudy)) break;
3100 EmitSignalDeactivateDialog();
3101 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3104 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3105 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3109 case 4064: // SEWING
3111 if(checkLock(aStudy)) break;
3113 EmitSignalDeactivateDialog();
3114 ( new SMESHGUI_SewingDlg( this ) )->show();
3117 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3118 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3122 case 4065: // MERGE NODES
3124 if(checkLock(aStudy)) break;
3126 EmitSignalDeactivateDialog();
3127 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3130 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3131 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3135 case 4066: // MERGE EQUAL ELEMENTS
3137 if (checkLock(aStudy)) break;
3139 EmitSignalDeactivateDialog();
3140 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3142 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3143 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3148 case 4067: // MAKE MESH PASS THROUGH POINT
3149 startOperation( 4067 );
3154 if(checkLock(aStudy)) break;
3156 EmitSignalDeactivateDialog();
3157 ( new SMESHGUI_ScaleDlg( this ) )->show();
3160 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3161 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3166 case 4069: // DUPLICATE NODES
3168 if(checkLock(aStudy)) break;
3170 EmitSignalDeactivateDialog();
3171 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3174 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3175 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3180 case 5105: // Library of selection filters
3182 static QList<int> aTypes;
3183 if ( aTypes.isEmpty() )
3185 aTypes.append( SMESH::NODE );
3186 aTypes.append( SMESH::EDGE );
3187 aTypes.append( SMESH::FACE );
3188 aTypes.append( SMESH::VOLUME );
3190 if (!myFilterLibraryDlg)
3191 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3192 else if (myFilterLibraryDlg->isHidden())
3193 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3194 myFilterLibraryDlg->raise();
3198 case 6017: // CONTROLS
3226 LightApp_SelectionMgr* mgr = selectionMgr();
3227 SALOME_ListIO selected; mgr->selectedObjects( selected );
3229 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3230 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3232 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3233 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3234 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3235 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3236 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3237 ::Control( theCommandID );
3242 SUIT_MessageBox::warning(desktop(),
3243 tr( "SMESH_WRN_WARNING" ),
3244 tr( "SMESH_BAD_SELECTION" ) );
3248 SUIT_MessageBox::warning(desktop(),
3249 tr( "SMESH_WRN_WARNING" ),
3250 tr( "NOT_A_VTK_VIEWER" ) );
3255 LightApp_SelectionMgr* mgr = selectionMgr();
3256 SALOME_ListIO selected; mgr->selectedObjects( selected );
3258 SALOME_ListIteratorOfListIO it(selected);
3259 for( ; it.More(); it.Next()) {
3260 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3261 if(anIObject->hasEntry()) {
3262 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3263 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3271 LightApp_SelectionMgr* mgr = selectionMgr();
3272 SALOME_ListIO selected; mgr->selectedObjects( selected );
3274 SALOME_ListIteratorOfListIO it(selected);
3275 for( ; it.More(); it.Next()) {
3276 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3277 if(anIObject->hasEntry())
3278 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3279 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3287 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3288 EmitSignalDeactivateDialog();
3289 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3295 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3296 //updateObjBrowser();
3300 //=============================================================================
3304 //=============================================================================
3305 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3310 //=============================================================================
3314 //=============================================================================
3315 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3320 //=============================================================================
3324 //=============================================================================
3325 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3330 //=============================================================================
3331 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3332 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3334 //=============================================================================
3335 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3336 SUIT_ViewWindow* wnd )
3338 if(theIO->hasEntry()){
3339 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3340 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3344 //=======================================================================
3345 // function : createSMESHAction
3347 //=======================================================================
3348 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3349 const int key, const bool toggle, const QString& shortcutAction )
3352 QWidget* parent = application()->desktop();
3353 SUIT_ResourceMgr* resMgr = resourceMgr();
3355 if ( !icon_id.isEmpty() )
3356 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3358 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3359 if ( !pix.isNull() )
3360 icon = QIcon( pix );
3362 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3363 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3364 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3366 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3367 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3370 //=======================================================================
3371 // function : createPopupItem
3373 //=======================================================================
3374 void SMESHGUI::createPopupItem( const int id,
3375 const QString& clients,
3376 const QString& types,
3377 const QString& theRule,
3382 parentId = popupMgr()->actionId( action( pId ) );
3384 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3385 popupMgr()->insert( action( id ), parentId, 0 );
3387 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3388 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3389 QString rule = "(%1) and (%2) and (%3)";
3390 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3391 if( clients.isEmpty() )
3392 rule = rule.arg( QString( "true" ) );
3394 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3395 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3398 bool cont = myRules.contains( id );
3400 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3402 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3403 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3406 //=======================================================================
3407 // function : initialize
3409 //=======================================================================
3410 void SMESHGUI::initialize( CAM_Application* app )
3412 SalomeApp_Module::initialize( app );
3414 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3416 /* Automatic Update flag */
3417 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3419 // ----- create actions --------------
3421 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3422 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3423 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3424 createSMESHAction( 114, "NUM" );
3425 createSMESHAction( 115, "STL" );
3426 createSMESHAction( 116, "CGNS" );
3427 createSMESHAction( 117, "SAUV" );
3428 createSMESHAction( 121, "DAT" );
3429 createSMESHAction( 122, "MED" );
3430 createSMESHAction( 123, "UNV" );
3431 createSMESHAction( 140, "STL" );
3432 createSMESHAction( 142, "CGNS" );
3433 createSMESHAction( 144, "SAUV" );
3434 createSMESHAction( 124, "EXPORT_DAT" );
3435 createSMESHAction( 125, "EXPORT_MED" );
3436 createSMESHAction( 126, "EXPORT_UNV" );
3437 createSMESHAction( 141, "EXPORT_STL" );
3438 createSMESHAction( 143, "EXPORT_CGNS" );
3439 createSMESHAction( 145, "EXPORT_SAUV" );
3440 createSMESHAction( 150, "FILE_INFO" );
3441 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3442 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3443 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3444 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3445 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3446 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3447 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3448 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3449 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3450 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3451 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3452 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3453 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3454 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3455 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3456 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3457 createSMESHAction( 804, "ADD" );
3458 createSMESHAction( 805, "REMOVE" );
3459 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3460 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3461 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3462 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3463 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3464 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3465 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3466 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3467 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3468 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3469 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3470 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3471 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3472 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3473 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3474 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3475 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3476 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3477 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3478 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3479 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3480 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3481 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3482 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3483 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3484 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3485 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3486 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3487 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3488 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3489 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3490 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3491 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3492 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3493 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3494 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3495 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3496 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3497 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3498 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3499 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3500 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3501 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3502 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3503 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3504 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3505 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3506 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3507 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3508 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3509 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3510 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3511 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3512 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3513 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3514 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3515 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3516 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3517 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3518 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3519 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3520 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3521 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3522 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3523 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3524 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3525 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3526 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3527 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3528 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3529 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3530 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3531 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3532 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3533 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3534 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3535 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3536 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3537 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3538 createSMESHAction( 415, "MAP", "ICON_MAP" );
3539 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3540 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3541 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3542 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3543 createSMESHAction( 200, "RESET" );
3544 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3545 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3546 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3547 #ifndef DISABLE_PLOT2DVIEWER
3548 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3550 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3551 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3552 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3553 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3554 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3555 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3556 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3557 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3558 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3559 createSMESHAction( 220, "ALL" );
3560 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3562 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3563 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3565 createSMESHAction( 1100, "EDIT_HYPO" );
3566 createSMESHAction( 1102, "UNASSIGN" );
3567 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3568 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3569 createSMESHAction( 1131, "DISPMODE" );
3570 createSMESHAction( 1132, "COLORS" );
3571 createSMESHAction( 1133, "TRANSP" );
3572 createSMESHAction( 1134, "CLIP" );
3573 createSMESHAction( 1135, "DISP_ENT" );
3574 createSMESHAction( 1136, "AUTO_COLOR" );
3575 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3576 createSMESHAction( 2000, "CTRL" );
3578 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3579 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3581 createSMESHAction( 300, "ERASE" );
3582 createSMESHAction( 301, "DISPLAY" );
3583 createSMESHAction( 302, "DISPLAY_ONLY" );
3585 // ----- create menu --------------
3586 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3587 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3588 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3589 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3590 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3591 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3592 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3593 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3595 createMenu( separator(), fileId );
3597 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3598 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3599 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3600 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3601 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3602 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3603 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3604 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3605 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3606 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3608 createMenu( 111, importId, -1 );
3609 createMenu( 112, importId, -1 );
3610 createMenu( 113, importId, -1 );
3611 createMenu( 115, importId, -1 );
3613 createMenu( 116, importId, -1 );
3615 createMenu( 117, importId, -1 );
3616 createMenu( 121, exportId, -1 );
3617 createMenu( 122, exportId, -1 );
3618 createMenu( 123, exportId, -1 );
3619 createMenu( 140, exportId, -1 ); // export to STL
3621 createMenu( 142, exportId, -1 ); // export to CGNS
3623 createMenu( 144, exportId, -1 ); // export to SAUV
3624 createMenu( separator(), fileId, 10 );
3626 createMenu( 33, editId, -1 );
3628 createMenu( 5105, toolsId, -1 );
3630 createMenu( 702, meshId, -1 ); // "Mesh" menu
3631 createMenu( 703, meshId, -1 );
3632 createMenu( 704, meshId, -1 );
3633 createMenu( 710, meshId, -1 );
3634 createMenu( 705, meshId, -1 );
3635 createMenu( separator(), meshId, -1 );
3636 createMenu( 701, meshId, -1 );
3637 createMenu( 711, meshId, -1 );
3638 createMenu( 712, meshId, -1 );
3639 createMenu( 713, meshId, -1 );
3640 createMenu( separator(), meshId, -1 );
3641 createMenu( 801, meshId, -1 );
3642 createMenu( 806, meshId, -1 );
3643 createMenu( 802, meshId, -1 );
3644 createMenu( 803, meshId, -1 );
3645 createMenu( 815, meshId, -1 );
3646 createMenu( separator(), meshId, -1 );
3647 createMenu( 810, meshId, -1 );
3648 createMenu( 811, meshId, -1 );
3649 createMenu( 812, meshId, -1 );
3650 createMenu( separator(), meshId, -1 );
3651 createMenu( 814, meshId, -1 );
3652 createMenu( separator(), meshId, -1 );
3653 createMenu( 900, meshId, -1 );
3654 //createMenu( 902, meshId, -1 );
3655 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3656 createMenu( 904, meshId, -1 );
3657 createMenu( separator(), meshId, -1 );
3659 createMenu( 6005, nodeId, -1 );
3660 createMenu( 6028, nodeId, -1 );
3661 createMenu( 6002, edgeId, -1 );
3662 createMenu( 6003, edgeId, -1 );
3663 createMenu( 6001, edgeId, -1 );
3664 createMenu( 6004, edgeId, -1 );
3665 createMenu( 6029, edgeId, -1 );
3666 createMenu( 6021, faceId, -1 );
3667 createMenu( 6025, faceId, -1 );
3668 createMenu( 6027, faceId, -1 );
3669 createMenu( 6018, faceId, -1 );
3670 createMenu( 6019, faceId, -1 );
3671 createMenu( 6011, faceId, -1 );
3672 createMenu( 6012, faceId, -1 );
3673 createMenu( 6013, faceId, -1 );
3674 createMenu( 6014, faceId, -1 );
3675 createMenu( 6015, faceId, -1 );
3676 createMenu( 6016, faceId, -1 );
3677 createMenu( 6022, faceId, -1 );
3678 createMenu( 6030, faceId, -1 );
3679 createMenu( 6017, volumeId, -1 );
3680 createMenu( 6009, volumeId, -1 );
3681 createMenu( 6023, volumeId, -1 );
3682 createMenu( 6024, volumeId, -1 );
3683 createMenu( 6026, volumeId, -1 );
3684 createMenu( 6031, volumeId, -1 );
3686 createMenu( 4000, addId, -1 );
3687 createMenu( 4009, addId, -1 );
3688 createMenu( 4010, addId, -1 );
3689 createMenu( 4021, addId, -1 );
3690 createMenu( 4022, addId, -1 );
3691 createMenu( 4023, addId, -1 );
3692 createMenu( 4031, addId, -1 );
3693 createMenu( 4032, addId, -1 );
3694 createMenu( 4133, addId, -1 );
3695 createMenu( 4134, addId, -1 );
3696 createMenu( 4135, addId, -1 );
3697 createMenu( 4033, addId, -1 );
3698 createMenu( separator(), addId, -1 );
3699 createMenu( 4034, addId, -1 );
3700 createMenu( 4035, addId, -1 );
3701 createMenu( 4036, addId, -1 );
3702 createMenu( 4136, addId, -1 );
3703 createMenu( 4037, addId, -1 );
3704 createMenu( 4038, addId, -1 );
3705 createMenu( 4039, addId, -1 );
3706 createMenu( 4040, addId, -1 );
3707 createMenu( 4140, addId, -1 );
3709 createMenu( 4041, removeId, -1 );
3710 createMenu( 4042, removeId, -1 );
3711 createMenu( 4044, removeId, -1 );
3712 createMenu( separator(), removeId, -1 );
3713 createMenu( 813, removeId, -1 );
3714 createMenu( separator(), removeId, -1 );
3715 createMenu( 4043, removeId, -1 );
3717 createMenu( 4051, renumId, -1 );
3718 createMenu( 4052, renumId, -1 );
3720 createMenu( 4061, transfId, -1 );
3721 createMenu( 4062, transfId, -1 );
3722 createMenu( 4063, transfId, -1 );
3723 createMenu( 4068, transfId, -1 );
3724 createMenu( 4064, transfId, -1 );
3725 createMenu( 4065, transfId, -1 );
3726 createMenu( 4066, transfId, -1 );
3727 createMenu( 4069, transfId, -1 );
3729 createMenu( 4067,modifyId, -1 );
3730 createMenu( 407, modifyId, -1 );
3731 createMenu( 408, modifyId, -1 );
3732 createMenu( 409, modifyId, -1 );
3733 createMenu( 410, modifyId, -1 );
3734 createMenu( 411, modifyId, -1 );
3735 createMenu( 419, modifyId, -1 );
3736 createMenu( 412, modifyId, -1 );
3737 createMenu( 413, modifyId, -1 );
3738 createMenu( 416, modifyId, -1 );
3739 createMenu( 414, modifyId, -1 );
3740 createMenu( 415, modifyId, -1 );
3741 createMenu( 417, modifyId, -1 );
3742 createMenu( 418, modifyId, -1 );
3744 createMenu( 501, measureId, -1 );
3745 createMenu( 502, measureId, -1 );
3746 createMenu( 214, viewId, -1 );
3748 // ----- create toolbars --------------
3749 int meshTb = createTool( tr( "TB_MESH" ) ),
3750 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3751 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3752 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3753 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3755 createTool( 702, meshTb );
3756 createTool( 703, meshTb );
3757 createTool( 704, meshTb );
3758 createTool( 710, meshTb );
3759 createTool( 705, meshTb );
3760 createTool( separator(), meshTb );
3761 createTool( 701, meshTb );
3762 createTool( 711, meshTb );
3763 createTool( 712, meshTb );
3764 createTool( 713, meshTb );
3765 createTool( separator(), meshTb );
3766 createTool( 801, meshTb );
3767 createTool( 806, meshTb );
3768 createTool( 802, meshTb );
3769 createTool( 803, meshTb );
3770 //createTool( 815, meshTb );
3771 createTool( separator(), meshTb );
3772 createTool( 900, meshTb );
3773 //createTool( 902, meshTb );
3774 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3775 createTool( 904, meshTb );
3776 createTool( separator(), meshTb );
3778 createTool( 6005, ctrlTb );
3779 createTool( 6028, ctrlTb );
3780 createTool( separator(), ctrlTb );
3781 createTool( 6002, ctrlTb );
3782 createTool( 6003, ctrlTb );
3783 createTool( 6001, ctrlTb );
3784 createTool( 6004, ctrlTb );
3785 createTool( 6029, ctrlTb );
3786 createTool( separator(), ctrlTb );
3787 createTool( 6021, ctrlTb );
3788 createTool( 6025, ctrlTb );
3789 createTool( 6027, ctrlTb );
3790 createTool( 6018, ctrlTb );
3791 createTool( 6019, ctrlTb );
3792 createTool( 6011, ctrlTb );
3793 createTool( 6012, ctrlTb );
3794 createTool( 6013, ctrlTb );
3795 createTool( 6014, ctrlTb );
3796 createTool( 6015, ctrlTb );
3797 createTool( 6016, ctrlTb );
3798 createTool( 6022, ctrlTb );
3799 createTool( 6030, ctrlTb );
3800 createTool( separator(), ctrlTb );
3801 createTool( 6017, ctrlTb );
3802 createTool( 6009, ctrlTb );
3803 createTool( 6023, ctrlTb );
3804 createTool( 6024, ctrlTb );
3805 createTool( 6026, ctrlTb );
3806 createTool( 6031, ctrlTb );
3807 createTool( separator(), ctrlTb );
3809 createTool( 4000, addRemTb );
3810 createTool( 4009, addRemTb );
3811 createTool( 4010, addRemTb );
3812 createTool( 4021, addRemTb );
3813 createTool( 4022, addRemTb );
3814 createTool( 4023, addRemTb );
3815 createTool( 4031, addRemTb );
3816 createTool( 4032, addRemTb );
3817 createTool( 4133, addRemTb );
3818 createTool( 4134, addRemTb );
3819 createTool( 4135, addRemTb );
3820 createTool( 4033, addRemTb );
3821 createTool( separator(), addRemTb );
3822 createTool( 4034, addRemTb );
3823 createTool( 4035, addRemTb );
3824 createTool( 4036, addRemTb );
3825 createTool( 4136, addRemTb );
3826 createTool( 4037, addRemTb );
3827 createTool( 4038, addRemTb );
3828 createTool( 4039, addRemTb );
3829 createTool( 4040, addRemTb );
3830 createTool( 4140, addRemTb );
3831 createTool( separator(), addRemTb );
3832 createTool( 4041, addRemTb );
3833 createTool( 4042, addRemTb );
3834 createTool( 4044, addRemTb );
3835 createTool( 4043, addRemTb );
3836 createTool( separator(), addRemTb );
3837 createTool( 4051, addRemTb );
3838 createTool( 4052, addRemTb );
3839 createTool( separator(), addRemTb );
3840 createTool( 4061, addRemTb );
3841 createTool( 4062, addRemTb );
3842 createTool( 4063, addRemTb );
3843 createTool( 4068, addRemTb );
3844 createTool( 4064, addRemTb );
3845 createTool( 4065, addRemTb );
3846 createTool( 4066, addRemTb );
3847 createTool( 4069, addRemTb );
3848 createTool( separator(), addRemTb );
3850 createTool( 4067,modifyTb );
3851 createTool( 407, modifyTb );
3852 createTool( 408, modifyTb );
3853 createTool( 409, modifyTb );
3854 createTool( 410, modifyTb );
3855 createTool( 411, modifyTb );
3856 createTool( 419, modifyTb );
3857 createTool( 412, modifyTb );
3858 createTool( 413, modifyTb );
3859 createTool( 416, modifyTb );
3860 createTool( 414, modifyTb );
3861 createTool( 415, modifyTb );
3862 createTool( 417, modifyTb );
3863 createTool( 418, modifyTb );
3865 createTool( 214, dispModeTb );
3867 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3868 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3871 QString OB = "'ObjectBrowser'",
3872 View = "'" + SVTK_Viewer::Type() + "'",
3874 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3875 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3876 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3877 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3878 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3879 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3880 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3881 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3882 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3883 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3884 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3886 mesh_part = mesh + " " + subMesh + " " + group,
3887 mesh_group = mesh + " " + group,
3888 hyp_alg = hypo + " " + algo;
3890 // popup for object browser
3892 isInvisible("not( isVisible )"),
3893 isEmpty("numberOfNodes = 0"),
3894 isNotEmpty("numberOfNodes <> 0"),
3896 // has nodes, edges, etc in VISIBLE! actor
3897 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3898 hasElems("(count( elemTypes ) > 0)"),
3899 hasDifferentElems("(count( elemTypes ) > 1)"),
3900 hasElems0d("({'Elem0d'} in elemTypes)"),
3901 hasEdges("({'Edge'} in elemTypes)"),
3902 hasFaces("({'Face'} in elemTypes)"),
3903 hasVolumes("({'Volume'} in elemTypes)");
3905 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3906 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3907 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3908 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3909 createPopupItem( 803, OB, group ); // EDIT_GROUP
3910 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3912 popupMgr()->insert( separator(), -1, 0 );
3913 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3914 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3915 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3916 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3917 createPopupItem( 214, OB, mesh_part ); // UPDATE
3918 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3919 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3920 popupMgr()->insert( separator(), -1, 0 );
3921 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3922 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3923 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3924 popupMgr()->insert( separator(), -1, 0 );
3925 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3926 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3927 popupMgr()->insert( separator(), -1, 0 );
3928 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3929 popupMgr()->insert( separator(), -1, 0 );
3930 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3931 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3933 popupMgr()->insert( separator(), -1, 0 );
3935 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3936 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3937 QString only_one_2D = only_one_non_empty + " && dim>1";
3939 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3940 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3941 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3943 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3945 createPopupItem( 145, OB, mesh_group, multiple_non_empty ); // EXPORT_SAUV
3946 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3947 popupMgr()->insert( separator(), -1, 0 );
3950 createPopupItem( 803, View, group ); // EDIT_GROUP
3951 createPopupItem( 804, View, elems ); // ADD
3952 createPopupItem( 805, View, elems ); // REMOVE
3954 popupMgr()->insert( separator(), -1, 0 );
3955 createPopupItem( 214, View, mesh_part ); // UPDATE
3956 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3957 createPopupItem( 904, View, mesh ); // FIND_ELEM
3958 popupMgr()->insert( separator(), -1, 0 );
3960 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3961 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3962 popupMgr()->insert( separator(), -1, 0 );
3965 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3966 QString aType = QString( "%1type in {%2}" ).arg( lc );
3967 aType = aType.arg( mesh_part );
3968 QString aMeshInVTK = aClient + "&&" + aType;
3970 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3971 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3972 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3974 //-------------------------------------------------
3976 //-------------------------------------------------
3977 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3979 popupMgr()->insert( action( 9010 ), anId, -1 );
3980 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3981 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3983 popupMgr()->insert( action( 9011 ), anId, -1 );
3984 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3985 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3987 popupMgr()->insert( separator(), -1, -1 );
3989 //-------------------------------------------------
3991 //-------------------------------------------------
3992 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3994 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3995 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3996 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3998 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3999 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4000 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4002 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4003 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4004 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4006 popupMgr()->insert( separator(), anId, -1 );
4008 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4009 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4010 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4012 //-------------------------------------------------
4014 //-------------------------------------------------
4015 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4017 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4019 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4020 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4021 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4023 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4024 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4025 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4027 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4028 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4029 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4031 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4032 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4033 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4035 popupMgr()->insert( separator(), anId, -1 );
4037 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4038 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4041 //-------------------------------------------------
4042 // Representation of the 2D Quadratic elements
4043 //-------------------------------------------------
4044 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4045 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4046 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4047 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4049 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4050 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4051 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4053 //-------------------------------------------------
4054 // Orientation of faces
4055 //-------------------------------------------------
4056 popupMgr()->insert( action( 221 ), -1, -1 );
4057 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4058 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4060 //-------------------------------------------------
4062 //-------------------------------------------------
4063 popupMgr()->insert( action( 1132 ), -1, -1 );
4064 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4066 //-------------------------------------------------
4068 //-------------------------------------------------
4069 popupMgr()->insert( action( 1133 ), -1, -1 );
4070 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4072 //-------------------------------------------------
4074 //-------------------------------------------------
4076 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4077 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4078 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4079 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4081 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4083 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4084 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4086 popupMgr()->insert( separator(), anId, -1 );
4088 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4090 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4091 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4092 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4094 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4095 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4096 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4098 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4100 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4101 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4102 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4104 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4105 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4106 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4108 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4109 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4110 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4112 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4113 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4114 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4115 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4116 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4117 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4119 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4121 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4122 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4123 QtxPopupMgr::VisibleRule );
4124 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4126 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4127 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4128 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4130 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4131 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4132 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4134 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4135 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4136 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4138 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4139 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4140 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4142 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4143 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4144 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4146 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4147 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4148 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4150 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4151 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4152 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4154 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4155 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4156 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4158 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4159 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4160 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4162 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4163 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4164 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4166 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4167 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4168 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4169 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4170 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4171 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4173 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4175 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4176 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4177 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4179 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4180 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4181 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4183 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4184 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4185 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4187 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4188 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4189 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4191 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4192 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4193 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4195 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4196 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4197 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4199 popupMgr()->insert( separator(), anId, -1 );
4201 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4202 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4204 popupMgr()->insert( separator(), anId, -1 );
4206 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4208 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4209 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4211 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4212 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4213 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4215 #ifndef DISABLE_PLOT2DVIEWER
4216 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4217 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4220 //-------------------------------------------------
4222 //-------------------------------------------------
4223 popupMgr()->insert( separator(), -1, -1 );
4224 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4225 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4226 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4227 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4229 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4230 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4232 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4233 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4235 popupMgr()->insert( separator(), -1, -1 );
4237 //-------------------------------------------------
4239 //-------------------------------------------------
4240 popupMgr()->insert( action( 1134 ), -1, -1 );
4241 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4243 popupMgr()->insert( separator(), -1, -1 );
4245 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4246 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4248 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4249 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4252 //================================================================================
4254 * \brief Return true if SMESH or GEOM objects are selected.
4255 * Is called form LightApp_Module::activateModule() which clear selection if
4256 * not isSelectionCompatible()
4258 //================================================================================
4260 bool SMESHGUI::isSelectionCompatible()
4262 bool isCompatible = true;
4263 SALOME_ListIO selected;
4264 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4265 Sel->selectedObjects( selected );
4267 SALOME_ListIteratorOfListIO It( selected );
4268 for ( ; isCompatible && It.More(); It.Next())
4270 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4271 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4273 return isCompatible;
4277 bool SMESHGUI::reusableOperation( const int id )
4279 // compute, evaluate and precompute are not reusable operations
4280 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4283 bool SMESHGUI::activateModule( SUIT_Study* study )
4285 bool res = SalomeApp_Module::activateModule( study );
4287 setMenuShown( true );
4288 setToolShown( true );
4290 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4291 PyGILState_STATE gstate = PyGILState_Ensure();
4292 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4293 if(pluginsmanager==NULL)
4297 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4302 PyGILState_Release(gstate);
4303 // end of GEOM plugins loading
4305 // Reset actions accelerator keys
4306 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4307 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4308 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4310 action( 33)->setEnabled(true); // Delete: Key_Delete
4312 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4313 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4314 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4315 if ( _PTR(Study) aStudy = s->studyDS()) {
4316 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4317 updateObjBrowser(); // objects can be removed
4320 // get all view currently opened in the study and connect their signals to
4321 // the corresponding slots of the class.
4322 SUIT_Desktop* aDesk = study->application()->desktop();
4324 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4325 SUIT_ViewWindow* wnd;
4326 foreach ( wnd, wndList )
4333 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4335 setMenuShown( false );
4336 setToolShown( false );
4338 EmitSignalCloseAllDialogs();
4340 // Unset actions accelerator keys
4341 action(111)->setShortcut(QKeySequence()); // Import DAT
4342 action(112)->setShortcut(QKeySequence()); // Import UNV
4343 action(113)->setShortcut(QKeySequence()); // Import MED
4345 action( 33)->setEnabled(false); // Delete: Key_Delete
4347 return SalomeApp_Module::deactivateModule( study );
4350 void SMESHGUI::studyClosed( SUIT_Study* s )
4352 SMESH::RemoveVisuData( s->id() );
4353 SalomeApp_Module::studyClosed( s );
4356 void SMESHGUI::OnGUIEvent()
4358 const QObject* obj = sender();
4359 if ( !obj || !obj->inherits( "QAction" ) )
4361 int id = actionId((QAction*)obj);
4366 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4368 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4369 if ( CORBA::is_nil( myComponentSMESH ) )
4371 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4373 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4374 return aGUI.myComponentSMESH;
4377 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4378 return myComponentSMESH;
4381 QString SMESHGUI::engineIOR() const
4383 CORBA::ORB_var anORB = getApp()->orb();
4384 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4385 return QString( anIOR.in() );
4388 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4390 SalomeApp_Module::contextMenuPopup( client, menu, title );
4392 selectionMgr()->selectedObjects( lst );
4393 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4394 Handle(SALOME_InteractiveObject) io = lst.First();
4395 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4396 _PTR(Study) study = appStudy->studyDS();
4397 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4399 QString aName = QString( obj->GetName().c_str() );
4400 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4401 aName.remove( (aName.length() - 1), 1 );
4407 LightApp_Selection* SMESHGUI::createSelection() const
4409 return new SMESHGUI_Selection();
4412 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4414 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4415 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4418 void SMESHGUI::viewManagers( QStringList& list ) const
4420 list.append( SVTK_Viewer::Type() );
4423 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4425 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4426 SMESH::UpdateSelectionProp( this );
4428 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4429 for(int i = 0; i < aViews.count() ; i++){
4430 SUIT_ViewWindow *sf = aViews[i];
4436 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4438 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4439 myClippingPlaneInfoMap.erase( theViewManager );
4442 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4444 theActor->AddObserver( SMESH::DeleteActorEvent,
4445 myEventCallbackCommand.GetPointer(),
4449 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4450 unsigned long theEvent,
4451 void* theClientData,
4454 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4455 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4456 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4457 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4458 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4459 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4460 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4461 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4462 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4463 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4464 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4465 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4466 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4467 if( anActor == *anIter3 ) {
4468 anActorList.erase( anIter3 );
4479 void SMESHGUI::createPreferences()
4481 // General tab ------------------------------------------------------------------------
4482 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4484 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4485 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4486 setPreferenceProperty( lim, "min", 0 );
4487 setPreferenceProperty( lim, "max", 100000000 );
4488 setPreferenceProperty( lim, "step", 1000 );
4489 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4491 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4492 setPreferenceProperty( qaGroup, "columns", 2 );
4493 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4494 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4495 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4496 setPreferenceProperty( prec, "min", 0 );
4497 setPreferenceProperty( prec, "max", 16 );
4498 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4499 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4500 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4501 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4502 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4504 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4505 setPreferenceProperty( dispgroup, "columns", 2 );
4506 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4508 modes.append( tr("MEN_WIRE") );
4509 modes.append( tr("MEN_SHADE") );
4510 modes.append( tr("MEN_NODES") );
4511 modes.append( tr("MEN_SHRINK") );
4512 QList<QVariant> indices;
4513 indices.append( 0 );
4514 indices.append( 1 );
4515 indices.append( 2 );
4516 indices.append( 3 );
4517 setPreferenceProperty( dispmode, "strings", modes );
4518 setPreferenceProperty( dispmode, "indexes", indices );
4520 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4521 setPreferenceProperty( arcgroup, "columns", 2 );
4522 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4523 QStringList quadraticModes;
4524 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4525 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4527 indices.append( 0 );
4528 indices.append( 1 );
4529 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4530 setPreferenceProperty( quadraticmode, "indexes", indices );
4532 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4533 "SMESH", "max_angle" );
4534 setPreferenceProperty( maxAngle, "min", 1 );
4535 setPreferenceProperty( maxAngle, "max", 90 );
4539 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4540 setPreferenceProperty( exportgroup, "columns", 2 );
4541 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4542 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4544 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4545 setPreferenceProperty( computeGroup, "columns", 2 );
4546 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4548 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4549 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4550 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4552 indices.append( 0 );
4553 indices.append( 1 );
4554 indices.append( 2 );
4555 setPreferenceProperty( notifyMode, "strings", modes );
4556 setPreferenceProperty( notifyMode, "indexes", indices );
4558 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4559 setPreferenceProperty( infoGroup, "columns", 4 );
4560 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4562 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4563 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4565 indices.append( 0 );
4566 indices.append( 1 );
4567 setPreferenceProperty( elemInfo, "strings", modes );
4568 setPreferenceProperty( elemInfo, "indexes", indices );
4569 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4570 setPreferenceProperty( nodesLim, "min", 0 );
4571 setPreferenceProperty( nodesLim, "max", 10000000 );
4572 setPreferenceProperty( nodesLim, "step", 10000 );
4573 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4575 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4576 setPreferenceProperty( segGroup, "columns", 2 );
4577 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4578 "SMESH", "segmentation" );
4579 setPreferenceProperty( segLen, "min", 1 );
4580 setPreferenceProperty( segLen, "max", 10000000 );
4581 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4582 "SMESH", "nb_segments_per_edge" );
4583 setPreferenceProperty( nbSeg, "min", 1 );
4584 setPreferenceProperty( nbSeg, "max", 10000000 );
4586 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4587 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4588 "SMESH", "forget_mesh_on_hyp_modif" );
4591 // Quantities with individual precision settings
4592 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4593 setPreferenceProperty( precGroup, "columns", 2 );
4595 const int nbQuantities = 6;
4596 int precs[nbQuantities], ii = 0;
4597 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4598 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4599 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4600 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4601 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4602 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4603 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4604 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4605 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4606 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4607 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4608 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4610 // Set property for precision value for spinboxes
4611 for ( ii = 0; ii < nbQuantities; ii++ ){
4612 setPreferenceProperty( precs[ii], "min", -14 );
4613 setPreferenceProperty( precs[ii], "max", 14 );
4614 setPreferenceProperty( precs[ii], "precision", 2 );
4617 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4618 setPreferenceProperty( previewGroup, "columns", 2 );
4619 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4620 setPreferenceProperty( chunkSize, "min", 0 );
4621 setPreferenceProperty( chunkSize, "max", 1000 );
4622 setPreferenceProperty( chunkSize, "step", 50 );
4624 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4625 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4627 // Mesh tab ------------------------------------------------------------------------
4628 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4629 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4630 setPreferenceProperty( nodeGroup, "columns", 3 );
4632 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4634 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4636 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4637 QList<QVariant> aMarkerTypeIndicesList;
4638 QList<QVariant> aMarkerTypeIconsList;
4639 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4640 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4641 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4642 aMarkerTypeIndicesList << i;
4643 aMarkerTypeIconsList << pixmap;
4645 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4646 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4648 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4650 QList<QVariant> aMarkerScaleIndicesList;
4651 QStringList aMarkerScaleValuesList;
4652 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4653 aMarkerScaleIndicesList << i;
4654 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4656 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4657 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4659 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4660 setPreferenceProperty( elemGroup, "columns", 2 );
4662 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4663 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4665 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4666 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4668 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4670 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4671 setPreferenceProperty( grpGroup, "columns", 2 );
4673 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4675 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4676 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4677 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4678 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4679 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4680 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4682 setPreferenceProperty( size0d, "min", 1 );
4683 setPreferenceProperty( size0d, "max", 10 );
4685 setPreferenceProperty( elemW, "min", 1 );
4686 setPreferenceProperty( elemW, "max", 5 );
4688 setPreferenceProperty( shrink, "min", 0 );
4689 setPreferenceProperty( shrink, "max", 100 );
4691 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4692 setPreferenceProperty( orientGroup, "columns", 1 );
4694 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4695 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4697 setPreferenceProperty( orientScale, "min", 0.05 );
4698 setPreferenceProperty( orientScale, "max", 0.5 );
4699 setPreferenceProperty( orientScale, "step", 0.05 );
4701 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4703 // Selection tab ------------------------------------------------------------------------
4704 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4706 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4707 setPreferenceProperty( selGroup, "columns", 2 );
4709 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4710 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4712 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4713 setPreferenceProperty( preGroup, "columns", 2 );
4715 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4717 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4718 setPreferenceProperty( precSelGroup, "columns", 2 );
4720 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4721 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4722 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4724 // Scalar Bar tab ------------------------------------------------------------------------
4725 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4726 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4727 setPreferenceProperty( fontGr, "columns", 2 );
4729 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4730 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4732 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4733 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4735 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4736 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4738 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4739 setPreferenceProperty( numcol, "min", 2 );
4740 setPreferenceProperty( numcol, "max", 256 );
4742 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4743 setPreferenceProperty( numlab, "min", 2 );
4744 setPreferenceProperty( numlab, "max", 65 );
4746 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4747 setPreferenceProperty( orientGr, "columns", 2 );
4748 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4749 QStringList orients;
4750 orients.append( tr( "SMESH_VERTICAL" ) );
4751 orients.append( tr( "SMESH_HORIZONTAL" ) );
4752 indices.clear(); indices.append( 0 ); indices.append( 1 );
4753 setPreferenceProperty( orient, "strings", orients );
4754 setPreferenceProperty( orient, "indexes", indices );
4756 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4757 setPreferenceProperty( posVSizeGr, "columns", 2 );
4758 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4759 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4760 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4761 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4762 setPreferenceProperty( xv, "step", 0.1 );
4763 setPreferenceProperty( xv, "min", 0.0 );
4764 setPreferenceProperty( xv, "max", 1.0 );
4765 setPreferenceProperty( yv, "step", 0.1 );
4766 setPreferenceProperty( yv, "min", 0.0 );
4767 setPreferenceProperty( yv, "max", 1.0 );
4768 setPreferenceProperty( wv, "step", 0.1 );
4769 setPreferenceProperty( wv, "min", 0.0 );
4770 setPreferenceProperty( wv, "max", 1.0 );
4771 setPreferenceProperty( hv, "min", 0.0 );
4772 setPreferenceProperty( hv, "max", 1.0 );
4773 setPreferenceProperty( hv, "step", 0.1 );
4775 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4776 setPreferenceProperty( posHSizeGr, "columns", 2 );
4777 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4778 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4779 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4780 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4781 setPreferenceProperty( xv, "min", 0.0 );
4782 setPreferenceProperty( xv, "max", 1.0 );
4783 setPreferenceProperty( xv, "step", 0.1 );
4784 setPreferenceProperty( xh, "min", 0.0 );
4785 setPreferenceProperty( xh, "max", 1.0 );
4786 setPreferenceProperty( xh, "step", 0.1 );
4787 setPreferenceProperty( yh, "min", 0.0 );
4788 setPreferenceProperty( yh, "max", 1.0 );
4789 setPreferenceProperty( yh, "step", 0.1 );
4790 setPreferenceProperty( wh, "min", 0.0 );
4791 setPreferenceProperty( wh, "max", 1.0 );
4792 setPreferenceProperty( wh, "step", 0.1 );
4793 setPreferenceProperty( hh, "min", 0.0 );
4794 setPreferenceProperty( hh, "max", 1.0 );
4795 setPreferenceProperty( hh, "step", 0.1 );
4797 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4798 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4799 setPreferenceProperty( distributionGr, "columns", 3 );
4801 types.append( tr( "SMESH_MONOCOLOR" ) );
4802 types.append( tr( "SMESH_MULTICOLOR" ) );
4803 indices.clear(); indices.append( 0 ); indices.append( 1 );
4804 setPreferenceProperty( coloringType, "strings", types );
4805 setPreferenceProperty( coloringType, "indexes", indices );
4806 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4810 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4812 if( sect=="SMESH" ) {
4813 float sbX1,sbY1,sbW,sbH;
4814 float aTol = 1.00000009999999;
4815 std::string aWarning;
4816 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4817 if( name=="selection_object_color" || name=="selection_element_color" ||
4818 name=="highlight_color" ||
4819 name=="selection_precision_node" || name=="selection_precision_element" ||
4820 name=="selection_precision_object")
4821 SMESH::UpdateSelectionProp( this );
4822 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4823 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4824 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4825 if(sbX1+sbW > aTol){
4826 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4829 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4830 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4833 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4834 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4835 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4836 if(sbY1+sbH > aTol){
4837 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4838 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4839 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4842 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4843 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4844 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4845 if(sbX1+sbW > aTol){
4846 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4849 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4850 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4853 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4854 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4855 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4856 if(sbY1+sbH > aTol){
4857 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4860 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4861 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4864 else if ( name == "segmentation" ) {
4865 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4866 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4868 else if ( name == "nb_segments_per_edge" ) {
4869 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4870 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4872 else if ( name == "historical_python_dump" ||
4873 name == "forget_mesh_on_hyp_modif") {
4874 QString val = aResourceMgr->stringValue( "SMESH", name );
4875 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
4878 if(aWarning.size() != 0){
4879 aWarning += "The default values are applied instead.";
4880 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4881 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4882 QObject::tr(aWarning.c_str()));
4887 //================================================================================
4889 * \brief Update something in accordance with update flags
4890 * \param theFlags - update flags
4892 * Update viewer or/and object browser etc. in accordance with update flags ( see
4893 * LightApp_UpdateFlags enumeration ).
4895 //================================================================================
4896 void SMESHGUI::update( const int flags )
4898 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4899 SMESH::UpdateView();
4901 SalomeApp_Module::update( flags );
4904 //================================================================================
4906 * \brief Set default selection mode
4908 * SLOT called when operation commited. Sets default selection mode
4910 //================================================================================
4911 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4913 SVTK_ViewWindow* vtkWnd =
4914 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4916 vtkWnd->SetSelectionMode( ActorSelection );
4919 //================================================================================
4921 * \brief Set default selection mode
4923 * SLOT called when operation aborted. Sets default selection mode
4925 //================================================================================
4926 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4928 SVTK_ViewWindow* vtkWnd =
4929 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4931 vtkWnd->SetSelectionMode( ActorSelection );
4934 //================================================================================
4936 * \brief Creates operation with given identifier
4937 * \param id - identifier of operation to be started
4938 * \return Pointer on created operation or NULL if operation is not created
4940 * Virtual method redefined from the base class creates operation with given id.
4941 * It is called called automatically from startOperation method of base class.
4943 //================================================================================
4944 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4946 LightApp_Operation* op = 0;
4947 // to do : create operation here
4950 case 417: //convert to quadratic
4951 op = new SMESHGUI_ConvToQuadOp();
4953 case 418: // create 2D mesh as boundary on 3D
4954 op = new SMESHGUI_Make2DFrom3DOp();
4956 case 701: // Compute mesh
4957 op = new SMESHGUI_ComputeOp();
4959 case 702: // Create mesh
4960 op = new SMESHGUI_MeshOp( true, true );
4962 case 703: // Create sub-mesh
4963 op = new SMESHGUI_MeshOp( true, false );
4965 case 704: // Edit mesh/sub-mesh
4966 op = new SMESHGUI_MeshOp( false );
4968 case 711: // Precompute mesh
4969 op = new SMESHGUI_PrecomputeOp();
4971 case 712: // Evaluate mesh
4972 op = new SMESHGUI_EvaluateOp();
4974 case 713: // Evaluate mesh
4975 op = new SMESHGUI_MeshOrderOp();
4977 case 806: // Create group on geom
4978 op = new SMESHGUI_GroupOnShapeOp();
4980 case 904: // Find element
4981 op = new SMESHGUI_FindElemByPointOp();
4983 case 4067: // make mesh pass through point
4984 op = new SMESHGUI_MakeNodeAtPointOp();
4991 op = SalomeApp_Module::createOperation( id );
4995 //================================================================================
4997 * \brief Stops current operations and starts a given one
4998 * \param id - The id of the operation to start
5000 //================================================================================
5002 void SMESHGUI::switchToOperation(int id)
5004 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5005 activeStudy()->abortAllOperations();
5006 startOperation( id );
5009 LightApp_Displayer* SMESHGUI::displayer()
5012 myDisplayer = new SMESHGUI_Displayer( getApp() );
5016 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5019 int aTolerance = 64;
5020 int anIterations = 0;
5026 if( anIterations % aPeriod == 0 )
5029 if( aTolerance < 1 )
5033 aHue = (int)( 360.0 * rand() / RAND_MAX );
5036 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5037 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5038 for( ; it != itEnd; ++it )
5040 SALOMEDS::Color anAutoColor = *it;
5041 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5044 aQColor.getHsv( &h, &s, &v );
5045 if( abs( h - aHue ) < aTolerance )
5057 aColor.setHsv( aHue, 255, 255 );
5059 SALOMEDS::Color aSColor;
5060 aSColor.R = (double)aColor.red() / 255.0;
5061 aSColor.G = (double)aColor.green() / 255.0;
5062 aSColor.B = (double)aColor.blue() / 255.0;
5067 const char gSeparator = '_'; // character used to separate parameter names
5068 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
5069 const char gPathSep = '|'; // character used to separate paths
5072 * \brief Store visual parameters
5074 * This method is called just before the study document is saved.
5075 * Store visual parameters in AttributeParameter attribue(s)
5077 void SMESHGUI::storeVisualParameters (int savePoint)
5079 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5080 if (!appStudy || !appStudy->studyDS())
5082 _PTR(Study) studyDS = appStudy->studyDS();
5084 // componentName is used for encoding of entries when storing them in IParameters
5085 std::string componentName = myComponentSMESH->ComponentDataType();
5086 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5087 //if (!aSComponent) return;
5090 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5091 componentName.c_str(),
5093 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5095 // store map of custom markers
5096 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5097 if( !aMarkerMap.empty() )
5099 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5100 for( ; anIter != aMarkerMap.end(); anIter++ )
5102 int anId = anIter->first;
5103 VTK::MarkerData aMarkerData = anIter->second;
5104 std::string aMarkerFileName = aMarkerData.first;
5105 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5106 if( aMarkerTexture.size() < 3 )
5107 continue; // should contain at least width, height and the first value
5109 QString aPropertyName( "texture" );
5110 aPropertyName += gSeparator;
5111 aPropertyName += QString::number( anId );
5113 QString aPropertyValue = aMarkerFileName.c_str();
5114 aPropertyValue += gPathSep;
5116 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5117 ushort aWidth = *aTextureIter++;
5118 ushort aHeight = *aTextureIter++;
5119 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5120 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5121 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5122 aPropertyValue += QString::number( *aTextureIter );
5124 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5128 // viewers counters are used for storing view_numbers in IParameters
5131 // main cycle to store parameters of displayed objects
5132 QList<SUIT_ViewManager*> lst;
5133 QList<SUIT_ViewManager*>::Iterator it;
5134 getApp()->viewManagers(lst);
5135 for (it = lst.begin(); it != lst.end(); it++)
5137 SUIT_ViewManager* vman = *it;
5138 QString vType = vman->getType();
5140 // saving VTK actors properties
5141 if (vType == SVTK_Viewer::Type())
5143 // store the clipping planes attached to the view manager
5144 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5145 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5146 if( anIter != myClippingPlaneInfoMap.end() )
5147 aClippingPlaneInfoList = anIter->second;
5149 if( !aClippingPlaneInfoList.empty() ) {
5150 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5151 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5153 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5154 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5156 QString aPropertyName( "ClippingPlane" );
5157 aPropertyName += gSeparator;
5158 aPropertyName += QString::number( vtkViewers );
5159 aPropertyName += gSeparator;
5160 aPropertyName += QString::number( anId );
5162 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5163 aPropertyValue += gDigitsSep;
5164 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5165 aPropertyValue += gDigitsSep;
5166 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5167 aPropertyValue += gDigitsSep;
5168 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5170 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5174 QVector<SUIT_ViewWindow*> views = vman->getViews();
5175 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5177 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5179 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5180 vtkActorCollection* allActors = aCopy.GetActors();
5181 allActors->InitTraversal();
5182 while (vtkActor* actor = allActors->GetNextActor())
5184 if (actor->GetVisibility()) // store only visible actors
5186 SMESH_Actor* aSmeshActor = 0;
5187 if (actor->IsA("SMESH_Actor"))
5188 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5189 if (aSmeshActor && aSmeshActor->hasIO())
5191 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5194 // entry is "encoded" = it does NOT contain component adress,
5195 // since it is a subject to change on next component loading
5196 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5198 std::string param, vtkParam = vType.toLatin1().data();
5199 vtkParam += gSeparator;
5200 vtkParam += QString::number(vtkViewers).toLatin1().data();
5201 vtkParam += gSeparator;
5204 param = vtkParam + "Visibility";
5205 ip->setParameter(entry, param, "On");
5208 param = vtkParam + "Representation";
5209 ip->setParameter(entry, param, QString::number
5210 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5213 param = vtkParam + "IsShrunk";
5214 ip->setParameter(entry, param, QString::number
5215 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5217 // Displayed entities
5218 unsigned int aMode = aSmeshActor->GetEntityMode();
5219 bool isE = aMode & SMESH_Actor::eEdges;
5220 bool isF = aMode & SMESH_Actor::eFaces;
5221 bool isV = aMode & SMESH_Actor::eVolumes;
5223 QString modeStr ("e");
5224 modeStr += gDigitsSep; modeStr += QString::number(isE);
5225 modeStr += gDigitsSep; modeStr += "f";
5226 modeStr += gDigitsSep; modeStr += QString::number(isF);
5227 modeStr += gDigitsSep; modeStr += "v";
5228 modeStr += gDigitsSep; modeStr += QString::number(isV);
5230 param = vtkParam + "Entities";
5231 ip->setParameter(entry, param, modeStr.toLatin1().data());
5233 // Colors (surface:edge:)
5234 vtkFloatingPointType r, g, b;
5237 aSmeshActor->GetSufaceColor(r, g, b, delta);
5238 QString colorStr ("surface");
5239 colorStr += gDigitsSep; colorStr += QString::number(r);
5240 colorStr += gDigitsSep; colorStr += QString::number(g);
5241 colorStr += gDigitsSep; colorStr += QString::number(b);
5243 colorStr += gDigitsSep; colorStr += "backsurface";
5244 colorStr += gDigitsSep; colorStr += QString::number(delta);
5247 aSmeshActor->GetEdgeColor(r, g, b);
5248 colorStr += gDigitsSep; colorStr += "edge";
5249 colorStr += gDigitsSep; colorStr += QString::number(r);
5250 colorStr += gDigitsSep; colorStr += QString::number(g);
5251 colorStr += gDigitsSep; colorStr += QString::number(b);
5253 aSmeshActor->GetNodeColor(r, g, b);
5254 colorStr += gDigitsSep; colorStr += "node";
5255 colorStr += gDigitsSep; colorStr += QString::number(r);
5256 colorStr += gDigitsSep; colorStr += QString::number(g);
5257 colorStr += gDigitsSep; colorStr += QString::number(b);
5259 aSmeshActor->GetOutlineColor(r, g, b);
5260 colorStr += gDigitsSep; colorStr += "outline";
5261 colorStr += gDigitsSep; colorStr += QString::number(r);
5262 colorStr += gDigitsSep; colorStr += QString::number(g);
5263 colorStr += gDigitsSep; colorStr += QString::number(b);
5265 param = vtkParam + "Colors";
5266 ip->setParameter(entry, param, colorStr.toLatin1().data());
5268 // Sizes of lines and points
5269 QString sizeStr ("line");
5270 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5271 sizeStr += gDigitsSep; sizeStr += "shrink";
5272 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5274 param = vtkParam + "Sizes";
5275 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5280 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5281 if( aMarkerType == VTK::MT_USER ) {
5282 markerStr += "custom";
5283 markerStr += gDigitsSep;
5284 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5288 markerStr += gDigitsSep;
5289 markerStr += QString::number( (int)aMarkerType );
5290 markerStr += gDigitsSep;
5291 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5294 param = vtkParam + "PointMarker";
5295 ip->setParameter(entry, param, markerStr.toLatin1().data());
5298 param = vtkParam + "Opacity";
5299 ip->setParameter(entry, param,
5300 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5303 param = vtkParam + "ClippingPlane";
5305 if( !aClippingPlaneInfoList.empty() ) {
5306 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5307 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5309 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5310 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5311 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5312 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5313 if( aSmeshActor == *anIter2 ) {
5314 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5315 QString::number( anId ).toLatin1().constData() );
5322 ip->setParameter( entry, param, "Off" );
5323 } // if (io->hasEntry())
5324 } // SMESH_Actor && hasIO
5326 } // while.. actors traversal
5330 } // if (SVTK view model)
5331 } // for (viewManagers)
5334 // data structures for clipping planes processing
5337 vtkIdType Orientation;
5338 vtkFloatingPointType Distance;
5339 vtkFloatingPointType Angle[2];
5341 typedef std::list<TPlaneData> TPlaneDataList;
5342 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5344 typedef std::list<vtkActor*> TActorList;
5347 TActorList ActorList;
5348 SUIT_ViewManager* ViewManager;
5350 typedef std::list<TPlaneInfo> TPlaneInfoList;
5351 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5354 * \brief Restore visual parameters
5356 * This method is called after the study document is opened.
5357 * Restore visual parameters from AttributeParameter attribue(s)
5359 void SMESHGUI::restoreVisualParameters (int savePoint)
5361 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5362 if (!appStudy || !appStudy->studyDS())
5364 _PTR(Study) studyDS = appStudy->studyDS();
5366 // componentName is used for encoding of entries when storing them in IParameters
5367 std::string componentName = myComponentSMESH->ComponentDataType();
5368 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5369 //if (!aSComponent) return;
5372 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5373 componentName.c_str(),
5375 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5377 // restore map of custom markers and map of clipping planes
5378 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5379 TPlaneDataMap aPlaneDataMap;
5381 std::vector<std::string> properties = ip->getProperties();
5382 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5384 std::string property = *propIt;
5385 QString aPropertyName( property.c_str() );
5386 QString aPropertyValue( ip->getProperty( property ).c_str() );
5388 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5389 if( aPropertyNameList.isEmpty() )
5392 QString aPropertyType = aPropertyNameList[0];
5393 if( aPropertyType == "texture" )
5395 if( aPropertyNameList.size() != 2 )
5399 int anId = aPropertyNameList[1].toInt( &ok );
5400 if( !ok || anId < 1 )
5403 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5404 if( aPropertyValueList.size() != 2 )
5407 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5408 QString aMarkerTextureString = aPropertyValueList[1];
5409 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5410 if( aMarkerTextureStringList.size() != 3 )
5414 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5419 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5423 VTK::MarkerTexture aMarkerTexture;
5424 aMarkerTexture.push_back( aWidth );
5425 aMarkerTexture.push_back( aHeight );
5427 QString aMarkerTextureData = aMarkerTextureStringList[2];
5428 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5430 QChar aChar = aMarkerTextureData.at( i );
5431 if( aChar.isDigit() )
5432 aMarkerTexture.push_back( aChar.digitValue() );
5435 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5437 else if( aPropertyType == "ClippingPlane" )
5439 if( aPropertyNameList.size() != 3 )
5443 int aViewId = aPropertyNameList[1].toInt( &ok );
5444 if( !ok || aViewId < 0 )
5448 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5449 if( !ok || aClippingPlaneId < 0 )
5452 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5453 if( aPropertyValueList.size() != 4 )
5456 TPlaneData aPlaneData;
5457 aPlaneData.Id = aClippingPlaneId;
5460 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5465 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5470 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5475 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5479 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5480 aPlaneDataList.push_back( aPlaneData );
5484 TPlaneInfoMap aPlaneInfoMap;
5486 std::vector<std::string> entries = ip->getEntries();
5488 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5490 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5491 QString entry (ip->decodeEntry(*entIt).c_str());
5493 // Check that the entry corresponds to a real object in the Study
5494 // as the object may be deleted or modified after the visual state is saved.
5495 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5496 if (!so) continue; //Skip the not existent entry
5498 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5499 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5501 std::vector<std::string>::iterator namesIt = paramNames.begin();
5502 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5504 // actors are stored in a map after displaying of them for
5505 // quicker access in the future: map < viewID to actor >
5506 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5508 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5510 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5511 // '_' is used as separator and should not be used in viewer type or parameter names.
5512 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5513 if (lst.size() != 3)
5516 QString viewerTypStr = lst[0];
5517 QString viewIndexStr = lst[1];
5518 QString paramNameStr = lst[2];
5521 int viewIndex = viewIndexStr.toUInt(&ok);
5522 if (!ok) // bad conversion of view index to integer
5526 if (viewerTypStr == SVTK_Viewer::Type())
5528 SMESH_Actor* aSmeshActor = 0;
5529 if (vtkActors.IsBound(viewIndex))
5530 aSmeshActor = vtkActors.Find(viewIndex);
5532 QList<SUIT_ViewManager*> lst;
5533 getApp()->viewManagers(viewerTypStr, lst);
5535 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5536 SUIT_ViewManager* vman = NULL;
5537 if (viewIndex >= 0 && viewIndex < lst.count())
5538 vman = lst.at(viewIndex);
5540 if (paramNameStr == "Visibility")
5542 if (!aSmeshActor && displayer() && vman)
5544 SUIT_ViewModel* vmodel = vman->getViewModel();
5545 // SVTK view model can be casted to SALOME_View
5546 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5548 // store displayed actor in a temporary map for quicker
5549 // access later when restoring other parameters
5550 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5551 vtkRenderer* Renderer = vtkView->getRenderer();
5552 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5553 vtkActorCollection* theActors = aCopy.GetActors();
5554 theActors->InitTraversal();
5555 bool isFound = false;
5556 vtkActor *ac = theActors->GetNextActor();
5557 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5558 if (ac->IsA("SMESH_Actor")) {
5559 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5560 if (aGeomAc->hasIO()) {
5561 Handle(SALOME_InteractiveObject) io =
5562 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5563 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5565 vtkActors.Bind(viewIndex, aGeomAc);
5571 } // if (paramNameStr == "Visibility")
5574 // the rest properties "work" with SMESH_Actor
5577 QString val ((*valuesIt).c_str());
5580 if (paramNameStr == "Representation") {
5581 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5584 else if (paramNameStr == "IsShrunk") {
5586 if (!aSmeshActor->IsShrunk())
5587 aSmeshActor->SetShrink();
5590 if (aSmeshActor->IsShrunk())
5591 aSmeshActor->UnShrink();
5594 // Displayed entities
5595 else if (paramNameStr == "Entities") {
5596 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5597 if (mode.count() == 6) {
5598 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5599 MESSAGE("Invalid order of data in Entities, must be: "
5600 "e:0/1:f:0/1:v:0/1");
5603 unsigned int aMode = aSmeshActor->GetEntityMode();
5604 unsigned int aNewMode =
5605 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5606 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5607 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5608 if (aNewMode != aMode)
5609 aSmeshActor->SetEntityMode(aNewMode);
5614 else if (paramNameStr == "Colors") {
5615 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5616 if (colors.count() == 16 || colors.count() == 18 ) {
5617 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5618 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
5619 (colors.count() == 18 && colors[14] != "outline")) {
5620 MESSAGE("Invalid order of data in Colors, must be: "
5621 "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");
5627 vtkFloatingPointType otr,otg,otb;
5628 //Old case backsurface color is independent
5629 if( colors.count() == 16 ) {
5631 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5632 er = colors[9].toFloat();
5633 eg = colors[10].toFloat();
5634 eb = colors[11].toFloat();
5636 nr = colors[13].toFloat();
5637 ng = colors[14].toFloat();
5638 nb = colors[15].toFloat();
5639 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5641 //New case backsurface color depends on surface color
5642 delta = colors[5].toInt();
5644 er = colors[7].toFloat();
5645 eg = colors[8].toFloat();
5646 eb = colors[9].toFloat();
5648 nr = colors[11].toFloat();
5649 ng = colors[12].toFloat();
5650 nb = colors[13].toFloat();
5652 otr = colors[15].toFloat();
5653 otg = colors[16].toFloat();
5654 otb = colors[17].toFloat();
5656 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5657 aSmeshActor->SetEdgeColor(er,eg,eb);
5658 aSmeshActor->SetNodeColor(nr,ng,nb);
5659 aSmeshActor->SetOutlineColor(otr,otg,otb);
5663 // Sizes of lines and points
5664 else if (paramNameStr == "Sizes") {
5665 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5666 if (sizes.count() == 4) {
5667 if (sizes[0] != "line" || sizes[2] != "shrink") {
5668 MESSAGE("Invalid order of data in Sizes, must be: "
5669 "line:int:shrink:float");
5672 aSmeshActor->SetLineWidth(sizes[1].toInt());
5673 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5676 else if (sizes.count() == 6) { // just to support old format
5677 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5678 MESSAGE("Invalid order of data in Sizes, must be: "
5679 "line:int:node:int:shrink:float");
5682 aSmeshActor->SetLineWidth(sizes[1].toInt());
5683 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5684 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5689 else if (paramNameStr == "PointMarker") {
5690 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5691 if( data.count() >= 2 ) {
5693 int aParam1 = data[1].toInt( &ok );
5695 if( data[0] == "std" && data.count() == 3 ) {
5696 int aParam2 = data[2].toInt( &ok );
5697 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5699 else if( data[0] == "custom" ) {
5700 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5701 if( markerIt != aMarkerMap.end() ) {
5702 VTK::MarkerData aMarkerData = markerIt->second;
5703 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5710 else if (paramNameStr == "Opacity") {
5711 aSmeshActor->SetOpacity(val.toFloat());
5714 else if (paramNameStr.startsWith("ClippingPlane")) {
5715 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5716 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5717 // new format - val looks like "Off" or "0" (plane id)
5718 // (note: in new format "Off" value is used only for consistency,
5719 // so it is processed together with values in old format)
5720 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5721 if( anIsOldFormat ) {
5722 if (paramNameStr == "ClippingPlane1" || val == "Off")
5723 aSmeshActor->RemoveAllClippingPlanes();
5725 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5726 double aDistance = vals[1].toFloat();
5727 vtkFloatingPointType anAngle[2];
5728 anAngle[0] = vals[2].toFloat();
5729 anAngle[1] = vals[3].toFloat();
5731 QList<SUIT_ViewManager*> lst;
5732 getApp()->viewManagers(viewerTypStr, lst);
5733 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5734 if (viewIndex >= 0 && viewIndex < lst.count()) {
5735 SUIT_ViewManager* vman = lst.at(viewIndex);
5736 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5738 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5740 SMESH::TActorList anActorList;
5741 anActorList.push_back( aSmeshActor );
5742 SMESH::OrientedPlane* aPlane =
5743 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5745 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5746 aClippingPlaneInfo.Plane = aPlane;
5747 aClippingPlaneInfo.ActorList = anActorList;
5748 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5755 int aPlaneId = val.toInt( &ok );
5756 if( ok && aPlaneId >= 0 ) {
5757 bool anIsDefinedPlane = false;
5758 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5759 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5760 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5761 TPlaneInfo& aPlaneInfo = *anIter;
5762 if( aPlaneInfo.PlaneId == aPlaneId ) {
5763 aPlaneInfo.ActorList.push_back( aSmeshActor );
5764 anIsDefinedPlane = true;
5768 if( !anIsDefinedPlane ) {
5769 TPlaneInfo aPlaneInfo;
5770 aPlaneInfo.PlaneId = aPlaneId;
5771 aPlaneInfo.ActorList.push_back( aSmeshActor );
5772 aPlaneInfo.ViewManager = vman;
5774 // to make the list sorted by plane id
5775 anIter = aPlaneInfoList.begin();
5776 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5777 const TPlaneInfo& aPlaneInfoRef = *anIter;
5778 if( aPlaneInfoRef.PlaneId > aPlaneId )
5781 aPlaneInfoList.insert( anIter, aPlaneInfo );
5786 } // if (aSmeshActor)
5787 } // other parameters than Visibility
5789 } // for names/parameters iterator
5790 } // for entries iterator
5792 // take into account planes with empty list of actors referred to them
5793 QList<SUIT_ViewManager*> aVMList;
5794 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5796 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5797 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5798 int aViewId = aPlaneDataIter->first;
5799 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5800 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5802 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5804 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5805 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5806 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5807 const TPlaneData& aPlaneData = *anIter2;
5808 int aPlaneId = aPlaneData.Id;
5810 bool anIsFound = false;
5811 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5812 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5813 const TPlaneInfo& aPlaneInfo = *anIter3;
5814 if( aPlaneInfo.PlaneId == aPlaneId ) {
5821 TPlaneInfo aPlaneInfo; // ActorList field is empty
5822 aPlaneInfo.PlaneId = aPlaneId;
5823 aPlaneInfo.ViewManager = aViewManager;
5825 // to make the list sorted by plane id
5826 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5827 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5828 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5829 if( aPlaneInfoRef.PlaneId > aPlaneId )
5832 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5838 // add clipping planes to actors according to the restored parameters
5839 // and update the clipping plane map
5840 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5841 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5842 int aViewId = anIter1->first;
5843 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5845 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5846 if( anIter2 == aPlaneDataMap.end() )
5848 const TPlaneDataList& aPlaneDataList = anIter2->second;
5850 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5851 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5852 const TPlaneInfo& aPlaneInfo = *anIter3;
5853 int aPlaneId = aPlaneInfo.PlaneId;
5854 const TActorList& anActorList = aPlaneInfo.ActorList;
5855 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5859 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5863 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5865 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5866 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5867 const TPlaneData& aPlaneData = *anIter4;
5868 if( aPlaneData.Id == aPlaneId ) {
5869 SMESH::OrientedPlane* aPlane =
5870 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5872 (SMESH::Orientation)aPlaneData.Orientation,
5873 aPlaneData.Distance,
5876 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5877 aClippingPlaneInfo.Plane = aPlane;
5878 aClippingPlaneInfo.ActorList = anActorList;
5879 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5887 // update all VTK views
5888 QList<SUIT_ViewManager*> lst;
5889 getApp()->viewManagers(lst);
5890 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5891 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5892 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5893 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5894 vtkView->getRenderer()->ResetCameraClippingRange();
5901 \brief Adds preferences for dfont of VTK viewer
5903 \param pIf group identifier
5904 \param param parameter
5905 \return identifier of preferences
5907 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5909 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5911 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5914 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5915 fam.append( tr( "SMESH_FONT_COURIER" ) );
5916 fam.append( tr( "SMESH_FONT_TIMES" ) );
5918 setPreferenceProperty( tfont, "fonts", fam );
5920 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5921 setPreferenceProperty( tfont, "features", f );
5927 \brief Actions after hypothesis edition
5928 Updates object browser after hypothesis edition
5930 void SMESHGUI::onHypothesisEdit( int result )
5933 SMESHGUI::Modified();
5934 updateObjBrowser( true );
5939 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5940 \param pview view being closed
5942 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5943 #ifndef DISABLE_PLOT2DVIEWER
5944 //Crear all Plot2d Viewers if need.
5945 SMESH::ClearPlot2Viewers(pview);
5950 \brief Connects or disconnects signals about activating and cloning view on the module slots
5951 \param pview view which is connected/disconnected
5953 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5957 SUIT_ViewManager* viewMgr = pview->getViewManager();
5959 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5960 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5962 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5963 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5968 \brief Return \c true if object can be renamed
5970 bool SMESHGUI::renameAllowed( const QString& entry) const {
5971 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5975 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
5979 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
5984 if(appStudy->isComponent(entry) || obj->isReference())
5987 // check type to prevent renaming of inappropriate objects
5988 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
5989 if (aType == MESH || aType == GROUP ||
5990 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5991 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5992 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5993 aType == HYPOTHESIS || aType == ALGORITHM)
6000 Rename object by entry.
6001 \param entry entry of the object
6002 \param name new name of the object
6003 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6005 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6007 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6011 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6016 _PTR(Study) aStudy = appStudy->studyDS();
6021 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6023 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6028 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6029 _PTR(GenericAttribute) anAttr;
6030 _PTR(AttributeName) aName;
6032 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6034 // check type to prevent renaming of inappropriate objects
6035 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6036 if (aType == MESH || aType == GROUP ||
6037 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
6038 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
6039 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
6040 aType == HYPOTHESIS || aType == ALGORITHM) {
6041 if ( !name.isEmpty() ) {
6042 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6044 // update name of group object and its actor
6045 Handle(SALOME_InteractiveObject) IObject =
6046 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6048 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6049 if( !aGroupObject->_is_nil() ) {
6050 aGroupObject->SetName( qPrintable(name) );
6051 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6052 anActor->setName( qPrintable(name) );