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_MeshInfosDlg.h"
56 #include "SMESHGUI_Measurements.h"
57 #include "SMESHGUI_MeshInfo.h"
58 #include "SMESHGUI_MeshOp.h"
59 #include "SMESHGUI_MeshOrderOp.h"
60 #include "SMESHGUI_MeshPatternDlg.h"
61 #include "SMESHGUI_MultiEditDlg.h"
62 #include "SMESHGUI_NodesDlg.h"
63 #include "SMESHGUI_Preferences_ColorDlg.h"
64 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
65 #include "SMESHGUI_RemoveElementsDlg.h"
66 #include "SMESHGUI_RemoveNodesDlg.h"
67 #include "SMESHGUI_RenumberingDlg.h"
68 #include "SMESHGUI_RevolutionDlg.h"
69 #include "SMESHGUI_RotationDlg.h"
70 #include "SMESHGUI_Selection.h"
71 #include "SMESHGUI_SewingDlg.h"
72 #include "SMESHGUI_SingleEditDlg.h"
73 #include "SMESHGUI_SmoothingDlg.h"
74 //#include "SMESHGUI_StandardMeshInfosDlg.h"
75 #include "SMESHGUI_SymmetryDlg.h"
76 #include "SMESHGUI_TranslationDlg.h"
77 #include "SMESHGUI_ScaleDlg.h"
78 #include "SMESHGUI_TransparencyDlg.h"
79 //#include "SMESHGUI_WhatIsDlg.h"
80 #include "SMESHGUI_DuplicateNodesDlg.h"
81 #include "SMESHGUI_CopyMeshDlg.h"
83 #include "SMESHGUI_Utils.h"
84 #include "SMESHGUI_MeshUtils.h"
85 #include "SMESHGUI_GroupUtils.h"
86 #include "SMESHGUI_FilterUtils.h"
87 #include "SMESHGUI_PatternUtils.h"
88 #include "SMESHGUI_VTKUtils.h"
89 #include "SMESHGUI_HypothesesUtils.h"
91 #include <SMESH_version.h>
93 #include <SMESH_Client.hxx>
94 #include <SMESH_Actor.h>
95 #include <SMESH_ScalarBarActor.h>
96 #include <SMESH_ActorUtils.h>
97 #include <SMESH_TypeFilter.hxx>
98 #include "SMESH_ControlsDef.hxx"
100 // SALOME GUI includes
101 #include <SalomeApp_Tools.h>
102 #include <SalomeApp_Study.h>
103 #include <SalomeApp_Application.h>
104 #include <SalomeApp_CheckFileDlg.h>
106 #include <LightApp_DataOwner.h>
107 #include <LightApp_Preferences.h>
108 #include <LightApp_SelectionMgr.h>
109 #include <LightApp_UpdateFlags.h>
110 #include <LightApp_NameDlg.h>
112 #include <SVTK_ViewWindow.h>
113 #include <SVTK_ViewModel.h>
114 #include <SVTK_ViewManager.h>
116 #include <VTKViewer_Algorithm.h>
118 #include <SUIT_MessageBox.h>
119 #include <SUIT_ResourceMgr.h>
120 #include <SUIT_FileDlg.h>
121 #include <SUIT_Desktop.h>
122 #include <SUIT_OverrideCursor.h>
123 #include <SUIT_Session.h>
125 #include <QtxPopupMgr.h>
126 #include <QtxFontEdit.h>
128 #include <SALOME_ListIO.hxx>
129 #include <SALOME_ListIteratorOfListIO.hxx>
131 #ifndef DISABLE_PLOT2DVIEWER
132 #include <SPlot2d_ViewModel.h>
133 #include <SPlot2d_Histogram.h>
137 #include <SALOMEconfig.h>
138 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
139 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
140 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
143 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
145 #include <QTextStream>
148 #include <boost/shared_ptr.hpp>
151 #include <vtkCamera.h>
152 #include <vtkRenderer.h>
153 #include <vtkPlane.h>
154 #include <vtkCallbackCommand.h>
155 #include <vtkLookupTable.h>
157 // SALOME KERNEL includes
158 #include <SALOMEDS_Study.hxx>
159 #include <SALOMEDSClient_StudyBuilder.hxx>
160 #include <SALOMEDSClient_SComponent.hxx>
161 #include <SALOMEDSClient_ClientFactory.hxx>
162 #include <SALOMEDSClient_IParameters.hxx>
165 #include <Standard_ErrorHandler.hxx>
166 #include <NCollection_DataMap.hxx>
168 //To disable automatic genericobj management, the following line should be commented.
169 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
170 #define WITHGENERICOBJ
174 //=============================================================
175 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
178 void ExportMeshToFile(int theCommandID);
180 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
182 void SetDisplayEntity(int theCommandID);
184 void Control( int theCommandID );
188 //=============================================================
189 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
193 std::string myExtension;
195 if ( theCommandID == 113 ) {
196 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
197 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
199 else if ( theCommandID == 112 ) {
200 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
202 else if ( theCommandID == 111 ) {
203 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
205 else if ( theCommandID == 115 ) {
206 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
208 else if ( theCommandID == 116 ) {
209 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
211 else if ( theCommandID == 117 ) {
212 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
213 filter.append( QObject::tr( "All files (*)" ) );
216 QString anInitialPath = "";
217 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
218 anInitialPath = QDir::currentPath();
220 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
223 QObject::tr( "SMESH_IMPORT_MESH" ) );
224 if ( filenames.count() > 0 ) {
225 SUIT_OverrideCursor wc;
226 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
229 QStringList anEntryList;
230 bool isEmpty = false;
231 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
232 QString filename = *it;
233 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
235 switch ( theCommandID ) {
238 // DAT format (currently unsupported)
239 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
240 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
246 aMeshes->length( 1 );
247 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
248 if ( aMeshes[0]->_is_nil() )
249 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
250 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
256 SMESH::DriverMED_ReadStatus res;
257 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
258 if ( res != SMESH::DRS_OK ) {
259 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
260 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
267 aMeshes->length( 1 );
268 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
269 if ( aMeshes[0]->_is_nil() ) {
270 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
271 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
278 SMESH::DriverMED_ReadStatus res;
279 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
280 if ( res != SMESH::DRS_OK ) {
281 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
282 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
289 SMESH::DriverMED_ReadStatus res;
290 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
291 if ( res != SMESH::DRS_OK ) {
292 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
293 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
299 catch ( const SALOME::SALOME_Exception& S_ex ) {
300 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
301 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
304 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
305 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
307 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
308 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
309 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
310 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
311 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
313 anEntryList.append( aMeshSO->GetID().c_str() );
315 #ifdef WITHGENERICOBJ
316 // obj has been published in study. Its refcount has been incremented.
317 // It is safe to decrement its refcount
318 // so that it will be destroyed when the entry in study will be removed
319 aMeshes[i]->UnRegister();
328 // update Object browser
329 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
331 // browse to the published meshes
332 if( LightApp_Application* anApp =
333 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
334 anApp->browseObjects( anEntryList );
336 // show Error message box if there were errors
337 if ( errors.count() > 0 ) {
338 SUIT_MessageBox::critical( SMESHGUI::desktop(),
339 QObject::tr( "SMESH_ERROR" ),
340 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
343 // show warning message box, if some imported mesh is empty
345 SUIT_MessageBox::warning( SMESHGUI::desktop(),
346 QObject::tr( "SMESH_WRN_WARNING" ),
347 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
352 //================================================================================
354 * \brief Export selected meshes or groups into a file
356 //================================================================================
358 void ExportMeshToFile( int theCommandID )
360 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
361 SALOME_ListIO selected;
363 aSel->selectedObjects( selected );
365 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
366 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
367 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
368 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
369 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
370 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
372 // actually, the following condition can't be met (added for insurance)
373 if( selected.Extent() == 0 ||
374 ( selected.Extent() > 1 && !isMED && !isSTL ))
377 // get mesh object from selection and check duplication of their names
378 bool hasDuplicatedMeshNames = false;
379 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
380 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
381 SALOME_ListIteratorOfListIO It( selected );
382 for( ; It.More(); It.Next() )
384 Handle(SALOME_InteractiveObject) anIObject = It.Value();
385 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
386 if ( aMeshItem->_is_nil() ) {
387 SUIT_MessageBox::warning( SMESHGUI::desktop(),
388 QObject::tr( "SMESH_WRN_WARNING" ),
389 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
393 QString aMeshName = anIObject->getName();
395 // check for name duplications
396 if ( !hasDuplicatedMeshNames )
397 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
398 if( aMeshName == (*aMeshIter).second ) {
399 hasDuplicatedMeshNames = true;
404 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
407 if( hasDuplicatedMeshNames && isMED ) {
408 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
409 QObject::tr("SMESH_WRN_WARNING"),
410 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
411 QObject::tr("SMESH_BUT_YES"),
412 QObject::tr("SMESH_BUT_NO"), 0, 1);
417 aMeshIter = aMeshList.begin();
418 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
419 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
420 QString aMeshName = (*aMeshIter).second;
422 if ( isMED || isCGNS || isSAUV )
424 // check for equal group names within each mesh
425 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
426 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
427 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
428 int aRet = SUIT_MessageBox::warning
429 (SMESHGUI::desktop(),
430 QObject::tr("SMESH_WRN_WARNING"),
431 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
432 QObject::tr("SMESH_BUT_YES"),
433 QObject::tr("SMESH_BUT_NO"), 0, 1);
441 // warn the user about presence of not supported elements
442 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
443 int nbPyramids = nbElems[ SMESH::Entity_Pyramid ] + nbElems[ SMESH::Entity_Quad_Pyramid ];
444 if ( nbPyramids > 0 ) {
445 int aRet = SUIT_MessageBox::warning
446 (SMESHGUI::desktop(),
447 QObject::tr("SMESH_WRN_WARNING"),
448 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
449 QObject::tr("SMESH_BUT_YES"),
450 QObject::tr("SMESH_BUT_NO"), 0, 1);
456 // Get parameters of export operation
459 SMESH::MED_VERSION aFormat;
460 // Init the parameters with the default values
461 bool aIsASCII_STL = true;
462 bool toCreateGroups = false;
463 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
465 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
466 bool toOverwrite = true;
468 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
469 QString anInitialPath = "";
470 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
471 anInitialPath = QDir::currentPath();
473 if ( isUNV || isDAT )
476 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
478 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
479 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
480 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
481 anInitialPath + QString("/") + aMeshName,
482 aFilter, aTitle, false);
484 else if ( isCGNS )// Export to CGNS
486 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
487 fd->setWindowTitle( aTitle );
488 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
489 if ( !anInitialPath.isEmpty() )
490 fd->setDirectory( anInitialPath );
491 fd->selectFile(aMeshName);
492 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
493 fd->setValidator( fv );
496 aFilename = fd->selectedFile();
497 toOverwrite = fv->isOverwrite();
501 else if ( isSTL ) // Export to STL
503 QMap<QString, int> aFilterMap;
504 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
505 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
508 QMap<QString, int>::const_iterator it = aFilterMap.begin();
509 for ( ; it != aFilterMap.end(); ++it )
510 filters.push_back( it.key() );
512 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
513 fd->setWindowTitle( aTitle );
514 fd->setNameFilters( filters );
515 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
516 if ( !anInitialPath.isEmpty() )
517 fd->setDirectory( anInitialPath );
518 fd->selectFile(aMeshName);
522 aFilename = fd->selectedFile();
523 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
528 else if ( isMED || isSAUV ) // Export to MED or SAUV
530 QMap<QString, SMESH::MED_VERSION> aFilterMap;
531 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
533 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
534 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
535 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
538 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
539 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
540 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
544 QString aDefaultFilter;
545 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
546 for ( ; it != aFilterMap.end(); ++it ) {
547 filters.push_back( it.key() );
548 if (it.value() == SMESH::MED_V2_2)
549 aDefaultFilter = it.key();
552 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
553 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
554 fd->setWindowTitle( aTitle );
555 fd->setNameFilters( filters );
556 fd->selectNameFilter(aDefaultFilter);
557 fd->SetChecked(toCreateGroups);
558 if ( !anInitialPath.isEmpty() )
559 fd->setDirectory( anInitialPath );
560 fd->selectFile(aMeshName);
562 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
563 fd->setValidator( fv );
568 aFilename = fd->selectedFile();
570 aFilename = QString::null;
573 aFormat = aFilterMap[fd->selectedNameFilter()];
574 toOverwrite = fv->isOverwrite();
576 if ( !aFilename.isEmpty() ) {
577 // med-2.1 does not support poly elements
578 if ( aFormat==SMESH::MED_V2_1 )
579 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
580 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
581 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
582 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
583 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
585 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
586 QObject::tr("SMESH_WRN_WARNING"),
587 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
588 QObject::tr("SMESH_BUT_YES"),
589 QObject::tr("SMESH_BUT_NO"), 0, 1);
597 // can't append to an existing using other format
598 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
599 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
600 if( !isVersionOk || aVersion != aFormat ) {
601 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
602 QObject::tr("SMESH_WRN_WARNING"),
603 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
604 QObject::tr("SMESH_BUT_YES"),
605 QObject::tr("SMESH_BUT_NO"), 0, 1);
612 QStringList aMeshNamesCollisionList;
613 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
614 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
615 QString anExistingMeshName( aMeshNames[ i ] );
616 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
617 QString anExportMeshName = (*aMeshIter).second;
618 if( anExportMeshName == anExistingMeshName ) {
619 aMeshNamesCollisionList.append( anExportMeshName );
624 if( !aMeshNamesCollisionList.isEmpty() ) {
625 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
626 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
627 QObject::tr("SMESH_WRN_WARNING"),
628 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
629 QObject::tr("SMESH_BUT_YES"),
630 QObject::tr("SMESH_BUT_NO"),
631 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
640 toCreateGroups = fd->IsChecked();
650 if ( !aFilename.isEmpty() ) {
651 // Check whether the file already exists and delete it if yes
652 QFile aFile( aFilename );
653 if ( aFile.exists() && toOverwrite )
655 SUIT_OverrideCursor wc;
658 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
659 // bool Renumber = false;
660 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
662 // Renumber= resMgr->booleanValue("SMESH","renumbering");
664 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
665 // aMeshEditor->RenumberNodes();
666 // aMeshEditor->RenumberElements();
667 // if ( SMESHGUI::automaticUpdate() )
668 // SMESH::UpdateView();
672 aMeshIter = aMeshList.begin();
673 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
675 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
676 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
677 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
678 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
679 aFormat, toOverwrite && aMeshIndex == 0 );
681 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
682 aFormat, toOverwrite && aMeshIndex == 0 );
687 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
689 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
690 if( !aMeshItem->_is_nil() )
691 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
696 if ( aMeshOrGroup->_is_equivalent( aMesh ))
697 aMesh->ExportDAT( aFilename.toLatin1().data() );
699 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
703 if ( aMeshOrGroup->_is_equivalent( aMesh ))
704 aMesh->ExportUNV( aFilename.toLatin1().data() );
706 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
710 if ( aMeshOrGroup->_is_equivalent( aMesh ))
711 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
713 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
717 aMeshIter = aMeshList.begin();
718 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
720 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
721 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
722 aMeshItem->ExportCGNS( aMeshOrGroup,
723 aFilename.toLatin1().data(),
724 toOverwrite && aMeshIndex == 0 );
728 catch (const SALOME::SALOME_Exception& S_ex){
730 SUIT_MessageBox::warning(SMESHGUI::desktop(),
731 QObject::tr("SMESH_WRN_WARNING"),
732 QObject::tr("SMESH_EXPORT_FAILED"));
738 inline void InverseEntityMode(unsigned int& theOutputMode,
739 unsigned int theMode)
741 bool anIsNotPresent = ~theOutputMode & theMode;
743 theOutputMode |= theMode;
745 theOutputMode &= ~theMode;
748 void SetDisplayEntity(int theCommandID){
749 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
750 SALOME_ListIO selected;
752 aSel->selectedObjects( selected );
754 if(selected.Extent() >= 1){
755 SALOME_ListIteratorOfListIO It( selected );
756 for( ; It.More(); It.Next()){
757 Handle(SALOME_InteractiveObject) IObject = It.Value();
758 if(IObject->hasEntry()){
759 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
760 unsigned int aMode = anActor->GetEntityMode();
761 switch(theCommandID){
763 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
766 InverseEntityMode(aMode,SMESH_Actor::eEdges);
769 InverseEntityMode(aMode,SMESH_Actor::eFaces);
772 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
775 aMode = SMESH_Actor::eAllEntity;
779 anActor->SetEntityMode(aMode);
787 SALOME_ListIO selected;
788 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
792 LightApp_SelectionMgr* aSel = app->selectionMgr();
793 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
794 if( !aSel || !appStudy )
797 aSel->selectedObjects( selected );
798 if( selected.IsEmpty() )
801 Handle(SALOME_InteractiveObject) anIObject = selected.First();
803 _PTR(Study) aStudy = appStudy->studyDS();
804 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
805 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
806 if( aMainObject->_is_nil() )
809 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
811 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
812 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
814 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
815 SALOMEDS::Color aColor = aGroupObject->GetColor();
816 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
818 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
819 if( aGroupObject->GetType() == SMESH::NODE )
820 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
821 else if( aGroupObject->GetType() == SMESH::EDGE )
822 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
823 else if( aGroupObject->GetType() == SMESH::ELEM0D )
824 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
828 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
829 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
835 SMESH::RepaintCurrentView();
838 QString functorToString( SMESH::Controls::FunctorPtr f )
840 QString type = QObject::tr( "UNKNOWN_CONTROL" );
841 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
842 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
843 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
844 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
845 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
846 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
847 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
848 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
849 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
850 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
851 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
852 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
853 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
854 type = QObject::tr( "WARP_ELEMENTS" );
855 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
856 type = QObject::tr( "TAPER_ELEMENTS" );
857 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
858 type = QObject::tr( "SKEW_ELEMENTS" );
859 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
860 type = QObject::tr( "AREA_ELEMENTS" );
861 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
862 type = QObject::tr( "LENGTH_EDGES" );
863 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
864 type = QObject::tr( "LENGTH2D_EDGES" );
865 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
866 type = QObject::tr( "MULTI_BORDERS" );
867 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
868 type = QObject::tr( "MULTI2D_BORDERS" );
869 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
870 type = QObject::tr( "FREE_NODES" );
871 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
872 type = QObject::tr( "FREE_EDGES" );
873 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
874 type = QObject::tr( "FREE_BORDERS" );
875 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
876 type = QObject::tr( "FREE_FACES" );
877 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
878 type = QObject::tr( "BARE_BORDER_VOLUME" );
879 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
880 type = QObject::tr( "BARE_BORDER_FACE" );
881 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
882 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
883 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
884 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
888 void SaveDistribution()
890 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
891 SALOME_ListIO selected;
893 aSel->selectedObjects( selected );
895 if ( selected.Extent() == 1 ) {
896 Handle(SALOME_InteractiveObject) anIO = selected.First();
897 if ( anIO->hasEntry() ) {
898 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
899 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
900 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
901 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
902 if ( aScalarBarActor && aFunctor ) {
903 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
905 std::vector<int> elements;
906 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
907 if ( mesh->_is_nil() ) {
908 SMESH::SMESH_IDSource_var idSource =
909 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
910 if ( !idSource->_is_nil() )
912 SMESH::long_array_var ids = idSource->GetIDs();
913 elements.resize( ids->length() );
914 for ( unsigned i = 0; i < elements.size(); ++i )
915 elements[i] = ids[i];
918 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
919 vtkLookupTable* lookupTable =
920 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
921 double * minmax = lookupTable->GetRange();
922 std::vector<int> nbEvents;
923 std::vector<double> funValues;
924 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
925 QString anInitialPath = "";
926 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
927 anInitialPath = QDir::currentPath();
928 QString aMeshName = anIO->getName();
930 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
931 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
932 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
933 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
934 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
937 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
939 if ( !aFilename.isEmpty() ) {
940 QFile f( aFilename );
941 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
942 QTextStream out( &f );
943 out << "# Mesh: " << aMeshName << endl;
944 out << "# Control: " << functorToString( aFunctor ) << endl;
946 out.setFieldWidth( 10 );
947 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
948 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
959 void ShowDistribution() {
960 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
961 SALOME_ListIO selected;
963 aSel->selectedObjects( selected );
965 if ( selected.Extent() == 1 ) {
966 Handle(SALOME_InteractiveObject) anIO = selected.First();
967 if ( anIO->hasEntry() ) {
968 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
969 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
970 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
971 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
977 #ifndef DISABLE_PLOT2DVIEWER
978 void PlotDistribution() {
979 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
983 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
984 SALOME_ListIO selected;
986 aSel->selectedObjects( selected );
988 if ( selected.Extent() == 1 ) {
989 Handle(SALOME_InteractiveObject) anIO = selected.First();
990 if ( anIO->hasEntry() ) {
991 //Find Actor by entry before getting Plot2d viewer,
992 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
993 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
995 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1000 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1004 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1008 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1009 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1010 QString functorName = functorToString( anActor->GetFunctor());
1011 QString aHistogramName("%1 : %2");
1012 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1013 aHistogram->setName(aHistogramName);
1014 aHistogram->setHorTitle(functorName);
1015 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1016 aPlot->displayObject(aHistogram, true);
1021 #endif //DISABLE_PLOT2DVIEWER
1023 void DisableAutoColor(){
1024 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1025 SALOME_ListIO selected;
1027 aSel->selectedObjects( selected );
1029 if(selected.Extent()){
1030 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1031 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1032 if ( !aMesh->_is_nil() ) {
1033 aMesh->SetAutoColor( false );
1038 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1039 SALOME_ListIO selected;
1040 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1044 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1045 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1046 if( !aSel || !appStudy )
1049 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1050 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1051 aModule->EmitSignalDeactivateDialog();
1052 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1053 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1058 _PTR(Study) aStudy = appStudy->studyDS();
1060 aSel->selectedObjects( selected );
1062 if(selected.Extent() >= 1){
1063 switch(theCommandID){
1065 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1066 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1070 QColor c, e, b, n, c0D, o, outl, selection, preselection;
1074 vtkFloatingPointType Shrink = 0.0;
1075 vtkFloatingPointType faces_orientation_scale = 0.0;
1076 bool faces_orientation_3dvectors = false;
1078 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1079 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1080 int aMarkerTextureCurrent = 0;
1082 SALOME_ListIteratorOfListIO It( selected );
1083 for( ; It.More(); It.Next()){
1084 Handle(SALOME_InteractiveObject) IObject = It.Value();
1085 if(IObject->hasEntry()){
1086 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1087 vtkFloatingPointType color[3];
1088 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1089 int c0 = int (color[0] * 255);
1090 int c1 = int (color[1] * 255);
1091 int c2 = int (color[2] * 255);
1092 c.setRgb(c0, c1, c2);
1094 vtkFloatingPointType edgecolor[3];
1095 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1096 c0 = int (edgecolor[0] * 255);
1097 c1 = int (edgecolor[1] * 255);
1098 c2 = int (edgecolor[2] * 255);
1099 e.setRgb(c0, c1, c2);
1101 vtkFloatingPointType nodecolor[3];
1102 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1103 c0 = int (nodecolor[0] * 255);
1104 c1 = int (nodecolor[1] * 255);
1105 c2 = int (nodecolor[2] * 255);
1106 n.setRgb(c0, c1, c2);
1108 vtkFloatingPointType color0D[3];
1109 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1110 c0 = int (color0D[0] * 255);
1111 c1 = int (color0D[1] * 255);
1112 c2 = int (color0D[2] * 255);
1113 c0D.setRgb(c0, c1, c2);
1115 vtkFloatingPointType outlineColor[3];
1116 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1117 c0 = int (outlineColor[0] * 255);
1118 c1 = int (outlineColor[1] * 255);
1119 c2 = int (outlineColor[2] * 255);
1120 outl.setRgb(c0, c1, c2);
1122 vtkFloatingPointType hColor[3];
1123 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1124 c0 = int (hColor[0] * 255);
1125 c1 = int (hColor[1] * 255);
1126 c2 = int (hColor[2] * 255);
1127 selection.setRgb(c0, c1, c2);
1129 vtkFloatingPointType phColor[3];
1130 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1131 c0 = int (phColor[0] * 255);
1132 c1 = int (phColor[1] * 255);
1133 c2 = int (phColor[2] * 255);
1134 preselection.setRgb(c0, c1, c2);
1136 size0D = (int)anActor->Get0DSize();
1139 Edgewidth = (int)anActor->GetLineWidth();
1142 Shrink = anActor->GetShrinkFactor();
1144 vtkFloatingPointType faces_orientation_color[3];
1145 anActor->GetFacesOrientationColor(faces_orientation_color);
1146 c0 = int (faces_orientation_color[0] * 255);
1147 c1 = int (faces_orientation_color[1] * 255);
1148 c2 = int (faces_orientation_color[2] * 255);
1149 o.setRgb(c0, c1, c2);
1151 faces_orientation_scale = anActor->GetFacesOrientationScale();
1152 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1154 aMarkerTypeCurrent = anActor->GetMarkerType();
1155 aMarkerScaleCurrent = anActor->GetMarkerScale();
1156 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1158 // even if there are multiple objects in the selection,
1159 // we need only the first one to get values for the dialog
1165 SMESHGUI_Preferences_ColorDlg *aDlg =
1166 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1167 aDlg->SetColor(1, c);
1168 aDlg->SetColor(2, e);
1169 aDlg->SetColor(3, n);
1170 aDlg->SetColor(4, outl);
1171 aDlg->SetDeltaBrightness(delta);
1172 aDlg->SetColor(5, c0D);
1173 aDlg->SetColor(6, o);
1174 aDlg->SetIntValue(1, Edgewidth);
1175 aDlg->SetIntValue(2, int(Shrink*100.));
1176 aDlg->SetIntValue(3, size0D);
1177 aDlg->SetDoubleValue(1, faces_orientation_scale);
1178 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1179 aDlg->SetColor(7, selection);
1180 aDlg->SetColor(8, preselection);
1182 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1184 if( aMarkerTypeCurrent != VTK::MT_USER )
1185 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1187 aDlg->setCustomMarker( aMarkerTextureCurrent );
1190 QColor color = aDlg->GetColor(1);
1191 QColor edgecolor = aDlg->GetColor(2);
1192 QColor nodecolor = aDlg->GetColor(3);
1193 QColor outlinecolor = aDlg->GetColor(4);
1194 QColor color0D = aDlg->GetColor(5);
1195 QColor faces_orientation_color = aDlg->GetColor(6);
1196 QColor selectioncolor = aDlg->GetColor(7);
1197 QColor preSelectioncolor = aDlg->GetColor(8);
1198 int delta = aDlg->GetDeltaBrightness();
1201 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1203 SALOME_ListIteratorOfListIO It( selected );
1204 for( ; It.More(); It.Next()){
1205 Handle(SALOME_InteractiveObject) IObject = It.Value();
1206 if(IObject->hasEntry()){
1207 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1208 /* actor color and backface color */
1209 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1210 vtkFloatingPointType (color.green()) / 255.,
1211 vtkFloatingPointType (color.blue()) / 255.,
1214 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1215 vtkFloatingPointType (edgecolor.green()) / 255.,
1216 vtkFloatingPointType (edgecolor.blue()) / 255.);
1218 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1219 vtkFloatingPointType (outlinecolor.green()) / 255.,
1220 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1223 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1224 vtkFloatingPointType (selectioncolor.green()) / 255.,
1225 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1227 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1228 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1229 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1232 /* Shrink factor and size edges */
1233 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1234 anActor->SetLineWidth(aDlg->GetIntValue(1));
1236 /* Nodes color and size */
1237 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1238 vtkFloatingPointType (nodecolor.green()) / 255.,
1239 vtkFloatingPointType (nodecolor.blue()) / 255.);
1242 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1243 vtkFloatingPointType (color0D.green()) / 255.,
1244 vtkFloatingPointType (color0D.blue()) / 255.);
1245 anActor->Set0DSize(aDlg->GetIntValue(3));
1247 /* Faces orientation */
1248 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1249 vtkFloatingPointType(faces_orientation_color.greenF()),
1250 vtkFloatingPointType(faces_orientation_color.blueF())};
1251 anActor->SetFacesOrientationColor(c);
1252 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1253 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1255 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1256 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1257 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1258 if( aMarkerTypeNew != VTK::MT_USER )
1259 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1261 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1262 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1263 if( anIter != aMarkerMap.end() )
1264 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1267 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1268 if( !aGroupObject->_is_nil() )
1270 SMESH::ElementType anElementType = aGroupObject->GetType();
1272 switch( anElementType )
1274 case SMESH::NODE: aColor = nodecolor; break;
1275 case SMESH::EDGE: aColor = edgecolor; break;
1276 default: aColor = color; break;
1279 SALOMEDS::Color aGroupColor;
1280 aGroupColor.R = (float)aColor.red() / 255.0;
1281 aGroupColor.G = (float)aColor.green() / 255.0;
1282 aGroupColor.B = (float)aColor.blue() / 255.0;
1283 aGroupObject->SetColor( aGroupColor );
1288 SMESH::RepaintCurrentView();
1294 SALOME_ListIteratorOfListIO It( selected );
1295 for( ; It.More(); It.Next()){
1296 Handle(SALOME_InteractiveObject) IObject = It.Value();
1297 if(IObject->hasEntry()){
1298 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1299 switch(theCommandID){
1301 anActor->SetRepresentation(SMESH_Actor::eEdge);
1304 anActor->SetRepresentation(SMESH_Actor::eSurface);
1307 if(anActor->IsShrunk())
1308 anActor->UnShrink();
1310 anActor->SetShrink();
1313 anActor->SetRepresentation(SMESH_Actor::ePoint);
1316 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1317 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1320 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1321 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1327 SMESH::RepaintCurrentView();
1331 void Control( int theCommandID )
1333 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1334 SALOME_ListIO selected;
1336 aSel->selectedObjects( selected );
1338 if( !selected.IsEmpty() ){
1339 Handle(SALOME_InteractiveObject) anIO = selected.First();
1341 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1342 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1343 switch ( theCommandID ){
1345 aControl = SMESH_Actor::eLength;
1348 aControl = SMESH_Actor::eLength2D;
1351 aControl = SMESH_Actor::eFreeEdges;
1354 aControl = SMESH_Actor::eFreeBorders;
1357 aControl = SMESH_Actor::eMultiConnection;
1360 aControl = SMESH_Actor::eFreeNodes;
1363 aControl = SMESH_Actor::eMultiConnection2D;
1366 aControl = SMESH_Actor::eArea;
1369 aControl = SMESH_Actor::eTaper;
1372 aControl = SMESH_Actor::eAspectRatio;
1375 aControl = SMESH_Actor::eAspectRatio3D;
1378 aControl = SMESH_Actor::eMinimumAngle;
1381 aControl = SMESH_Actor::eWarping;
1384 aControl = SMESH_Actor::eSkew;
1387 aControl = SMESH_Actor::eVolume3D;
1390 aControl = SMESH_Actor::eFreeFaces;
1393 aControl = SMESH_Actor::eMaxElementLength2D;
1396 aControl = SMESH_Actor::eMaxElementLength3D;
1399 aControl = SMESH_Actor::eBareBorderVolume;
1402 aControl = SMESH_Actor::eBareBorderFace;
1405 aControl = SMESH_Actor::eOverConstrainedVolume;
1408 aControl = SMESH_Actor::eOverConstrainedFace;
1411 anActor->SetControlMode(aControl);
1412 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1413 SMESH::RepaintCurrentView();
1414 #ifndef DISABLE_PLOT2DVIEWER
1415 if(anActor->GetPlot2Histogram()) {
1416 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1417 QString functorName = functorToString( anActor->GetFunctor());
1418 QString aHistogramName("%1 : %2");
1419 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1420 aHistogram->setName(aHistogramName);
1421 aHistogram->setHorTitle(functorName);
1422 SMESH::ProcessIn2DViewers(anActor);
1431 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1432 MeshObjectType theType,
1433 const QString theInTypeName,
1434 QString & theOutTypeName)
1436 SMESH_TypeFilter aTypeFilter( theType );
1438 if( !theIO.IsNull() )
1440 entry = theIO->getEntry();
1441 LightApp_DataOwner owner( entry );
1442 if ( aTypeFilter.isOk( &owner )) {
1443 theOutTypeName = theInTypeName;
1451 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1453 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1454 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1456 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1457 CORBA::String_var anID = aSComp->GetID().c_str();
1458 if (!strcmp(anID.in(),theIO->getEntry()))
1464 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1465 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1466 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1467 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1468 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1476 QString CheckHomogeneousSelection()
1478 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1479 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1480 SALOME_ListIO selected;
1482 aSel->selectedObjects( selected );
1484 QString RefType = CheckTypeObject(selected.First());
1485 SALOME_ListIteratorOfListIO It(selected);
1486 for ( ; It.More(); It.Next())
1488 Handle(SALOME_InteractiveObject) IObject = It.Value();
1489 QString Type = CheckTypeObject(IObject);
1490 if (Type.compare(RefType) != 0)
1491 return "Heterogeneous Selection";
1498 void SMESHGUI::OnEditDelete()
1500 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1501 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1502 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1504 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1505 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1506 _PTR(GenericAttribute) anAttr;
1507 _PTR(AttributeIOR) anIOR;
1509 int objectCount = 0;
1511 QString aParentComponent = QString::null;
1512 Handle(SALOME_InteractiveObject) anIO;
1513 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1515 anIO = anIt.Value();
1516 QString cur = anIO->getComponentDataType();
1517 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1519 // check if object is reference
1520 _PTR(SObject) aRefSObj;
1521 aNameList.append("\n - ");
1522 if ( aSO->ReferencedObject( aRefSObj ) ) {
1523 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1524 aNameList.append( aRefName );
1525 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1528 aNameList.append(anIO->getName());
1532 if( aParentComponent.isNull() )
1533 aParentComponent = cur;
1534 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1535 aParentComponent = "";
1538 if ( objectCount == 0 )
1539 return; // No Valid Objects Selected
1541 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1542 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1543 QObject::tr("ERR_ERROR"),
1544 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1547 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1548 if (SUIT_MessageBox::warning
1549 (SMESHGUI::desktop(),
1550 QObject::tr("SMESH_WRN_WARNING"),
1551 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1552 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1553 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1556 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1558 SALOME_ListIteratorOfListIO It(selected);
1560 aStudyBuilder->NewCommand(); // There is a transaction
1561 for( ; It.More(); It.Next()){ // loop on selected IO's
1562 Handle(SALOME_InteractiveObject) IObject = It.Value();
1563 if(IObject->hasEntry()) {
1564 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1566 // disable removal of "SMESH" component object
1567 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1569 if ( engineIOR() == anIOR->Value().c_str() )
1572 //Check the referenced object
1573 _PTR(SObject) aRefSObject;
1574 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1575 aSO = aRefSObject; // Delete main Object instead of reference
1577 // put the whole hierarchy of sub-objects of the selected SO into a list and
1578 // then treat them all starting from the deepest objects (at list back)
1580 std::list< _PTR(SObject) > listSO;
1581 listSO.push_back( aSO );
1582 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1583 for ( ; itSO != listSO.end(); ++itSO ) {
1584 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1585 for (it->InitEx(false); it->More(); it->Next())
1586 listSO.push_back( it->Value() );
1589 // treat SO's in the list starting from the back
1591 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1592 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1593 _PTR(SObject) SO = *ritSO;
1594 if ( !SO ) continue;
1595 std::string anEntry = SO->GetID();
1597 /** Erase graphical object **/
1598 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1599 ViewManagerList aViewMenegers = anApp->viewManagers();
1600 ViewManagerList::const_iterator it = aViewMenegers.begin();
1601 for( ; it != aViewMenegers.end(); it++) {
1602 SUIT_ViewManager* vm = *it;
1603 int nbSf = vm ? vm->getViewsCount() : 0;
1605 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1606 for(int i = 0; i < nbSf; i++){
1607 SUIT_ViewWindow *sf = aViews[i];
1608 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1609 SMESH::RemoveActor(sf,anActor);
1615 /** Remove an object from data structures **/
1616 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1617 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1618 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1619 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1620 aMesh->RemoveGroup( aGroup );
1622 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1623 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1624 aMesh->RemoveSubMesh( aSubMesh );
1626 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1628 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1631 IObject = new SALOME_InteractiveObject
1632 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1633 QString objType = CheckTypeObject(IObject);
1634 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1635 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1636 aStudyBuilder->RemoveObjectWithChildren( SO );
1638 else {// default action: remove SObject from the study
1639 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1640 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1642 aStudyBuilder->RemoveObjectWithChildren( SO );
1646 } /* listSO back loop */
1647 } /* IObject->hasEntry() */
1650 aStudyBuilder->CommitCommand();
1652 /* Clear any previous selection */
1654 aSel->setSelectedObjects( l1 );
1656 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1661 SMESHGUI_EXPORT CAM_Module* createModule()
1663 return new SMESHGUI();
1666 SMESHGUI_EXPORT char* getModuleVersion() {
1667 return (char*)SMESH_VERSION_STR;
1671 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1673 //=============================================================================
1677 //=============================================================================
1678 SMESHGUI::SMESHGUI() :
1679 SalomeApp_Module( "SMESH" ),
1680 LightApp_Module( "SMESH" )
1682 if ( CORBA::is_nil( myComponentSMESH ) )
1684 CORBA::Boolean anIsEmbeddedMode;
1685 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1686 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1688 // 0019923: EDF 765 SMESH : default values of hypothesis
1689 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1690 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1691 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1692 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1693 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1696 myActiveDialogBox = 0;
1697 myFilterLibraryDlg = 0;
1701 myEventCallbackCommand = vtkCallbackCommand::New();
1702 myEventCallbackCommand->Delete();
1703 myEventCallbackCommand->SetClientData( this );
1704 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1707 SMESH::GetFilterManager();
1708 SMESH::GetPattern();
1709 SMESH::GetMeasurements();
1711 /* load resources for all available meshers */
1712 SMESH::InitAvailableHypotheses();
1715 //=============================================================================
1719 //=============================================================================
1720 SMESHGUI::~SMESHGUI()
1722 #ifdef WITHGENERICOBJ
1723 SMESH::GetFilterManager()->UnRegister();
1724 SMESH::GetMeasurements()->UnRegister();
1726 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1727 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1730 //=============================================================================
1734 //=============================================================================
1735 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1737 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1739 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1744 //=============================================================================
1748 //=============================================================================
1749 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1751 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1755 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1756 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1757 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1758 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1759 return autoUpdate && !exceeded;
1762 //=============================================================================
1766 //=============================================================================
1767 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1769 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1772 //=============================================================================
1776 //=============================================================================
1777 SMESHGUI* SMESHGUI::GetSMESHGUI()
1779 SMESHGUI* smeshMod = 0;
1780 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1783 CAM_Module* module = app->module( "Mesh" );
1784 smeshMod = dynamic_cast<SMESHGUI*>( module );
1787 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1789 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1792 _PTR(Study) aStudy = study->studyDS();
1794 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1803 Standard_EXPORT SMESHGUI* GetComponentGUI()
1805 return SMESHGUI::GetSMESHGUI();
1809 //=============================================================================
1813 //=============================================================================
1814 void SMESHGUI::SetState(int aState)
1819 //=============================================================================
1823 //=============================================================================
1824 void SMESHGUI::ResetState()
1829 //=============================================================================
1833 //=============================================================================
1834 void SMESHGUI::EmitSignalDeactivateDialog()
1836 emit SignalDeactivateActiveDialog();
1839 //=============================================================================
1843 //=============================================================================
1844 void SMESHGUI::EmitSignalStudyFrameChanged()
1846 emit SignalStudyFrameChanged();
1849 //=============================================================================
1853 //=============================================================================
1854 void SMESHGUI::EmitSignalCloseAllDialogs()
1856 emit SignalCloseAllDialogs();
1859 //=============================================================================
1863 //=============================================================================
1864 void SMESHGUI::EmitSignalVisibilityChanged()
1866 emit SignalVisibilityChanged();
1869 //=============================================================================
1873 //=============================================================================
1874 QDialog *SMESHGUI::GetActiveDialogBox()
1876 return myActiveDialogBox;
1879 //=============================================================================
1883 //=============================================================================
1884 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1886 myActiveDialogBox = (QDialog *) aDlg;
1890 //=============================================================================
1894 //=============================================================================
1895 SUIT_Desktop* SMESHGUI::desktop()
1897 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1899 return app->desktop();
1904 //=============================================================================
1908 //=============================================================================
1909 SalomeApp_Study* SMESHGUI::activeStudy()
1911 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1913 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1918 //=============================================================================
1922 //=============================================================================
1923 void SMESHGUI::Modified( bool theIsUpdateActions )
1925 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1926 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1927 appStudy->Modified();
1928 if( theIsUpdateActions )
1929 app->updateActions();
1934 //=============================================================================
1938 //=============================================================================
1939 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1941 /* Here the position is on the bottom right corner - 10 */
1942 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1944 SUIT_Desktop *PP = desktop();
1945 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1946 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1950 //=============================================================================
1954 //=============================================================================
1955 static int isStudyLocked(_PTR(Study) theStudy){
1956 return theStudy->GetProperties()->IsLocked();
1959 static bool checkLock(_PTR(Study) theStudy) {
1960 if (isStudyLocked(theStudy)) {
1961 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1962 QObject::tr("WRN_WARNING"),
1963 QObject::tr("WRN_STUDY_LOCKED") );
1969 //=======================================================================
1970 //function : CheckActiveStudyLocked
1972 //=======================================================================
1974 bool SMESHGUI::isActiveStudyLocked()
1976 _PTR(Study) aStudy = activeStudy()->studyDS();
1977 return checkLock( aStudy );
1980 //=============================================================================
1984 //=============================================================================
1985 bool SMESHGUI::OnGUIEvent( int theCommandID )
1987 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1991 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1992 SUIT_ResourceMgr* mgr = resourceMgr();
1996 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1997 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2000 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2001 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2003 //QAction* act = action( theCommandID );
2005 switch (theCommandID) {
2007 if(checkLock(aStudy)) break;
2018 if(checkLock(aStudy)) break;
2019 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2023 case 150: //MED FILE INFORMATION
2025 SALOME_ListIO selected;
2026 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2028 aSel->selectedObjects( selected );
2029 if( selected.Extent() )
2031 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2032 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2033 if ( !aMesh->_is_nil() )
2035 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2042 case 122: // EXPORT MED
2055 ::ExportMeshToFile(theCommandID);
2059 case 200: // SCALAR BAR
2061 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2062 SALOME_ListIO selected;
2064 aSel->selectedObjects( selected );
2066 if( selected.Extent() ) {
2067 Handle(SALOME_InteractiveObject) anIO = selected.First();
2068 if( anIO->hasEntry() ) {
2069 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2070 anActor->SetControlMode( SMESH_Actor::eNone );
2071 #ifndef DISABLE_PLOT2DVIEWER
2072 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2081 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2086 // dump control distribution data to the text file
2087 ::SaveDistribution();
2093 // show/ distribution
2094 ::ShowDistribution();
2098 #ifndef DISABLE_PLOT2DVIEWER
2101 // plot distribution
2102 ::PlotDistribution();
2113 ::DisableAutoColor();
2116 case 1134: // Clipping
2117 case 1133: // Tranparency
2118 case 1132: // Colors / Size
2125 ::SetDisplayMode(theCommandID, myMarkerMap);
2128 //2D quadratic representation
2131 ::SetDisplayMode(theCommandID, myMarkerMap);
2135 case 216: // 0D elements
2138 case 219: // Volumes
2139 case 220: // All Entity
2140 ::SetDisplayEntity(theCommandID);
2143 case 221: // Orientation of faces
2145 LightApp_SelectionMgr* mgr = selectionMgr();
2146 SALOME_ListIO selected; mgr->selectedObjects( selected );
2148 SALOME_ListIteratorOfListIO it(selected);
2149 for( ; it.More(); it.Next()) {
2150 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2151 if(anIObject->hasEntry()) {
2152 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2153 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2162 if(checkLock(aStudy)) break;
2164 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2167 SMESH::UpdateView();
2169 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2170 SMESH::OnVisuException();
2172 catch (...) { // PAL16774 (Crash after display of many groups)
2173 SMESH::OnVisuException();
2177 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2178 aSel->selectedObjects( l );
2179 aSel->setSelectedObjects( l );
2184 case 301: // DISPLAY
2185 case 302: // DISPLAY ONLY
2187 SMESH::EDisplaing anAction;
2188 switch (theCommandID) {
2189 case 300: anAction = SMESH::eErase; break;
2190 case 301: anAction = SMESH::eDisplay; break;
2191 case 302: anAction = SMESH::eDisplayOnly; break;
2194 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2195 SALOME_ListIO sel_objects, to_process;
2197 aSel->selectedObjects( sel_objects );
2199 if( theCommandID==302 )
2201 MESSAGE("anAction = SMESH::eDisplayOnly");
2202 startOperation( myEraseAll );
2205 extractContainers( sel_objects, to_process );
2208 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2212 SALOME_ListIteratorOfListIO It( to_process );
2213 for ( ; It.More(); It.Next()) {
2215 Handle(SALOME_InteractiveObject) IOS = It.Value();
2216 if (IOS->hasEntry()) {
2218 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2219 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2220 break; // PAL16774 (Crash after display of many groups)
2222 if (anAction == SMESH::eDisplayOnly)
2224 MESSAGE("anAction = SMESH::eDisplayOnly");
2225 anAction = SMESH::eDisplay;
2231 // PAL13338 + PAL15161 -->
2232 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2233 MESSAGE("anAction = SMESH::eDisplayOnly");
2234 SMESH::UpdateView();
2235 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2237 // PAL13338 + PAL15161 <--
2239 catch (...) { // PAL16774 (Crash after display of many groups)
2240 SMESH::OnVisuException();
2243 if (anAction == SMESH::eErase) {
2244 MESSAGE("anAction == SMESH::eErase");
2246 aSel->setSelectedObjects( l1 );
2249 aSel->setSelectedObjects( to_process );
2256 if(checkLock(aStudy)) break;
2259 EmitSignalDeactivateDialog();
2261 ( new SMESHGUI_NodesDlg( this ) )->show();
2264 SUIT_MessageBox::warning(desktop(),
2265 tr("SMESH_WRN_WARNING"),
2266 tr("SMESH_WRN_VIEWER_VTK"));
2271 case 2151: // FILTER
2275 EmitSignalDeactivateDialog();
2276 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2281 case 701: // COMPUTE MESH
2282 case 711: // PRECOMPUTE MESH
2283 case 712: // EVALUATE MESH
2284 case 713: // MESH ORDER
2286 if (checkLock(aStudy)) break;
2287 startOperation( theCommandID );
2291 case 702: // Create mesh
2292 case 703: // Create sub-mesh
2293 case 704: // Edit mesh/sub-mesh
2294 startOperation( theCommandID );
2296 case 705: // copy mesh
2298 if (checkLock(aStudy)) break;
2299 EmitSignalDeactivateDialog();
2300 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2303 case 710: // Build compound mesh
2305 if (checkLock(aStudy)) break;
2306 EmitSignalDeactivateDialog();
2307 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2311 case 407: // DIAGONAL INVERSION
2312 case 408: // Delete diagonal
2316 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2317 tr( "NOT_A_VTK_VIEWER" ) );
2321 if ( checkLock( aStudy ) )
2324 /*Standard_Boolean aRes;
2325 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2326 if ( aMesh->_is_nil() )
2328 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2329 tr( "SMESH_BAD_SELECTION" ) );
2333 EmitSignalDeactivateDialog();
2334 if ( theCommandID == 407 )
2335 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2337 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2340 case 409: // Change orientation
2341 case 410: // Union of triangles
2342 case 411: // Cutting of quadrangles
2343 case 419: // Splitting volumes into tetrahedra
2347 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2348 tr( "NOT_A_VTK_VIEWER" ) );
2352 if ( checkLock( aStudy ) )
2355 EmitSignalDeactivateDialog();
2356 SMESHGUI_MultiEditDlg* aDlg = NULL;
2357 if ( theCommandID == 409 )
2358 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2359 else if ( theCommandID == 410 )
2360 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2361 else if ( theCommandID == 419 )
2362 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2364 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2369 case 412: // Smoothing
2371 if(checkLock(aStudy)) break;
2373 EmitSignalDeactivateDialog();
2374 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2377 SUIT_MessageBox::warning(desktop(),
2378 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2382 case 413: // Extrusion
2384 if (checkLock(aStudy)) break;
2386 EmitSignalDeactivateDialog();
2387 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2389 SUIT_MessageBox::warning(desktop(),
2390 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2394 case 414: // Revolution
2396 if(checkLock(aStudy)) break;
2398 EmitSignalDeactivateDialog();
2399 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2402 SUIT_MessageBox::warning(desktop(),
2403 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2407 case 415: // Pattern mapping
2409 if ( checkLock( aStudy ) )
2413 EmitSignalDeactivateDialog();
2414 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2417 SUIT_MessageBox::warning(desktop(),
2418 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2422 case 416: // Extrusion along a path
2424 if (checkLock(aStudy)) break;
2426 EmitSignalDeactivateDialog();
2427 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2429 SUIT_MessageBox::warning(desktop(),
2430 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2434 case 417: // Convert mesh to quadratic
2436 startOperation( 417 );
2437 /* if (checkLock(aStudy)) break;
2439 EmitSignalDeactivateDialog();
2440 new SMESHGUI_ConvToQuadDlg();
2442 SUIT_MessageBox::warning(desktop(),
2443 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2447 case 418: // create 2D mesh from 3D
2449 startOperation( 418 );
2452 case 806: // CREATE GEO GROUP
2454 startOperation( 806 );
2457 case 801: // CREATE GROUP
2461 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2462 tr( "NOT_A_VTK_VIEWER" ) );
2466 if(checkLock(aStudy)) break;
2467 EmitSignalDeactivateDialog();
2468 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2470 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2471 SALOME_ListIO selected;
2473 aSel->selectedObjects( selected );
2475 int nbSel = selected.Extent();
2477 // check if mesh is selected
2478 aMesh = SMESH::GetMeshByIO( selected.First() );
2480 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2485 case 802: // CONSTRUCT GROUP
2489 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2490 tr( "NOT_A_VTK_VIEWER" ) );
2494 if(checkLock(aStudy)) break;
2495 EmitSignalDeactivateDialog();
2497 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2498 SALOME_ListIO selected;
2500 aSel->selectedObjects( selected );
2502 int nbSel = selected.Extent();
2504 // check if submesh is selected
2505 Handle(SALOME_InteractiveObject) IObject = selected.First();
2506 if (IObject->hasEntry()) {
2507 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2509 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2510 if (!aSubMesh->_is_nil()) {
2512 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2513 // get submesh elements list by types
2514 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2515 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2516 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2517 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2518 // create group for each type o elements
2519 QString aName = IObject->getName();
2520 QStringList anEntryList;
2521 if (aNodes->length() > 0) {
2522 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2523 aGroup->Add(aNodes.inout());
2524 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2525 anEntryList.append( aSObject->GetID().c_str() );
2527 if (aEdges->length() > 0) {
2528 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2529 aGroup->Add(aEdges.inout());
2530 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2531 anEntryList.append( aSObject->GetID().c_str() );
2533 if (aFaces->length() > 0) {
2534 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2535 aGroup->Add(aFaces.inout());
2536 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2537 anEntryList.append( aSObject->GetID().c_str() );
2539 if (aVolumes->length() > 0) {
2540 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2541 aGroup->Add(aVolumes.inout());
2542 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2543 anEntryList.append( aSObject->GetID().c_str() );
2546 anApp->browseObjects( anEntryList );
2548 catch(const SALOME::SALOME_Exception & S_ex){
2549 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2556 SUIT_MessageBox::warning(desktop(),
2557 tr("SMESH_WRN_WARNING"),
2558 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2563 case 803: // EDIT GROUP
2567 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2568 tr( "NOT_A_VTK_VIEWER" ) );
2572 if(checkLock(aStudy)) break;
2573 EmitSignalDeactivateDialog();
2575 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2576 SALOME_ListIO selected;
2578 aSel->selectedObjects( selected );
2580 SALOME_ListIteratorOfListIO It (selected);
2581 int nbSelectedGroups = 0;
2582 for ( ; It.More(); It.Next() )
2584 SMESH::SMESH_GroupBase_var aGroup =
2585 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2586 if (!aGroup->_is_nil()) {
2588 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2592 if (nbSelectedGroups == 0)
2594 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2600 case 804: // Add elements to group
2602 if(checkLock(aStudy)) break;
2603 if (myState == 800) {
2604 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2605 if (aDlg) aDlg->onAdd();
2610 case 805: // Remove elements from group
2612 if(checkLock(aStudy)) break;
2613 if (myState == 800) {
2614 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2615 if (aDlg) aDlg->onRemove();
2620 case 815: // Edit GEOM GROUP as standalone
2624 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2625 tr( "NOT_A_VTK_VIEWER" ) );
2629 if(checkLock(aStudy)) break;
2630 EmitSignalDeactivateDialog();
2632 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2633 SALOME_ListIO selected;
2635 aSel->selectedObjects( selected );
2637 SALOME_ListIteratorOfListIO It (selected);
2638 for ( ; It.More(); It.Next() )
2640 SMESH::SMESH_GroupOnGeom_var aGroup =
2641 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2642 if (!aGroup->_is_nil()) {
2643 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2648 SMESH::SMESH_GroupOnFilter_var aGroup =
2649 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2650 if (!aGroup->_is_nil()) {
2651 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2659 case 810: // Union Groups
2660 case 811: // Intersect groups
2661 case 812: // Cut groups
2665 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2666 tr( "NOT_A_VTK_VIEWER" ) );
2670 if ( checkLock( aStudy ) )
2673 EmitSignalDeactivateDialog();
2675 SMESHGUI_GroupOpDlg* aDlg = 0;
2676 if ( theCommandID == 810 )
2677 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2678 else if ( theCommandID == 811 )
2679 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2681 aDlg = new SMESHGUI_CutGroupsDlg( this );
2688 case 814: // Create groups of entities from existing groups of superior dimensions
2690 if ( checkLock( aStudy ) )
2693 EmitSignalDeactivateDialog();
2694 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2700 case 813: // Delete groups with their contents
2704 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2705 tr( "NOT_A_VTK_VIEWER" ) );
2709 if ( checkLock( aStudy ) )
2712 EmitSignalDeactivateDialog();
2714 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2718 case 900: // MESH INFOS
2719 case 903: // WHAT IS
2721 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2722 EmitSignalDeactivateDialog();
2723 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2724 SALOME_ListIO selected;
2726 aSel->selectedObjects( selected );
2728 if ( selected.Extent() > 1 ) { // a dlg for each IO
2729 SALOME_ListIteratorOfListIO It( selected );
2730 for ( ; It.More(); It.Next() ) {
2731 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2732 dlg->showInfo( It.Value() );
2737 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2743 case 902: // STANDARD MESH INFOS
2745 EmitSignalDeactivateDialog();
2746 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2747 SALOME_ListIO selected;
2749 aSel->selectedObjects( selected );
2751 if ( selected.Extent() > 1 ) { // a dlg for each IO
2753 SALOME_ListIteratorOfListIO It (selected);
2754 for ( ; It.More(); It.Next() ) {
2756 IOs.Append( It.Value() );
2757 aSel->setSelectedObjects( IOs );
2758 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2760 // restore selection
2761 aSel->setSelectedObjects( selected );
2764 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2767 case 903: // WHAT IS
2769 EmitSignalDeactivateDialog();
2770 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2775 case 904: // FIND ELEM
2777 startOperation( theCommandID );
2781 case 1100: // EDIT HYPOTHESIS
2783 if(checkLock(aStudy)) break;
2785 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2786 SALOME_ListIO selected;
2788 aSel->selectedObjects( selected );
2790 int nbSel = selected.Extent();
2793 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2794 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2796 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2797 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2798 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2799 if ( !aHypothesis->_is_nil() )
2802 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2803 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2805 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2815 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2817 if(checkLock(aStudy)) break;
2818 SUIT_OverrideCursor wc;
2820 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2821 SALOME_ListIO selected;
2823 aSel->selectedObjects( selected, QString::null, false );
2825 SALOME_ListIteratorOfListIO It(selected);
2826 for (int i = 0; It.More(); It.Next(), i++) {
2827 Handle(SALOME_InteractiveObject) IObject = It.Value();
2828 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2831 aSel->setSelectedObjects( l1 );
2836 case 4009: // ELEM0D
2837 case 4010: // GEOM::EDGE
2838 case 4021: // TRIANGLE
2840 case 4023: // POLYGON
2844 if(checkLock(aStudy)) break;
2846 EmitSignalDeactivateDialog();
2847 SMDSAbs_ElementType type = SMDSAbs_Edge;
2849 switch (theCommandID) {
2850 case 4009: // ELEM0D
2851 type = SMDSAbs_0DElement; nbNodes = 1; break;
2852 case 4021: // TRIANGLE
2853 type = SMDSAbs_Face; nbNodes = 3; break;
2855 type = SMDSAbs_Face; nbNodes = 4; break;
2857 type = SMDSAbs_Volume; nbNodes = 4; break;
2858 case 4023: // POLYGON
2859 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2861 type = SMDSAbs_Volume; nbNodes = 8; break;
2862 case 4033: // POLYHEDRE
2863 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2866 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2869 SUIT_MessageBox::warning(desktop(),
2870 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2874 case 4033: // POLYHEDRON
2876 if(checkLock(aStudy)) break;
2878 EmitSignalDeactivateDialog();
2879 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2882 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2883 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2887 case 4034: // QUADRATIC EDGE
2888 case 4035: // QUADRATIC TRIANGLE
2889 case 4036: // QUADRATIC QUADRANGLE
2890 case 4037: // QUADRATIC TETRAHEDRON
2891 case 4038: // QUADRATIC PYRAMID
2892 case 4039: // QUADRATIC PENTAHEDRON
2893 case 4040: // QUADRATIC HEXAHEDRON
2895 if(checkLock(aStudy)) break;
2897 EmitSignalDeactivateDialog();
2900 switch (theCommandID) {
2902 type = QUAD_EDGE; break;
2904 type = QUAD_TRIANGLE; break;
2906 type = QUAD_QUADRANGLE; break;
2908 type = QUAD_TETRAHEDRON; break;
2910 type = QUAD_PYRAMID; break;
2912 type = QUAD_PENTAHEDRON; break;
2914 type = QUAD_HEXAHEDRON;
2918 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2921 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2922 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2926 case 4041: // REMOVES NODES
2928 if(checkLock(aStudy)) break;
2930 EmitSignalDeactivateDialog();
2931 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2934 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2935 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2939 case 4042: // REMOVES ELEMENTS
2941 if(checkLock(aStudy)) break;
2943 EmitSignalDeactivateDialog();
2944 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2948 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2949 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2953 case 4043: { // CLEAR_MESH
2955 if(checkLock(aStudy)) break;
2957 SALOME_ListIO selected;
2958 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2959 aSel->selectedObjects( selected );
2961 SUIT_OverrideCursor wc;
2962 SALOME_ListIteratorOfListIO It (selected);
2963 for ( ; It.More(); It.Next() )
2965 Handle(SALOME_InteractiveObject) IOS = It.Value();
2966 SMESH::SMESH_Mesh_var aMesh =
2967 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2968 if ( aMesh->_is_nil()) continue;
2970 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2972 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2973 SMESH::ModifiedMesh( aMeshSObj, false, true);
2974 // hide groups and submeshes
2975 _PTR(ChildIterator) anIter =
2976 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2977 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2979 _PTR(SObject) so = anIter->Value();
2980 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2983 catch (const SALOME::SALOME_Exception& S_ex){
2985 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2989 SMESH::UpdateView();
2993 case 4044: // REMOVE ORPHAN NODES
2995 if(checkLock(aStudy)) break;
2996 SALOME_ListIO selected;
2997 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2998 aSel->selectedObjects( selected );
2999 if ( selected.Extent() == 1 ) {
3000 Handle(SALOME_InteractiveObject) anIO = selected.First();
3001 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3002 if ( !aMesh->_is_nil() ) {
3003 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3004 tr( "SMESH_WARNING" ),
3005 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3006 SUIT_MessageBox::Yes |
3007 SUIT_MessageBox::No,
3008 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3011 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3012 int removed = aMeshEditor->RemoveOrphanNodes();
3013 SUIT_MessageBox::information(SMESHGUI::desktop(),
3014 tr("SMESH_INFORMATION"),
3015 tr("NB_NODES_REMOVED").arg(removed));
3016 if ( removed > 0 ) {
3017 SMESH::UpdateView();
3018 SMESHGUI::Modified();
3021 catch (const SALOME::SALOME_Exception& S_ex) {
3022 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3031 case 4051: // RENUMBERING NODES
3033 if(checkLock(aStudy)) break;
3035 EmitSignalDeactivateDialog();
3036 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3040 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3041 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3045 case 4052: // RENUMBERING ELEMENTS
3047 if(checkLock(aStudy)) break;
3049 EmitSignalDeactivateDialog();
3050 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3054 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3055 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3059 case 4061: // TRANSLATION
3061 if(checkLock(aStudy)) break;
3063 EmitSignalDeactivateDialog();
3064 ( new SMESHGUI_TranslationDlg( this ) )->show();
3067 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3068 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3072 case 4062: // ROTATION
3074 if(checkLock(aStudy)) break;
3076 EmitSignalDeactivateDialog();
3077 ( new SMESHGUI_RotationDlg( this ) )->show();
3080 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3081 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3085 case 4063: // SYMMETRY
3087 if(checkLock(aStudy)) break;
3089 EmitSignalDeactivateDialog();
3090 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3093 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3094 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3098 case 4064: // SEWING
3100 if(checkLock(aStudy)) break;
3102 EmitSignalDeactivateDialog();
3103 ( new SMESHGUI_SewingDlg( this ) )->show();
3106 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3107 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3111 case 4065: // MERGE NODES
3113 if(checkLock(aStudy)) break;
3115 EmitSignalDeactivateDialog();
3116 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3119 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3120 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3124 case 4066: // MERGE EQUAL ELEMENTS
3126 if (checkLock(aStudy)) break;
3128 EmitSignalDeactivateDialog();
3129 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3131 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3132 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3137 case 4067: // MAKE MESH PASS THROUGH POINT
3138 startOperation( 4067 );
3143 if(checkLock(aStudy)) break;
3145 EmitSignalDeactivateDialog();
3146 ( new SMESHGUI_ScaleDlg( this ) )->show();
3149 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3150 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3155 case 4069: // DUPLICATE NODES
3157 if(checkLock(aStudy)) break;
3159 EmitSignalDeactivateDialog();
3160 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3163 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3164 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3169 case 5105: // Library of selection filters
3171 static QList<int> aTypes;
3172 if ( aTypes.isEmpty() )
3174 aTypes.append( SMESH::NODE );
3175 aTypes.append( SMESH::EDGE );
3176 aTypes.append( SMESH::FACE );
3177 aTypes.append( SMESH::VOLUME );
3179 if (!myFilterLibraryDlg)
3180 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3181 else if (myFilterLibraryDlg->isHidden())
3182 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3183 myFilterLibraryDlg->raise();
3187 case 6017: // CONTROLS
3211 LightApp_SelectionMgr* mgr = selectionMgr();
3212 SALOME_ListIO selected; mgr->selectedObjects( selected );
3214 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3215 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3217 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3218 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3219 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3220 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3221 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3222 ::Control( theCommandID );
3227 SUIT_MessageBox::warning(desktop(),
3228 tr( "SMESH_WRN_WARNING" ),
3229 tr( "SMESH_BAD_SELECTION" ) );
3233 SUIT_MessageBox::warning(desktop(),
3234 tr( "SMESH_WRN_WARNING" ),
3235 tr( "NOT_A_VTK_VIEWER" ) );
3240 LightApp_SelectionMgr* mgr = selectionMgr();
3241 SALOME_ListIO selected; mgr->selectedObjects( selected );
3243 SALOME_ListIteratorOfListIO it(selected);
3244 for( ; it.More(); it.Next()) {
3245 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3246 if(anIObject->hasEntry()) {
3247 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3248 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3256 LightApp_SelectionMgr* mgr = selectionMgr();
3257 SALOME_ListIO selected; mgr->selectedObjects( selected );
3259 SALOME_ListIteratorOfListIO it(selected);
3260 for( ; it.More(); it.Next()) {
3261 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3262 if(anIObject->hasEntry())
3263 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3264 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3272 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3273 EmitSignalDeactivateDialog();
3274 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3280 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3281 //updateObjBrowser();
3285 //=============================================================================
3289 //=============================================================================
3290 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3295 //=============================================================================
3299 //=============================================================================
3300 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3305 //=============================================================================
3309 //=============================================================================
3310 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3315 //=============================================================================
3316 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3317 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3319 //=============================================================================
3320 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3321 SUIT_ViewWindow* wnd )
3323 if(theIO->hasEntry()){
3324 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3325 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3329 //=======================================================================
3330 // function : createSMESHAction
3332 //=======================================================================
3333 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3334 const int key, const bool toggle, const QString& shortcutAction )
3337 QWidget* parent = application()->desktop();
3338 SUIT_ResourceMgr* resMgr = resourceMgr();
3340 if ( !icon_id.isEmpty() )
3341 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3343 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3344 if ( !pix.isNull() )
3345 icon = QIcon( pix );
3347 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3348 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3349 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3351 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3352 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3355 //=======================================================================
3356 // function : createPopupItem
3358 //=======================================================================
3359 void SMESHGUI::createPopupItem( const int id,
3360 const QString& clients,
3361 const QString& types,
3362 const QString& theRule,
3367 parentId = popupMgr()->actionId( action( pId ) );
3369 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3370 popupMgr()->insert( action( id ), parentId, 0 );
3372 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3373 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3374 QString rule = "(%1) and (%2) and (%3)";
3375 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3376 if( clients.isEmpty() )
3377 rule = rule.arg( QString( "true" ) );
3379 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3380 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3383 bool cont = myRules.contains( id );
3385 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3387 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3388 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3391 //=======================================================================
3392 // function : initialize
3394 //=======================================================================
3395 void SMESHGUI::initialize( CAM_Application* app )
3397 SalomeApp_Module::initialize( app );
3399 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3401 /* Automatic Update flag */
3402 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3404 // ----- create actions --------------
3406 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3407 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3408 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3409 createSMESHAction( 114, "NUM" );
3410 createSMESHAction( 115, "STL" );
3411 createSMESHAction( 116, "CGNS" );
3412 createSMESHAction( 117, "SAUV" );
3413 createSMESHAction( 121, "DAT" );
3414 createSMESHAction( 122, "MED" );
3415 createSMESHAction( 123, "UNV" );
3416 createSMESHAction( 140, "STL" );
3417 createSMESHAction( 142, "CGNS" );
3418 createSMESHAction( 144, "SAUV" );
3419 createSMESHAction( 124, "EXPORT_DAT" );
3420 createSMESHAction( 125, "EXPORT_MED" );
3421 createSMESHAction( 126, "EXPORT_UNV" );
3422 createSMESHAction( 141, "EXPORT_STL" );
3423 createSMESHAction( 143, "EXPORT_CGNS" );
3424 createSMESHAction( 145, "EXPORT_SAUV" );
3425 createSMESHAction( 150, "FILE_INFO" );
3426 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3427 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3428 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3429 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3430 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3431 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3432 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3433 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3434 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3435 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3436 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3437 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3438 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3439 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3440 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3441 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3442 createSMESHAction( 804, "ADD" );
3443 createSMESHAction( 805, "REMOVE" );
3444 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3445 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3446 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3447 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3448 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3449 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3450 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3451 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3452 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3453 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3454 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3455 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3456 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3457 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3458 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3459 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3460 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3461 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3462 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3463 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3464 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3465 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3466 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3467 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3468 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3469 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3470 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3471 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3472 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3473 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3474 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3475 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3476 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3477 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3478 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3479 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3480 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3481 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3482 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3483 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3484 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3485 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3486 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3487 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3488 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3489 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3490 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3491 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3492 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3493 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3494 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3495 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3496 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3497 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3498 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3499 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3500 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3501 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3502 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3503 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3504 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3505 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3506 createSMESHAction( 415, "MAP", "ICON_MAP" );
3507 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3508 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3509 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3510 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3511 createSMESHAction( 200, "RESET" );
3512 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3513 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3514 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3515 #ifndef DISABLE_PLOT2DVIEWER
3516 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3518 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3519 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3520 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3521 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3522 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3523 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3524 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3525 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3526 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3527 createSMESHAction( 220, "ALL" );
3528 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3530 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3531 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3533 createSMESHAction( 1100, "EDIT_HYPO" );
3534 createSMESHAction( 1102, "UNASSIGN" );
3535 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3536 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3537 createSMESHAction( 1131, "DISPMODE" );
3538 createSMESHAction( 1132, "COLORS" );
3539 createSMESHAction( 1133, "TRANSP" );
3540 createSMESHAction( 1134, "CLIP" );
3541 createSMESHAction( 1135, "DISP_ENT" );
3542 createSMESHAction( 1136, "AUTO_COLOR" );
3543 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3544 createSMESHAction( 2000, "CTRL" );
3546 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3547 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3549 createSMESHAction( 300, "ERASE" );
3550 createSMESHAction( 301, "DISPLAY" );
3551 createSMESHAction( 302, "DISPLAY_ONLY" );
3552 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3553 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3554 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3555 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3556 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3557 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3558 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3559 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3561 // ----- create menu --------------
3562 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3563 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3564 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3565 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3566 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3567 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3568 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3569 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3571 createMenu( separator(), fileId );
3573 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3574 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3575 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3576 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3577 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3578 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3579 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3580 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3581 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3582 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3584 createMenu( 111, importId, -1 );
3585 createMenu( 112, importId, -1 );
3586 createMenu( 113, importId, -1 );
3587 createMenu( 115, importId, -1 );
3589 createMenu( 116, importId, -1 );
3591 createMenu( 117, importId, -1 );
3592 createMenu( 121, exportId, -1 );
3593 createMenu( 122, exportId, -1 );
3594 createMenu( 123, exportId, -1 );
3595 createMenu( 140, exportId, -1 ); // export to STL
3597 createMenu( 142, exportId, -1 ); // export to CGNS
3599 createMenu( 144, exportId, -1 ); // export to SAUV
3600 createMenu( separator(), fileId, 10 );
3602 createMenu( 33, editId, -1 );
3604 createMenu( 5105, toolsId, -1 );
3606 createMenu( 702, meshId, -1 ); // "Mesh" menu
3607 createMenu( 703, meshId, -1 );
3608 createMenu( 704, meshId, -1 );
3609 createMenu( 710, meshId, -1 );
3610 createMenu( 705, meshId, -1 );
3611 createMenu( separator(), meshId, -1 );
3612 createMenu( 701, meshId, -1 );
3613 createMenu( 711, meshId, -1 );
3614 createMenu( 712, meshId, -1 );
3615 createMenu( 713, meshId, -1 );
3616 createMenu( separator(), meshId, -1 );
3617 createMenu( 801, meshId, -1 );
3618 createMenu( 806, meshId, -1 );
3619 createMenu( 802, meshId, -1 );
3620 createMenu( 803, meshId, -1 );
3621 createMenu( 815, meshId, -1 );
3622 createMenu( separator(), meshId, -1 );
3623 createMenu( 810, meshId, -1 );
3624 createMenu( 811, meshId, -1 );
3625 createMenu( 812, meshId, -1 );
3626 createMenu( separator(), meshId, -1 );
3627 createMenu( 814, meshId, -1 );
3628 createMenu( separator(), meshId, -1 );
3629 createMenu( 900, meshId, -1 );
3630 //createMenu( 902, meshId, -1 );
3631 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3632 createMenu( 904, meshId, -1 );
3633 createMenu( separator(), meshId, -1 );
3635 createMenu( 6005, nodeId, -1 );
3636 createMenu( 6002, edgeId, -1 );
3637 createMenu( 6003, edgeId, -1 );
3638 createMenu( 6001, edgeId, -1 );
3639 createMenu( 6004, edgeId, -1 );
3640 createMenu( 6021, faceId, -1 );
3641 createMenu( 6025, faceId, -1 );
3642 createMenu( 6027, faceId, -1 );
3643 createMenu( 6018, faceId, -1 );
3644 createMenu( 6019, faceId, -1 );
3645 createMenu( 6011, faceId, -1 );
3646 createMenu( 6012, faceId, -1 );
3647 createMenu( 6013, faceId, -1 );
3648 createMenu( 6014, faceId, -1 );
3649 createMenu( 6015, faceId, -1 );
3650 createMenu( 6016, faceId, -1 );
3651 createMenu( 6022, faceId, -1 );
3652 createMenu( 6017, volumeId, -1 );
3653 createMenu( 6009, volumeId, -1 );
3654 createMenu( 6023, volumeId, -1 );
3655 createMenu( 6024, volumeId, -1 );
3656 createMenu( 6026, volumeId, -1 );
3658 createMenu( 4000, addId, -1 );
3659 createMenu( 4009, addId, -1 );
3660 createMenu( 4010, addId, -1 );
3661 createMenu( 4021, addId, -1 );
3662 createMenu( 4022, addId, -1 );
3663 createMenu( 4023, addId, -1 );
3664 createMenu( 4031, addId, -1 );
3665 createMenu( 4032, addId, -1 );
3666 createMenu( 4033, addId, -1 );
3667 createMenu( separator(), addId, -1 );
3668 createMenu( 4034, addId, -1 );
3669 createMenu( 4035, addId, -1 );
3670 createMenu( 4036, addId, -1 );
3671 createMenu( 4037, addId, -1 );
3672 createMenu( 4038, addId, -1 );
3673 createMenu( 4039, addId, -1 );
3674 createMenu( 4040, addId, -1 );
3676 createMenu( 4041, removeId, -1 );
3677 createMenu( 4042, removeId, -1 );
3678 createMenu( 4044, removeId, -1 );
3679 createMenu( separator(), removeId, -1 );
3680 createMenu( 813, removeId, -1 );
3681 createMenu( separator(), removeId, -1 );
3682 createMenu( 4043, removeId, -1 );
3684 createMenu( 4051, renumId, -1 );
3685 createMenu( 4052, renumId, -1 );
3687 createMenu( 4061, transfId, -1 );
3688 createMenu( 4062, transfId, -1 );
3689 createMenu( 4063, transfId, -1 );
3690 createMenu( 4068, transfId, -1 );
3691 createMenu( 4064, transfId, -1 );
3692 createMenu( 4065, transfId, -1 );
3693 createMenu( 4066, transfId, -1 );
3694 createMenu( 4069, transfId, -1 );
3696 createMenu( 4067,modifyId, -1 );
3697 createMenu( 407, modifyId, -1 );
3698 createMenu( 408, modifyId, -1 );
3699 createMenu( 409, modifyId, -1 );
3700 createMenu( 410, modifyId, -1 );
3701 createMenu( 411, modifyId, -1 );
3702 createMenu( 419, modifyId, -1 );
3703 createMenu( 412, modifyId, -1 );
3704 createMenu( 413, modifyId, -1 );
3705 createMenu( 416, modifyId, -1 );
3706 createMenu( 414, modifyId, -1 );
3707 createMenu( 415, modifyId, -1 );
3708 createMenu( 417, modifyId, -1 );
3709 createMenu( 418, modifyId, -1 );
3711 createMenu( 501, measureId, -1 );
3712 createMenu( 502, measureId, -1 );
3713 createMenu( 214, viewId, -1 );
3715 // ----- create toolbars --------------
3716 int meshTb = createTool( tr( "TB_MESH" ) ),
3717 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3718 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3719 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3720 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3722 createTool( 702, meshTb );
3723 createTool( 703, meshTb );
3724 createTool( 704, meshTb );
3725 createTool( 710, meshTb );
3726 createTool( 705, meshTb );
3727 createTool( separator(), meshTb );
3728 createTool( 701, meshTb );
3729 createTool( 711, meshTb );
3730 createTool( 712, meshTb );
3731 createTool( 713, meshTb );
3732 createTool( separator(), meshTb );
3733 createTool( 801, meshTb );
3734 createTool( 806, meshTb );
3735 createTool( 802, meshTb );
3736 createTool( 803, meshTb );
3737 //createTool( 815, meshTb );
3738 createTool( separator(), meshTb );
3739 createTool( 900, meshTb );
3740 //createTool( 902, meshTb );
3741 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3742 createTool( 904, meshTb );
3743 createTool( separator(), meshTb );
3745 createTool( 6005, ctrlTb );
3746 createTool( separator(), ctrlTb );
3747 createTool( 6002, ctrlTb );
3748 createTool( 6003, ctrlTb );
3749 createTool( 6001, ctrlTb );
3750 createTool( 6004, ctrlTb );
3751 createTool( separator(), ctrlTb );
3752 createTool( 6021, ctrlTb );
3753 createTool( 6025, ctrlTb );
3754 createTool( 6027, ctrlTb );
3755 createTool( 6018, ctrlTb );
3756 createTool( 6019, ctrlTb );
3757 createTool( 6011, ctrlTb );
3758 createTool( 6012, ctrlTb );
3759 createTool( 6013, ctrlTb );
3760 createTool( 6014, ctrlTb );
3761 createTool( 6015, ctrlTb );
3762 createTool( 6016, ctrlTb );
3763 createTool( 6022, ctrlTb );
3764 createTool( separator(), ctrlTb );
3765 createTool( 6017, ctrlTb );
3766 createTool( 6009, ctrlTb );
3767 createTool( 6023, ctrlTb );
3768 createTool( 6024, ctrlTb );
3769 createTool( 6026, ctrlTb );
3770 createTool( separator(), ctrlTb );
3772 createTool( 4000, addRemTb );
3773 createTool( 4009, addRemTb );
3774 createTool( 4010, addRemTb );
3775 createTool( 4021, addRemTb );
3776 createTool( 4022, addRemTb );
3777 createTool( 4023, addRemTb );
3778 createTool( 4031, addRemTb );
3779 createTool( 4032, addRemTb );
3780 createTool( 4033, addRemTb );
3781 createTool( separator(), addRemTb );
3782 createTool( 4034, addRemTb );
3783 createTool( 4035, addRemTb );
3784 createTool( 4036, addRemTb );
3785 createTool( 4037, addRemTb );
3786 createTool( 4038, addRemTb );
3787 createTool( 4039, addRemTb );
3788 createTool( 4040, addRemTb );
3789 createTool( separator(), addRemTb );
3790 createTool( 4041, addRemTb );
3791 createTool( 4042, addRemTb );
3792 createTool( 4044, addRemTb );
3793 createTool( 4043, addRemTb );
3794 createTool( separator(), addRemTb );
3795 createTool( 4051, addRemTb );
3796 createTool( 4052, addRemTb );
3797 createTool( separator(), addRemTb );
3798 createTool( 4061, addRemTb );
3799 createTool( 4062, addRemTb );
3800 createTool( 4063, addRemTb );
3801 createTool( 4068, addRemTb );
3802 createTool( 4064, addRemTb );
3803 createTool( 4065, addRemTb );
3804 createTool( 4066, addRemTb );
3805 createTool( 4069, addRemTb );
3806 createTool( separator(), addRemTb );
3808 createTool( 4067,modifyTb );
3809 createTool( 407, modifyTb );
3810 createTool( 408, modifyTb );
3811 createTool( 409, modifyTb );
3812 createTool( 410, modifyTb );
3813 createTool( 411, modifyTb );
3814 createTool( 419, modifyTb );
3815 createTool( 412, modifyTb );
3816 createTool( 413, modifyTb );
3817 createTool( 416, modifyTb );
3818 createTool( 414, modifyTb );
3819 createTool( 415, modifyTb );
3820 createTool( 417, modifyTb );
3821 createTool( 418, modifyTb );
3823 createTool( 214, dispModeTb );
3825 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3826 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3829 QString OB = "'ObjectBrowser'",
3830 View = "'" + SVTK_Viewer::Type() + "'",
3832 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3833 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3834 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3835 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3836 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3837 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3838 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3839 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3840 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3841 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3842 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3844 mesh_part = mesh + " " + subMesh + " " + group,
3845 mesh_group = mesh + " " + group,
3846 hyp_alg = hypo + " " + algo;
3848 // popup for object browser
3850 isInvisible("not( isVisible )"),
3851 isEmpty("numberOfNodes = 0"),
3852 isNotEmpty("numberOfNodes <> 0"),
3854 // has nodes, edges, etc in VISIBLE! actor
3855 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3856 hasElems("(count( elemTypes ) > 0)"),
3857 hasDifferentElems("(count( elemTypes ) > 1)"),
3858 hasElems0d("({'Elem0d'} in elemTypes)"),
3859 hasEdges("({'Edge'} in elemTypes)"),
3860 hasFaces("({'Face'} in elemTypes)"),
3861 hasVolumes("({'Volume'} in elemTypes)");
3863 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3864 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3865 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3866 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3867 createPopupItem( 803, OB, group ); // EDIT_GROUP
3868 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3870 popupMgr()->insert( separator(), -1, 0 );
3871 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3872 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3873 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3874 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3875 createPopupItem( 214, OB, mesh_part ); // UPDATE
3876 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3877 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3878 popupMgr()->insert( separator(), -1, 0 );
3879 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3880 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3881 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3882 popupMgr()->insert( separator(), -1, 0 );
3883 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3884 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3885 popupMgr()->insert( separator(), -1, 0 );
3886 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3887 popupMgr()->insert( separator(), -1, 0 );
3888 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3889 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3891 popupMgr()->insert( separator(), -1, 0 );
3893 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3894 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3895 QString only_one_2D = only_one_non_empty + " && dim>1";
3897 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3898 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3899 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3901 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3903 createPopupItem( 145, OB, mesh_group, multiple_non_empty ); // EXPORT_SAUV
3904 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3905 popupMgr()->insert( separator(), -1, 0 );
3908 createPopupItem( 803, View, group ); // EDIT_GROUP
3909 createPopupItem( 804, View, elems ); // ADD
3910 createPopupItem( 805, View, elems ); // REMOVE
3912 popupMgr()->insert( separator(), -1, 0 );
3913 createPopupItem( 214, View, mesh_part ); // UPDATE
3914 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3915 createPopupItem( 904, View, mesh ); // FIND_ELEM
3916 popupMgr()->insert( separator(), -1, 0 );
3918 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3919 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3920 popupMgr()->insert( separator(), -1, 0 );
3923 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3924 QString aType = QString( "%1type in {%2}" ).arg( lc );
3925 aType = aType.arg( mesh_part );
3926 QString aMeshInVTK = aClient + "&&" + aType;
3928 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3929 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3930 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3932 //-------------------------------------------------
3934 //-------------------------------------------------
3935 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3937 popupMgr()->insert( action( 9010 ), anId, -1 );
3938 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3939 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3941 popupMgr()->insert( action( 9011 ), anId, -1 );
3942 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3943 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3945 popupMgr()->insert( separator(), -1, -1 );
3947 //-------------------------------------------------
3949 //-------------------------------------------------
3950 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3952 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3953 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3954 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3956 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3957 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3958 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3960 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3961 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3962 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3964 popupMgr()->insert( separator(), anId, -1 );
3966 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3967 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3968 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3970 //-------------------------------------------------
3972 //-------------------------------------------------
3973 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3975 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3977 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3978 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3979 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3981 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3982 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3983 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3985 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3986 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3987 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3989 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3990 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3991 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3993 popupMgr()->insert( separator(), anId, -1 );
3995 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3996 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3999 //-------------------------------------------------
4000 // Representation of the 2D Quadratic elements
4001 //-------------------------------------------------
4002 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4003 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4004 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4005 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4007 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4008 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4009 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4011 //-------------------------------------------------
4012 // Orientation of faces
4013 //-------------------------------------------------
4014 popupMgr()->insert( action( 221 ), -1, -1 );
4015 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4016 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4018 //-------------------------------------------------
4020 //-------------------------------------------------
4021 popupMgr()->insert( action( 1132 ), -1, -1 );
4022 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4024 //-------------------------------------------------
4026 //-------------------------------------------------
4027 popupMgr()->insert( action( 1133 ), -1, -1 );
4028 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4030 //-------------------------------------------------
4032 //-------------------------------------------------
4034 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4035 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4036 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4037 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4039 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4041 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4042 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4044 popupMgr()->insert( separator(), anId, -1 );
4046 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4048 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4049 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4050 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4052 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4054 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4055 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4056 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4058 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4059 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4060 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4062 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4063 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4064 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4066 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4067 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4068 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4070 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4072 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4073 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4074 QtxPopupMgr::VisibleRule );
4075 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4077 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4078 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4079 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4081 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4082 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4083 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4085 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4086 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4087 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4089 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4090 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4091 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4093 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4094 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4095 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4097 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4098 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4099 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4101 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4102 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4103 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4105 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4106 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4107 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4109 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4110 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4111 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4113 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4114 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4115 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4117 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4118 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4119 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4121 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4123 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4124 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4125 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4127 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4128 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4129 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4131 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4132 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4133 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4135 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4136 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4137 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4139 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4140 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4141 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4143 popupMgr()->insert( separator(), anId, -1 );
4145 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4146 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4148 popupMgr()->insert( separator(), anId, -1 );
4150 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4152 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4153 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4155 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4156 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4157 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4159 #ifndef DISABLE_PLOT2DVIEWER
4160 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4161 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4164 //-------------------------------------------------
4166 //-------------------------------------------------
4167 popupMgr()->insert( separator(), -1, -1 );
4168 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4169 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4170 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4171 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4173 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4174 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4176 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4177 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4179 popupMgr()->insert( separator(), -1, -1 );
4181 //-------------------------------------------------
4183 //-------------------------------------------------
4184 popupMgr()->insert( action( 1134 ), -1, -1 );
4185 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4187 popupMgr()->insert( separator(), -1, -1 );
4189 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4190 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4192 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4193 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4196 //================================================================================
4198 * \brief Return true if SMESH or GEOM objects are selected.
4199 * Is called form LightApp_Module::activateModule() which clear selection if
4200 * not isSelectionCompatible()
4202 //================================================================================
4204 bool SMESHGUI::isSelectionCompatible()
4206 bool isCompatible = true;
4207 SALOME_ListIO selected;
4208 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4209 Sel->selectedObjects( selected );
4211 SALOME_ListIteratorOfListIO It( selected );
4212 for ( ; isCompatible && It.More(); It.Next())
4214 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4215 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4217 return isCompatible;
4221 bool SMESHGUI::reusableOperation( const int id )
4223 // compute, evaluate and precompute are not reusable operations
4224 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4227 bool SMESHGUI::activateModule( SUIT_Study* study )
4229 bool res = SalomeApp_Module::activateModule( study );
4231 setMenuShown( true );
4232 setToolShown( true );
4234 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4235 PyGILState_STATE gstate = PyGILState_Ensure();
4236 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4237 if(pluginsmanager==NULL)
4241 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4246 PyGILState_Release(gstate);
4247 // end of GEOM plugins loading
4249 // Reset actions accelerator keys
4250 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4251 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4252 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4254 action( 33)->setEnabled(true); // Delete: Key_Delete
4256 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4257 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4258 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4259 if ( _PTR(Study) aStudy = s->studyDS()) {
4260 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4261 updateObjBrowser(); // objects can be removed
4264 // get all view currently opened in the study and connect their signals to
4265 // the corresponding slots of the class.
4266 SUIT_Desktop* aDesk = study->application()->desktop();
4268 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4269 SUIT_ViewWindow* wnd;
4270 foreach ( wnd, wndList )
4277 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4279 setMenuShown( false );
4280 setToolShown( false );
4282 EmitSignalCloseAllDialogs();
4284 // Unset actions accelerator keys
4285 action(111)->setShortcut(QKeySequence()); // Import DAT
4286 action(112)->setShortcut(QKeySequence()); // Import UNV
4287 action(113)->setShortcut(QKeySequence()); // Import MED
4289 action( 33)->setEnabled(false); // Delete: Key_Delete
4291 return SalomeApp_Module::deactivateModule( study );
4294 void SMESHGUI::studyClosed( SUIT_Study* s )
4296 SMESH::RemoveVisuData( s->id() );
4297 SalomeApp_Module::studyClosed( s );
4300 void SMESHGUI::OnGUIEvent()
4302 const QObject* obj = sender();
4303 if ( !obj || !obj->inherits( "QAction" ) )
4305 int id = actionId((QAction*)obj);
4310 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4312 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4313 if ( CORBA::is_nil( myComponentSMESH ) )
4315 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4317 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4318 return aGUI.myComponentSMESH;
4321 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4322 return myComponentSMESH;
4325 QString SMESHGUI::engineIOR() const
4327 CORBA::ORB_var anORB = getApp()->orb();
4328 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4329 return QString( anIOR.in() );
4332 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4334 SalomeApp_Module::contextMenuPopup( client, menu, title );
4336 selectionMgr()->selectedObjects( lst );
4337 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4338 Handle(SALOME_InteractiveObject) io = lst.First();
4339 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4340 _PTR(Study) study = appStudy->studyDS();
4341 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4343 QString aName = QString( obj->GetName().c_str() );
4344 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4345 aName.remove( (aName.length() - 1), 1 );
4351 LightApp_Selection* SMESHGUI::createSelection() const
4353 return new SMESHGUI_Selection();
4356 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4358 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4359 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4362 void SMESHGUI::viewManagers( QStringList& list ) const
4364 list.append( SVTK_Viewer::Type() );
4367 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4369 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4370 SMESH::UpdateSelectionProp( this );
4372 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4373 for(int i = 0; i < aViews.count() ; i++){
4374 SUIT_ViewWindow *sf = aViews[i];
4380 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4382 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4383 myClippingPlaneInfoMap.erase( theViewManager );
4386 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4388 theActor->AddObserver( SMESH::DeleteActorEvent,
4389 myEventCallbackCommand.GetPointer(),
4393 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4394 unsigned long theEvent,
4395 void* theClientData,
4398 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4399 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4400 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4401 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4402 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4403 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4404 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4405 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4406 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4407 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4408 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4409 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4410 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4411 if( anActor == *anIter3 ) {
4412 anActorList.erase( anIter3 );
4423 void SMESHGUI::createPreferences()
4425 // General tab ------------------------------------------------------------------------
4426 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4428 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4429 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4430 setPreferenceProperty( lim, "min", 0 );
4431 setPreferenceProperty( lim, "max", 100000000 );
4432 setPreferenceProperty( lim, "step", 1000 );
4433 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4435 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4436 setPreferenceProperty( qaGroup, "columns", 2 );
4437 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4438 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4439 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4440 setPreferenceProperty( prec, "min", 0 );
4441 setPreferenceProperty( prec, "max", 16 );
4443 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4444 setPreferenceProperty( dispgroup, "columns", 2 );
4445 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4447 modes.append( tr("MEN_WIRE") );
4448 modes.append( tr("MEN_SHADE") );
4449 modes.append( tr("MEN_NODES") );
4450 modes.append( tr("MEN_SHRINK") );
4451 QList<QVariant> indices;
4452 indices.append( 0 );
4453 indices.append( 1 );
4454 indices.append( 2 );
4455 indices.append( 3 );
4456 setPreferenceProperty( dispmode, "strings", modes );
4457 setPreferenceProperty( dispmode, "indexes", indices );
4459 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4460 setPreferenceProperty( arcgroup, "columns", 2 );
4461 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4462 QStringList quadraticModes;
4463 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4464 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4466 indices.append( 0 );
4467 indices.append( 1 );
4468 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4469 setPreferenceProperty( quadraticmode, "indexes", indices );
4471 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4472 "SMESH", "max_angle" );
4473 setPreferenceProperty( maxAngle, "min", 1 );
4474 setPreferenceProperty( maxAngle, "max", 90 );
4478 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4479 setPreferenceProperty( exportgroup, "columns", 2 );
4480 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4481 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4483 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4484 setPreferenceProperty( computeGroup, "columns", 2 );
4485 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4487 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4488 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4489 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4491 indices.append( 0 );
4492 indices.append( 1 );
4493 indices.append( 2 );
4494 setPreferenceProperty( notifyMode, "strings", modes );
4495 setPreferenceProperty( notifyMode, "indexes", indices );
4497 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4498 setPreferenceProperty( infoGroup, "columns", 4 );
4499 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4501 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4502 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4504 indices.append( 0 );
4505 indices.append( 1 );
4506 setPreferenceProperty( elemInfo, "strings", modes );
4507 setPreferenceProperty( elemInfo, "indexes", indices );
4508 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4509 setPreferenceProperty( nodesLim, "min", 0 );
4510 setPreferenceProperty( nodesLim, "max", 10000000 );
4511 setPreferenceProperty( nodesLim, "step", 10000 );
4512 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4514 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4515 setPreferenceProperty( segGroup, "columns", 2 );
4516 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4517 "SMESH", "segmentation" );
4518 setPreferenceProperty( segLen, "min", 1 );
4519 setPreferenceProperty( segLen, "max", 10000000 );
4520 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4521 "SMESH", "nb_segments_per_edge" );
4522 setPreferenceProperty( nbSeg, "min", 1 );
4523 setPreferenceProperty( nbSeg, "max", 10000000 );
4525 // Quantities with individual precision settings
4526 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4527 setPreferenceProperty( precGroup, "columns", 2 );
4529 const int nbQuantities = 6;
4530 int precs[nbQuantities], ii = 0;
4531 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4532 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4533 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4534 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4535 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4536 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4537 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4538 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4539 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4540 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4541 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4542 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4544 // Set property for precision value for spinboxes
4545 for ( ii = 0; ii < nbQuantities; ii++ ){
4546 setPreferenceProperty( precs[ii], "min", -14 );
4547 setPreferenceProperty( precs[ii], "max", 14 );
4548 setPreferenceProperty( precs[ii], "precision", 2 );
4551 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4552 setPreferenceProperty( previewGroup, "columns", 2 );
4553 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4554 setPreferenceProperty( chunkSize, "min", 0 );
4555 setPreferenceProperty( chunkSize, "max", 1000 );
4556 setPreferenceProperty( chunkSize, "step", 50 );
4558 // Mesh tab ------------------------------------------------------------------------
4559 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4560 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4561 setPreferenceProperty( nodeGroup, "columns", 3 );
4563 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4565 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4567 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4568 QList<QVariant> aMarkerTypeIndicesList;
4569 QList<QVariant> aMarkerTypeIconsList;
4570 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4571 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4572 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4573 aMarkerTypeIndicesList << i;
4574 aMarkerTypeIconsList << pixmap;
4576 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4577 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4579 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4581 QList<QVariant> aMarkerScaleIndicesList;
4582 QStringList aMarkerScaleValuesList;
4583 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4584 aMarkerScaleIndicesList << i;
4585 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4587 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4588 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4590 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4591 setPreferenceProperty( elemGroup, "columns", 2 );
4593 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4594 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4596 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4597 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4599 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4601 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4602 setPreferenceProperty( grpGroup, "columns", 2 );
4604 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4606 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4607 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4608 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4609 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4610 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4611 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4613 setPreferenceProperty( size0d, "min", 1 );
4614 setPreferenceProperty( size0d, "max", 10 );
4616 setPreferenceProperty( elemW, "min", 1 );
4617 setPreferenceProperty( elemW, "max", 5 );
4619 setPreferenceProperty( shrink, "min", 0 );
4620 setPreferenceProperty( shrink, "max", 100 );
4622 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4623 setPreferenceProperty( orientGroup, "columns", 1 );
4625 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4626 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4628 setPreferenceProperty( orientScale, "min", 0.05 );
4629 setPreferenceProperty( orientScale, "max", 0.5 );
4630 setPreferenceProperty( orientScale, "step", 0.05 );
4632 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4634 // Selection tab ------------------------------------------------------------------------
4635 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4637 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4638 setPreferenceProperty( selGroup, "columns", 2 );
4640 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4641 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4642 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4644 setPreferenceProperty( selW, "min", 1 );
4645 setPreferenceProperty( selW, "max", 5 );
4647 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4648 setPreferenceProperty( preGroup, "columns", 2 );
4650 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4651 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4653 setPreferenceProperty( preW, "min", 1 );
4654 setPreferenceProperty( preW, "max", 5 );
4656 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4657 setPreferenceProperty( precSelGroup, "columns", 2 );
4659 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4660 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4661 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4663 // Scalar Bar tab ------------------------------------------------------------------------
4664 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4665 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4666 setPreferenceProperty( fontGr, "columns", 2 );
4668 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4669 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4671 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4672 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4674 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4675 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4677 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4678 setPreferenceProperty( numcol, "min", 2 );
4679 setPreferenceProperty( numcol, "max", 256 );
4681 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4682 setPreferenceProperty( numlab, "min", 2 );
4683 setPreferenceProperty( numlab, "max", 65 );
4685 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4686 setPreferenceProperty( orientGr, "columns", 2 );
4687 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4688 QStringList orients;
4689 orients.append( tr( "SMESH_VERTICAL" ) );
4690 orients.append( tr( "SMESH_HORIZONTAL" ) );
4691 indices.clear(); indices.append( 0 ); indices.append( 1 );
4692 setPreferenceProperty( orient, "strings", orients );
4693 setPreferenceProperty( orient, "indexes", indices );
4695 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4696 setPreferenceProperty( posVSizeGr, "columns", 2 );
4697 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4698 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4699 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4700 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4701 setPreferenceProperty( xv, "step", 0.1 );
4702 setPreferenceProperty( xv, "min", 0.0 );
4703 setPreferenceProperty( xv, "max", 1.0 );
4704 setPreferenceProperty( yv, "step", 0.1 );
4705 setPreferenceProperty( yv, "min", 0.0 );
4706 setPreferenceProperty( yv, "max", 1.0 );
4707 setPreferenceProperty( wv, "step", 0.1 );
4708 setPreferenceProperty( wv, "min", 0.0 );
4709 setPreferenceProperty( wv, "max", 1.0 );
4710 setPreferenceProperty( hv, "min", 0.0 );
4711 setPreferenceProperty( hv, "max", 1.0 );
4712 setPreferenceProperty( hv, "step", 0.1 );
4714 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4715 setPreferenceProperty( posHSizeGr, "columns", 2 );
4716 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4717 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4718 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4719 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4720 setPreferenceProperty( xv, "min", 0.0 );
4721 setPreferenceProperty( xv, "max", 1.0 );
4722 setPreferenceProperty( xv, "step", 0.1 );
4723 setPreferenceProperty( xh, "min", 0.0 );
4724 setPreferenceProperty( xh, "max", 1.0 );
4725 setPreferenceProperty( xh, "step", 0.1 );
4726 setPreferenceProperty( yh, "min", 0.0 );
4727 setPreferenceProperty( yh, "max", 1.0 );
4728 setPreferenceProperty( yh, "step", 0.1 );
4729 setPreferenceProperty( wh, "min", 0.0 );
4730 setPreferenceProperty( wh, "max", 1.0 );
4731 setPreferenceProperty( wh, "step", 0.1 );
4732 setPreferenceProperty( hh, "min", 0.0 );
4733 setPreferenceProperty( hh, "max", 1.0 );
4734 setPreferenceProperty( hh, "step", 0.1 );
4736 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4737 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4738 setPreferenceProperty( distributionGr, "columns", 3 );
4740 types.append( tr( "SMESH_MONOCOLOR" ) );
4741 types.append( tr( "SMESH_MULTICOLOR" ) );
4742 indices.clear(); indices.append( 0 ); indices.append( 1 );
4743 setPreferenceProperty( coloringType, "strings", types );
4744 setPreferenceProperty( coloringType, "indexes", indices );
4745 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4749 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4751 if( sect=="SMESH" ) {
4752 float sbX1,sbY1,sbW,sbH;
4753 float aTol = 1.00000009999999;
4754 std::string aWarning;
4755 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4756 if( name=="selection_object_color" || name=="selection_element_color" ||
4757 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4758 name=="selection_precision_node" || name=="selection_precision_element" ||
4759 name=="selection_precision_object")
4760 SMESH::UpdateSelectionProp( this );
4761 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4762 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4763 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4764 if(sbX1+sbW > aTol){
4765 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4768 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4769 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4772 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4773 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4774 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4775 if(sbY1+sbH > aTol){
4776 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4777 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4778 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4781 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4782 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4783 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4784 if(sbX1+sbW > aTol){
4785 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4788 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4789 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4792 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4793 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4794 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4795 if(sbY1+sbH > aTol){
4796 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4799 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4800 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4803 else if ( name == "segmentation" ) {
4804 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4805 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4807 else if ( name == "nb_segments_per_edge" ) {
4808 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4809 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4812 if(aWarning.size() != 0){
4813 aWarning += "The default values are applied instead.";
4814 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4815 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4816 QObject::tr(aWarning.c_str()));
4821 //================================================================================
4823 * \brief Update something in accordance with update flags
4824 * \param theFlags - update flags
4826 * Update viewer or/and object browser etc. in accordance with update flags ( see
4827 * LightApp_UpdateFlags enumeration ).
4829 //================================================================================
4830 void SMESHGUI::update( const int flags )
4832 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4833 SMESH::UpdateView();
4835 SalomeApp_Module::update( flags );
4838 //================================================================================
4840 * \brief Set default selection mode
4842 * SLOT called when operation commited. Sets default selection mode
4844 //================================================================================
4845 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4847 SVTK_ViewWindow* vtkWnd =
4848 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4850 vtkWnd->SetSelectionMode( ActorSelection );
4853 //================================================================================
4855 * \brief Set default selection mode
4857 * SLOT called when operation aborted. Sets default selection mode
4859 //================================================================================
4860 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4862 SVTK_ViewWindow* vtkWnd =
4863 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4865 vtkWnd->SetSelectionMode( ActorSelection );
4868 //================================================================================
4870 * \brief Creates operation with given identifier
4871 * \param id - identifier of operation to be started
4872 * \return Pointer on created operation or NULL if operation is not created
4874 * Virtual method redefined from the base class creates operation with given id.
4875 * It is called called automatically from startOperation method of base class.
4877 //================================================================================
4878 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4880 LightApp_Operation* op = 0;
4881 // to do : create operation here
4884 case 417: //convert to quadratic
4885 op = new SMESHGUI_ConvToQuadOp();
4887 case 418: // create 2D mesh as boundary on 3D
4888 op = new SMESHGUI_Make2DFrom3DOp();
4890 case 701: // Compute mesh
4891 op = new SMESHGUI_ComputeOp();
4893 case 702: // Create mesh
4894 op = new SMESHGUI_MeshOp( true, true );
4896 case 703: // Create sub-mesh
4897 op = new SMESHGUI_MeshOp( true, false );
4899 case 704: // Edit mesh/sub-mesh
4900 op = new SMESHGUI_MeshOp( false );
4902 case 711: // Precompute mesh
4903 op = new SMESHGUI_PrecomputeOp();
4905 case 712: // Evaluate mesh
4906 op = new SMESHGUI_EvaluateOp();
4908 case 713: // Evaluate mesh
4909 op = new SMESHGUI_MeshOrderOp();
4911 case 806: // Create group on geom
4912 op = new SMESHGUI_GroupOnShapeOp();
4914 case 904: // Find element
4915 op = new SMESHGUI_FindElemByPointOp();
4917 case 4067: // make mesh pass through point
4918 op = new SMESHGUI_MakeNodeAtPointOp();
4925 op = SalomeApp_Module::createOperation( id );
4929 //================================================================================
4931 * \brief Stops current operations and starts a given one
4932 * \param id - The id of the operation to start
4934 //================================================================================
4936 void SMESHGUI::switchToOperation(int id)
4938 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4939 activeStudy()->abortAllOperations();
4940 startOperation( id );
4943 LightApp_Displayer* SMESHGUI::displayer()
4946 myDisplayer = new SMESHGUI_Displayer( getApp() );
4950 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4953 int aTolerance = 64;
4954 int anIterations = 0;
4960 if( anIterations % aPeriod == 0 )
4963 if( aTolerance < 1 )
4967 aHue = (int)( 360.0 * rand() / RAND_MAX );
4970 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4971 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4972 for( ; it != itEnd; ++it )
4974 SALOMEDS::Color anAutoColor = *it;
4975 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4978 aQColor.getHsv( &h, &s, &v );
4979 if( abs( h - aHue ) < aTolerance )
4991 aColor.setHsv( aHue, 255, 255 );
4993 SALOMEDS::Color aSColor;
4994 aSColor.R = (double)aColor.red() / 255.0;
4995 aSColor.G = (double)aColor.green() / 255.0;
4996 aSColor.B = (double)aColor.blue() / 255.0;
5001 const char gSeparator = '_'; // character used to separate parameter names
5002 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
5003 const char gPathSep = '|'; // character used to separate paths
5006 * \brief Store visual parameters
5008 * This method is called just before the study document is saved.
5009 * Store visual parameters in AttributeParameter attribue(s)
5011 void SMESHGUI::storeVisualParameters (int savePoint)
5013 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5014 if (!appStudy || !appStudy->studyDS())
5016 _PTR(Study) studyDS = appStudy->studyDS();
5018 // componentName is used for encoding of entries when storing them in IParameters
5019 std::string componentName = myComponentSMESH->ComponentDataType();
5020 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5021 //if (!aSComponent) return;
5024 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5025 componentName.c_str(),
5027 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5029 // store map of custom markers
5030 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5031 if( !aMarkerMap.empty() )
5033 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5034 for( ; anIter != aMarkerMap.end(); anIter++ )
5036 int anId = anIter->first;
5037 VTK::MarkerData aMarkerData = anIter->second;
5038 std::string aMarkerFileName = aMarkerData.first;
5039 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5040 if( aMarkerTexture.size() < 3 )
5041 continue; // should contain at least width, height and the first value
5043 QString aPropertyName( "texture" );
5044 aPropertyName += gSeparator;
5045 aPropertyName += QString::number( anId );
5047 QString aPropertyValue = aMarkerFileName.c_str();
5048 aPropertyValue += gPathSep;
5050 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5051 ushort aWidth = *aTextureIter++;
5052 ushort aHeight = *aTextureIter++;
5053 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5054 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5055 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5056 aPropertyValue += QString::number( *aTextureIter );
5058 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5062 // viewers counters are used for storing view_numbers in IParameters
5065 // main cycle to store parameters of displayed objects
5066 QList<SUIT_ViewManager*> lst;
5067 QList<SUIT_ViewManager*>::Iterator it;
5068 getApp()->viewManagers(lst);
5069 for (it = lst.begin(); it != lst.end(); it++)
5071 SUIT_ViewManager* vman = *it;
5072 QString vType = vman->getType();
5074 // saving VTK actors properties
5075 if (vType == SVTK_Viewer::Type())
5077 // store the clipping planes attached to the view manager
5078 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5079 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5080 if( anIter != myClippingPlaneInfoMap.end() )
5081 aClippingPlaneInfoList = anIter->second;
5083 if( !aClippingPlaneInfoList.empty() ) {
5084 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5085 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5087 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5088 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5090 QString aPropertyName( "ClippingPlane" );
5091 aPropertyName += gSeparator;
5092 aPropertyName += QString::number( vtkViewers );
5093 aPropertyName += gSeparator;
5094 aPropertyName += QString::number( anId );
5096 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5097 aPropertyValue += gDigitsSep;
5098 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5099 aPropertyValue += gDigitsSep;
5100 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5101 aPropertyValue += gDigitsSep;
5102 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5104 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5108 QVector<SUIT_ViewWindow*> views = vman->getViews();
5109 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5111 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5113 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5114 vtkActorCollection* allActors = aCopy.GetActors();
5115 allActors->InitTraversal();
5116 while (vtkActor* actor = allActors->GetNextActor())
5118 if (actor->GetVisibility()) // store only visible actors
5120 SMESH_Actor* aSmeshActor = 0;
5121 if (actor->IsA("SMESH_Actor"))
5122 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5123 if (aSmeshActor && aSmeshActor->hasIO())
5125 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5128 // entry is "encoded" = it does NOT contain component adress,
5129 // since it is a subject to change on next component loading
5130 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5132 std::string param, vtkParam = vType.toLatin1().data();
5133 vtkParam += gSeparator;
5134 vtkParam += QString::number(vtkViewers).toLatin1().data();
5135 vtkParam += gSeparator;
5138 param = vtkParam + "Visibility";
5139 ip->setParameter(entry, param, "On");
5142 param = vtkParam + "Representation";
5143 ip->setParameter(entry, param, QString::number
5144 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5147 param = vtkParam + "IsShrunk";
5148 ip->setParameter(entry, param, QString::number
5149 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5151 // Displayed entities
5152 unsigned int aMode = aSmeshActor->GetEntityMode();
5153 bool isE = aMode & SMESH_Actor::eEdges;
5154 bool isF = aMode & SMESH_Actor::eFaces;
5155 bool isV = aMode & SMESH_Actor::eVolumes;
5157 QString modeStr ("e");
5158 modeStr += gDigitsSep; modeStr += QString::number(isE);
5159 modeStr += gDigitsSep; modeStr += "f";
5160 modeStr += gDigitsSep; modeStr += QString::number(isF);
5161 modeStr += gDigitsSep; modeStr += "v";
5162 modeStr += gDigitsSep; modeStr += QString::number(isV);
5164 param = vtkParam + "Entities";
5165 ip->setParameter(entry, param, modeStr.toLatin1().data());
5167 // Colors (surface:edge:)
5168 vtkFloatingPointType r, g, b;
5171 aSmeshActor->GetSufaceColor(r, g, b, delta);
5172 QString colorStr ("surface");
5173 colorStr += gDigitsSep; colorStr += QString::number(r);
5174 colorStr += gDigitsSep; colorStr += QString::number(g);
5175 colorStr += gDigitsSep; colorStr += QString::number(b);
5177 colorStr += gDigitsSep; colorStr += "backsurface";
5178 colorStr += gDigitsSep; colorStr += QString::number(delta);
5181 aSmeshActor->GetEdgeColor(r, g, b);
5182 colorStr += gDigitsSep; colorStr += "edge";
5183 colorStr += gDigitsSep; colorStr += QString::number(r);
5184 colorStr += gDigitsSep; colorStr += QString::number(g);
5185 colorStr += gDigitsSep; colorStr += QString::number(b);
5187 aSmeshActor->GetNodeColor(r, g, b);
5188 colorStr += gDigitsSep; colorStr += "node";
5189 colorStr += gDigitsSep; colorStr += QString::number(r);
5190 colorStr += gDigitsSep; colorStr += QString::number(g);
5191 colorStr += gDigitsSep; colorStr += QString::number(b);
5193 aSmeshActor->GetOutlineColor(r, g, b);
5194 colorStr += gDigitsSep; colorStr += "outline";
5195 colorStr += gDigitsSep; colorStr += QString::number(r);
5196 colorStr += gDigitsSep; colorStr += QString::number(g);
5197 colorStr += gDigitsSep; colorStr += QString::number(b);
5199 param = vtkParam + "Colors";
5200 ip->setParameter(entry, param, colorStr.toLatin1().data());
5202 // Sizes of lines and points
5203 QString sizeStr ("line");
5204 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5205 sizeStr += gDigitsSep; sizeStr += "shrink";
5206 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5208 param = vtkParam + "Sizes";
5209 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5214 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5215 if( aMarkerType == VTK::MT_USER ) {
5216 markerStr += "custom";
5217 markerStr += gDigitsSep;
5218 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5222 markerStr += gDigitsSep;
5223 markerStr += QString::number( (int)aMarkerType );
5224 markerStr += gDigitsSep;
5225 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5228 param = vtkParam + "PointMarker";
5229 ip->setParameter(entry, param, markerStr.toLatin1().data());
5232 param = vtkParam + "Opacity";
5233 ip->setParameter(entry, param,
5234 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5237 param = vtkParam + "ClippingPlane";
5239 if( !aClippingPlaneInfoList.empty() ) {
5240 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5241 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5243 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5244 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5245 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5246 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5247 if( aSmeshActor == *anIter2 ) {
5248 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5249 QString::number( anId ).toLatin1().constData() );
5256 ip->setParameter( entry, param, "Off" );
5257 } // if (io->hasEntry())
5258 } // SMESH_Actor && hasIO
5260 } // while.. actors traversal
5264 } // if (SVTK view model)
5265 } // for (viewManagers)
5268 // data structures for clipping planes processing
5271 vtkIdType Orientation;
5272 vtkFloatingPointType Distance;
5273 vtkFloatingPointType Angle[2];
5275 typedef std::list<TPlaneData> TPlaneDataList;
5276 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5278 typedef std::list<vtkActor*> TActorList;
5281 TActorList ActorList;
5282 SUIT_ViewManager* ViewManager;
5284 typedef std::list<TPlaneInfo> TPlaneInfoList;
5285 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5288 * \brief Restore visual parameters
5290 * This method is called after the study document is opened.
5291 * Restore visual parameters from AttributeParameter attribue(s)
5293 void SMESHGUI::restoreVisualParameters (int savePoint)
5295 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5296 if (!appStudy || !appStudy->studyDS())
5298 _PTR(Study) studyDS = appStudy->studyDS();
5300 // componentName is used for encoding of entries when storing them in IParameters
5301 std::string componentName = myComponentSMESH->ComponentDataType();
5302 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5303 //if (!aSComponent) return;
5306 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5307 componentName.c_str(),
5309 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5311 // restore map of custom markers and map of clipping planes
5312 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5313 TPlaneDataMap aPlaneDataMap;
5315 std::vector<std::string> properties = ip->getProperties();
5316 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5318 std::string property = *propIt;
5319 QString aPropertyName( property.c_str() );
5320 QString aPropertyValue( ip->getProperty( property ).c_str() );
5322 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5323 if( aPropertyNameList.isEmpty() )
5326 QString aPropertyType = aPropertyNameList[0];
5327 if( aPropertyType == "texture" )
5329 if( aPropertyNameList.size() != 2 )
5333 int anId = aPropertyNameList[1].toInt( &ok );
5334 if( !ok || anId < 1 )
5337 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5338 if( aPropertyValueList.size() != 2 )
5341 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5342 QString aMarkerTextureString = aPropertyValueList[1];
5343 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5344 if( aMarkerTextureStringList.size() != 3 )
5348 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5353 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5357 VTK::MarkerTexture aMarkerTexture;
5358 aMarkerTexture.push_back( aWidth );
5359 aMarkerTexture.push_back( aHeight );
5361 QString aMarkerTextureData = aMarkerTextureStringList[2];
5362 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5364 QChar aChar = aMarkerTextureData.at( i );
5365 if( aChar.isDigit() )
5366 aMarkerTexture.push_back( aChar.digitValue() );
5369 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5371 else if( aPropertyType == "ClippingPlane" )
5373 if( aPropertyNameList.size() != 3 )
5377 int aViewId = aPropertyNameList[1].toInt( &ok );
5378 if( !ok || aViewId < 0 )
5382 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5383 if( !ok || aClippingPlaneId < 0 )
5386 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5387 if( aPropertyValueList.size() != 4 )
5390 TPlaneData aPlaneData;
5391 aPlaneData.Id = aClippingPlaneId;
5394 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5399 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5404 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5409 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5413 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5414 aPlaneDataList.push_back( aPlaneData );
5418 TPlaneInfoMap aPlaneInfoMap;
5420 std::vector<std::string> entries = ip->getEntries();
5422 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5424 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5425 QString entry (ip->decodeEntry(*entIt).c_str());
5427 // Check that the entry corresponds to a real object in the Study
5428 // as the object may be deleted or modified after the visual state is saved.
5429 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5430 if (!so) continue; //Skip the not existent entry
5432 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5433 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5435 std::vector<std::string>::iterator namesIt = paramNames.begin();
5436 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5438 // actors are stored in a map after displaying of them for
5439 // quicker access in the future: map < viewID to actor >
5440 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5442 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5444 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5445 // '_' is used as separator and should not be used in viewer type or parameter names.
5446 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5447 if (lst.size() != 3)
5450 QString viewerTypStr = lst[0];
5451 QString viewIndexStr = lst[1];
5452 QString paramNameStr = lst[2];
5455 int viewIndex = viewIndexStr.toUInt(&ok);
5456 if (!ok) // bad conversion of view index to integer
5460 if (viewerTypStr == SVTK_Viewer::Type())
5462 SMESH_Actor* aSmeshActor = 0;
5463 if (vtkActors.IsBound(viewIndex))
5464 aSmeshActor = vtkActors.Find(viewIndex);
5466 QList<SUIT_ViewManager*> lst;
5467 getApp()->viewManagers(viewerTypStr, lst);
5469 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5470 SUIT_ViewManager* vman = NULL;
5471 if (viewIndex >= 0 && viewIndex < lst.count())
5472 vman = lst.at(viewIndex);
5474 if (paramNameStr == "Visibility")
5476 if (!aSmeshActor && displayer() && vman)
5478 SUIT_ViewModel* vmodel = vman->getViewModel();
5479 // SVTK view model can be casted to SALOME_View
5480 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5482 // store displayed actor in a temporary map for quicker
5483 // access later when restoring other parameters
5484 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5485 vtkRenderer* Renderer = vtkView->getRenderer();
5486 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5487 vtkActorCollection* theActors = aCopy.GetActors();
5488 theActors->InitTraversal();
5489 bool isFound = false;
5490 vtkActor *ac = theActors->GetNextActor();
5491 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5492 if (ac->IsA("SMESH_Actor")) {
5493 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5494 if (aGeomAc->hasIO()) {
5495 Handle(SALOME_InteractiveObject) io =
5496 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5497 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5499 vtkActors.Bind(viewIndex, aGeomAc);
5505 } // if (paramNameStr == "Visibility")
5508 // the rest properties "work" with SMESH_Actor
5511 QString val ((*valuesIt).c_str());
5514 if (paramNameStr == "Representation") {
5515 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5518 else if (paramNameStr == "IsShrunk") {
5520 if (!aSmeshActor->IsShrunk())
5521 aSmeshActor->SetShrink();
5524 if (aSmeshActor->IsShrunk())
5525 aSmeshActor->UnShrink();
5528 // Displayed entities
5529 else if (paramNameStr == "Entities") {
5530 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5531 if (mode.count() == 6) {
5532 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5533 MESSAGE("Invalid order of data in Entities, must be: "
5534 "e:0/1:f:0/1:v:0/1");
5537 unsigned int aMode = aSmeshActor->GetEntityMode();
5538 unsigned int aNewMode =
5539 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5540 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5541 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5542 if (aNewMode != aMode)
5543 aSmeshActor->SetEntityMode(aNewMode);
5548 else if (paramNameStr == "Colors") {
5549 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5550 if (colors.count() == 16 || colors.count() == 18 ) {
5551 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5552 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
5553 (colors.count() == 18 && colors[14] != "outline")) {
5554 MESSAGE("Invalid order of data in Colors, must be: "
5555 "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");
5561 vtkFloatingPointType otr,otg,otb;
5562 //Old case backsurface color is independent
5563 if( colors.count() == 16 ) {
5565 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5566 er = colors[9].toFloat();
5567 eg = colors[10].toFloat();
5568 eb = colors[11].toFloat();
5570 nr = colors[13].toFloat();
5571 ng = colors[14].toFloat();
5572 nb = colors[15].toFloat();
5573 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5575 //New case backsurface color depends on surface color
5576 delta = colors[5].toInt();
5578 er = colors[7].toFloat();
5579 eg = colors[8].toFloat();
5580 eb = colors[9].toFloat();
5582 nr = colors[11].toFloat();
5583 ng = colors[12].toFloat();
5584 nb = colors[13].toFloat();
5586 otr = colors[15].toFloat();
5587 otg = colors[16].toFloat();
5588 otb = colors[17].toFloat();
5590 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5591 aSmeshActor->SetEdgeColor(er,eg,eb);
5592 aSmeshActor->SetNodeColor(nr,ng,nb);
5593 aSmeshActor->SetOutlineColor(otr,otg,otb);
5597 // Sizes of lines and points
5598 else if (paramNameStr == "Sizes") {
5599 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5600 if (sizes.count() == 4) {
5601 if (sizes[0] != "line" || sizes[2] != "shrink") {
5602 MESSAGE("Invalid order of data in Sizes, must be: "
5603 "line:int:shrink:float");
5606 aSmeshActor->SetLineWidth(sizes[1].toInt());
5607 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5610 else if (sizes.count() == 6) { // just to support old format
5611 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5612 MESSAGE("Invalid order of data in Sizes, must be: "
5613 "line:int:node:int:shrink:float");
5616 aSmeshActor->SetLineWidth(sizes[1].toInt());
5617 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5618 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5623 else if (paramNameStr == "PointMarker") {
5624 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5625 if( data.count() >= 2 ) {
5627 int aParam1 = data[1].toInt( &ok );
5629 if( data[0] == "std" && data.count() == 3 ) {
5630 int aParam2 = data[2].toInt( &ok );
5631 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5633 else if( data[0] == "custom" ) {
5634 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5635 if( markerIt != aMarkerMap.end() ) {
5636 VTK::MarkerData aMarkerData = markerIt->second;
5637 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5644 else if (paramNameStr == "Opacity") {
5645 aSmeshActor->SetOpacity(val.toFloat());
5648 else if (paramNameStr.startsWith("ClippingPlane")) {
5649 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5650 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5651 // new format - val looks like "Off" or "0" (plane id)
5652 // (note: in new format "Off" value is used only for consistency,
5653 // so it is processed together with values in old format)
5654 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5655 if( anIsOldFormat ) {
5656 if (paramNameStr == "ClippingPlane1" || val == "Off")
5657 aSmeshActor->RemoveAllClippingPlanes();
5659 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5660 double aDistance = vals[1].toFloat();
5661 vtkFloatingPointType anAngle[2];
5662 anAngle[0] = vals[2].toFloat();
5663 anAngle[1] = vals[3].toFloat();
5665 QList<SUIT_ViewManager*> lst;
5666 getApp()->viewManagers(viewerTypStr, lst);
5667 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5668 if (viewIndex >= 0 && viewIndex < lst.count()) {
5669 SUIT_ViewManager* vman = lst.at(viewIndex);
5670 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5672 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5674 SMESH::TActorList anActorList;
5675 anActorList.push_back( aSmeshActor );
5676 SMESH::OrientedPlane* aPlane =
5677 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5679 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5680 aClippingPlaneInfo.Plane = aPlane;
5681 aClippingPlaneInfo.ActorList = anActorList;
5682 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5689 int aPlaneId = val.toInt( &ok );
5690 if( ok && aPlaneId >= 0 ) {
5691 bool anIsDefinedPlane = false;
5692 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5693 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5694 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5695 TPlaneInfo& aPlaneInfo = *anIter;
5696 if( aPlaneInfo.PlaneId == aPlaneId ) {
5697 aPlaneInfo.ActorList.push_back( aSmeshActor );
5698 anIsDefinedPlane = true;
5702 if( !anIsDefinedPlane ) {
5703 TPlaneInfo aPlaneInfo;
5704 aPlaneInfo.PlaneId = aPlaneId;
5705 aPlaneInfo.ActorList.push_back( aSmeshActor );
5706 aPlaneInfo.ViewManager = vman;
5708 // to make the list sorted by plane id
5709 anIter = aPlaneInfoList.begin();
5710 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5711 const TPlaneInfo& aPlaneInfoRef = *anIter;
5712 if( aPlaneInfoRef.PlaneId > aPlaneId )
5715 aPlaneInfoList.insert( anIter, aPlaneInfo );
5720 } // if (aSmeshActor)
5721 } // other parameters than Visibility
5723 } // for names/parameters iterator
5724 } // for entries iterator
5726 // take into account planes with empty list of actors referred to them
5727 QList<SUIT_ViewManager*> aVMList;
5728 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5730 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5731 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5732 int aViewId = aPlaneDataIter->first;
5733 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5734 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5736 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5738 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5739 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5740 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5741 const TPlaneData& aPlaneData = *anIter2;
5742 int aPlaneId = aPlaneData.Id;
5744 bool anIsFound = false;
5745 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5746 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5747 const TPlaneInfo& aPlaneInfo = *anIter3;
5748 if( aPlaneInfo.PlaneId == aPlaneId ) {
5755 TPlaneInfo aPlaneInfo; // ActorList field is empty
5756 aPlaneInfo.PlaneId = aPlaneId;
5757 aPlaneInfo.ViewManager = aViewManager;
5759 // to make the list sorted by plane id
5760 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5761 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5762 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5763 if( aPlaneInfoRef.PlaneId > aPlaneId )
5766 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5772 // add clipping planes to actors according to the restored parameters
5773 // and update the clipping plane map
5774 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5775 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5776 int aViewId = anIter1->first;
5777 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5779 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5780 if( anIter2 == aPlaneDataMap.end() )
5782 const TPlaneDataList& aPlaneDataList = anIter2->second;
5784 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5785 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5786 const TPlaneInfo& aPlaneInfo = *anIter3;
5787 int aPlaneId = aPlaneInfo.PlaneId;
5788 const TActorList& anActorList = aPlaneInfo.ActorList;
5789 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5793 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5797 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5799 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5800 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5801 const TPlaneData& aPlaneData = *anIter4;
5802 if( aPlaneData.Id == aPlaneId ) {
5803 SMESH::OrientedPlane* aPlane =
5804 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5806 (SMESH::Orientation)aPlaneData.Orientation,
5807 aPlaneData.Distance,
5810 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5811 aClippingPlaneInfo.Plane = aPlane;
5812 aClippingPlaneInfo.ActorList = anActorList;
5813 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5821 // update all VTK views
5822 QList<SUIT_ViewManager*> lst;
5823 getApp()->viewManagers(lst);
5824 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5825 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5826 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5827 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5828 vtkView->getRenderer()->ResetCameraClippingRange();
5835 \brief Adds preferences for dfont of VTK viewer
5837 \param pIf group identifier
5838 \param param parameter
5839 \return identifier of preferences
5841 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5843 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5845 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5848 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5849 fam.append( tr( "SMESH_FONT_COURIER" ) );
5850 fam.append( tr( "SMESH_FONT_TIMES" ) );
5852 setPreferenceProperty( tfont, "fonts", fam );
5854 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5855 setPreferenceProperty( tfont, "features", f );
5861 \brief Actions after hypothesis edition
5862 Updates object browser after hypothesis edition
5864 void SMESHGUI::onHypothesisEdit( int result )
5867 SMESHGUI::Modified();
5868 updateObjBrowser( true );
5873 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5874 \param pview view being closed
5876 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5877 #ifndef DISABLE_PLOT2DVIEWER
5878 //Crear all Plot2d Viewers if need.
5879 SMESH::ClearPlot2Viewers(pview);
5884 \brief Connects or disconnects signals about activating and cloning view on the module slots
5885 \param pview view which is connected/disconnected
5887 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5891 SUIT_ViewManager* viewMgr = pview->getViewManager();
5893 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5894 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5896 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5897 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5902 \brief Return \c true if object can be renamed
5904 bool SMESHGUI::renameAllowed( const QString& entry) const {
5905 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5909 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5913 bool appRes = SalomeApp_Module::renameAllowed(entry);
5917 // check type to prevent renaming of inappropriate objects
5918 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5919 if (aType == MESH || aType == GROUP ||
5920 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5921 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5922 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5923 aType == HYPOTHESIS || aType == ALGORITHM)
5930 Rename object by entry.
5931 \param entry entry of the object
5932 \param name new name of the object
5933 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5935 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5937 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5941 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5945 bool appRes = SalomeApp_Module::renameObject(entry,name);
5949 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5950 _PTR(GenericAttribute) anAttr;
5951 _PTR(AttributeName) aName;
5953 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5955 // check type to prevent renaming of inappropriate objects
5956 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5957 if (aType == MESH || aType == GROUP ||
5958 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5959 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5960 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5961 aType == HYPOTHESIS || aType == ALGORITHM) {
5962 if ( !name.isEmpty() ) {
5963 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5965 // update name of group object and its actor
5966 Handle(SALOME_InteractiveObject) IObject =
5967 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5969 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5970 if( !aGroupObject->_is_nil() ) {
5971 aGroupObject->SetName( qPrintable(name) );
5972 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5973 anActor->setName( qPrintable(name) );