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
29 #include "SMESHGUI_AddMeshElementDlg.h"
30 #include "SMESHGUI_AddQuadraticElementDlg.h"
31 #include "SMESHGUI_BuildCompoundDlg.h"
32 #include "SMESHGUI_ClippingDlg.h"
33 #include "SMESHGUI_ComputeDlg.h"
34 #include "SMESHGUI_ConvToQuadOp.h"
35 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
36 #include "SMESHGUI_DeleteGroupDlg.h"
37 #include "SMESHGUI_Displayer.h"
38 #include "SMESHGUI_MergeDlg.h"
39 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
40 #include "SMESHGUI_ExtrusionDlg.h"
41 #include "SMESHGUI_FileInfoDlg.h"
42 #include "SMESHGUI_FileValidator.h"
43 #include "SMESHGUI_FilterDlg.h"
44 #include "SMESHGUI_FilterLibraryDlg.h"
45 #include "SMESHGUI_FindElemByPointDlg.h"
46 #include "SMESHGUI_GroupDlg.h"
47 #include "SMESHGUI_GroupOnShapeDlg.h"
48 #include "SMESHGUI_GroupOpDlg.h"
49 #include "SMESHGUI_Hypotheses.h"
50 #include "SMESHGUI_Make2DFrom3DOp.h"
51 #include "SMESHGUI_MakeNodeAtPointDlg.h"
52 //#include "SMESHGUI_MeshInfosDlg.h"
53 #include "SMESHGUI_Measurements.h"
54 #include "SMESHGUI_MeshInfo.h"
55 #include "SMESHGUI_MeshOp.h"
56 #include "SMESHGUI_MeshOrderOp.h"
57 #include "SMESHGUI_MeshPatternDlg.h"
58 #include "SMESHGUI_MultiEditDlg.h"
59 #include "SMESHGUI_NodesDlg.h"
60 #include "SMESHGUI_Preferences_ColorDlg.h"
61 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
62 #include "SMESHGUI_RemoveElementsDlg.h"
63 #include "SMESHGUI_RemoveNodesDlg.h"
64 #include "SMESHGUI_RenumberingDlg.h"
65 #include "SMESHGUI_RevolutionDlg.h"
66 #include "SMESHGUI_RotationDlg.h"
67 #include "SMESHGUI_Selection.h"
68 #include "SMESHGUI_SewingDlg.h"
69 #include "SMESHGUI_SingleEditDlg.h"
70 #include "SMESHGUI_SmoothingDlg.h"
71 //#include "SMESHGUI_StandardMeshInfosDlg.h"
72 #include "SMESHGUI_SymmetryDlg.h"
73 #include "SMESHGUI_TranslationDlg.h"
74 #include "SMESHGUI_ScaleDlg.h"
75 #include "SMESHGUI_TransparencyDlg.h"
76 //#include "SMESHGUI_WhatIsDlg.h"
77 #include "SMESHGUI_DuplicateNodesDlg.h"
78 #include "SMESHGUI_CopyMeshDlg.h"
80 #include "SMESHGUI_Utils.h"
81 #include "SMESHGUI_MeshUtils.h"
82 #include "SMESHGUI_GroupUtils.h"
83 #include "SMESHGUI_FilterUtils.h"
84 #include "SMESHGUI_PatternUtils.h"
85 #include "SMESHGUI_VTKUtils.h"
86 #include "SMESHGUI_HypothesesUtils.h"
88 #include <SMESH_version.h>
90 #include <SMESH_Client.hxx>
91 #include <SMESH_Actor.h>
92 #include <SMESH_ScalarBarActor.h>
93 #include <SMESH_ActorUtils.h>
94 #include <SMESH_TypeFilter.hxx>
95 #include "SMESH_ControlsDef.hxx"
97 // SALOME GUI includes
98 #include <SalomeApp_Tools.h>
99 #include <SalomeApp_Study.h>
100 #include <SalomeApp_Application.h>
101 #include <SalomeApp_CheckFileDlg.h>
103 #include <LightApp_DataOwner.h>
104 #include <LightApp_Preferences.h>
105 #include <LightApp_SelectionMgr.h>
106 #include <LightApp_UpdateFlags.h>
107 #include <LightApp_NameDlg.h>
109 #include <SVTK_ViewWindow.h>
110 #include <SVTK_ViewModel.h>
111 #include <SVTK_ViewManager.h>
113 #include <VTKViewer_Algorithm.h>
115 #include <SUIT_MessageBox.h>
116 #include <SUIT_ResourceMgr.h>
117 #include <SUIT_FileDlg.h>
118 #include <SUIT_Desktop.h>
119 #include <SUIT_OverrideCursor.h>
120 #include <SUIT_Session.h>
122 #include <QtxPopupMgr.h>
123 #include <QtxFontEdit.h>
125 #include <SALOME_ListIO.hxx>
126 #include <SALOME_ListIteratorOfListIO.hxx>
128 #ifndef DISABLE_PLOT2DVIEWER
129 #include <SPlot2d_ViewModel.h>
130 #include <SPlot2d_Histogram.h>
134 #include <SALOMEconfig.h>
135 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
136 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
137 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
140 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
142 #include <QTextStream>
145 #include <boost/shared_ptr.hpp>
148 #include <vtkCamera.h>
149 #include <vtkRenderer.h>
150 #include <vtkPlane.h>
151 #include <vtkCallbackCommand.h>
152 #include <vtkLookupTable.h>
154 // SALOME KERNEL includes
155 #include <SALOMEDS_Study.hxx>
156 #include <SALOMEDSClient_StudyBuilder.hxx>
157 #include <SALOMEDSClient_SComponent.hxx>
158 #include <SALOMEDSClient_ClientFactory.hxx>
159 #include <SALOMEDSClient_IParameters.hxx>
162 #include <Standard_ErrorHandler.hxx>
163 #include <NCollection_DataMap.hxx>
165 //To disable automatic genericobj management, the following line should be commented.
166 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
167 #define WITHGENERICOBJ
171 //=============================================================
172 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
175 void ExportMeshToFile(int theCommandID);
177 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
179 void SetDisplayEntity(int theCommandID);
181 void Control( int theCommandID );
185 //=============================================================
186 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
190 std::string myExtension;
192 if ( theCommandID == 113 ) {
193 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
194 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
196 else if ( theCommandID == 112 ) {
197 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
199 else if ( theCommandID == 111 ) {
200 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
202 else if ( theCommandID == 115 ) {
203 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
205 else if ( theCommandID == 116 ) {
206 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
208 else if ( theCommandID == 117 ) {
209 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
210 filter.append( QObject::tr( "All files (*)" ) );
213 QString anInitialPath = "";
214 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
215 anInitialPath = QDir::currentPath();
217 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
220 QObject::tr( "SMESH_IMPORT_MESH" ) );
221 if ( filenames.count() > 0 ) {
222 SUIT_OverrideCursor wc;
223 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
226 QStringList anEntryList;
227 bool isEmpty = false;
228 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
229 QString filename = *it;
230 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
232 switch ( theCommandID ) {
235 // DAT format (currently unsupported)
236 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
237 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
243 aMeshes->length( 1 );
244 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
245 if ( aMeshes[0]->_is_nil() )
246 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
247 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
253 SMESH::DriverMED_ReadStatus res;
254 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
255 if ( res != SMESH::DRS_OK ) {
256 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
257 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
264 aMeshes->length( 1 );
265 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
266 if ( aMeshes[0]->_is_nil() ) {
267 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
268 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
275 SMESH::DriverMED_ReadStatus res;
276 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
277 if ( res != SMESH::DRS_OK ) {
278 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
279 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
286 SMESH::DriverMED_ReadStatus res;
287 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
288 if ( res != SMESH::DRS_OK ) {
289 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
290 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
296 catch ( const SALOME::SALOME_Exception& S_ex ) {
297 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
298 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
301 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
302 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
304 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
305 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
306 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
307 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
308 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
310 anEntryList.append( aMeshSO->GetID().c_str() );
312 #ifdef WITHGENERICOBJ
313 // obj has been published in study. Its refcount has been incremented.
314 // It is safe to decrement its refcount
315 // so that it will be destroyed when the entry in study will be removed
316 aMeshes[i]->UnRegister();
325 // update Object browser
326 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
328 // browse to the published meshes
329 if( LightApp_Application* anApp =
330 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
331 anApp->browseObjects( anEntryList );
333 // show Error message box if there were errors
334 if ( errors.count() > 0 ) {
335 SUIT_MessageBox::critical( SMESHGUI::desktop(),
336 QObject::tr( "SMESH_ERROR" ),
337 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
340 // show warning message box, if some imported mesh is empty
342 SUIT_MessageBox::warning( SMESHGUI::desktop(),
343 QObject::tr( "SMESH_WRN_WARNING" ),
344 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
349 //================================================================================
351 * \brief Export selected meshes or groups into a file
353 //================================================================================
355 void ExportMeshToFile( int theCommandID )
357 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
358 SALOME_ListIO selected;
360 aSel->selectedObjects( selected );
362 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
363 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
364 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
365 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
366 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
367 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
369 // actually, the following condition can't be met (added for insurance)
370 if( selected.Extent() == 0 ||
371 ( selected.Extent() > 1 && !isMED && !isSTL ))
374 // get mesh object from selection and check duplication of their names
375 bool hasDuplicatedMeshNames = false;
376 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
377 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
378 SALOME_ListIteratorOfListIO It( selected );
379 for( ; It.More(); It.Next() )
381 Handle(SALOME_InteractiveObject) anIObject = It.Value();
382 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
383 if ( aMeshItem->_is_nil() ) {
384 SUIT_MessageBox::warning( SMESHGUI::desktop(),
385 QObject::tr( "SMESH_WRN_WARNING" ),
386 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
390 QString aMeshName = anIObject->getName();
392 // check for name duplications
393 if ( !hasDuplicatedMeshNames )
394 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
395 if( aMeshName == (*aMeshIter).second ) {
396 hasDuplicatedMeshNames = true;
401 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
404 if( hasDuplicatedMeshNames && isMED ) {
405 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
406 QObject::tr("SMESH_WRN_WARNING"),
407 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
408 QObject::tr("SMESH_BUT_YES"),
409 QObject::tr("SMESH_BUT_NO"), 0, 1);
414 aMeshIter = aMeshList.begin();
415 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
416 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
417 QString aMeshName = (*aMeshIter).second;
419 if ( isMED || isCGNS || isSAUV )
421 // check for equal group names within each mesh
422 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
423 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
424 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
425 int aRet = SUIT_MessageBox::warning
426 (SMESHGUI::desktop(),
427 QObject::tr("SMESH_WRN_WARNING"),
428 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
429 QObject::tr("SMESH_BUT_YES"),
430 QObject::tr("SMESH_BUT_NO"), 0, 1);
438 // warn the user about presence of not supported elements
439 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
440 int nbPyramids = nbElems[ SMESH::Entity_Pyramid ] + nbElems[ SMESH::Entity_Quad_Pyramid ];
441 if ( nbPyramids > 0 ) {
442 int aRet = SUIT_MessageBox::warning
443 (SMESHGUI::desktop(),
444 QObject::tr("SMESH_WRN_WARNING"),
445 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
446 QObject::tr("SMESH_BUT_YES"),
447 QObject::tr("SMESH_BUT_NO"), 0, 1);
453 // Get parameters of export operation
456 SMESH::MED_VERSION aFormat;
457 // Init the parameters with the default values
458 bool aIsASCII_STL = true;
459 bool toCreateGroups = false;
460 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
462 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
463 bool toOverwrite = true;
465 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
466 QString anInitialPath = "";
467 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
468 anInitialPath = QDir::currentPath();
470 if ( isUNV || isDAT )
473 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
475 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
476 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
477 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
478 anInitialPath + QString("/") + aMeshName,
479 aFilter, aTitle, false);
481 else if ( isCGNS )// Export to CGNS
483 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
484 fd->setWindowTitle( aTitle );
485 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
486 if ( !anInitialPath.isEmpty() )
487 fd->setDirectory( anInitialPath );
488 fd->selectFile(aMeshName);
489 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
490 fd->setValidator( fv );
493 aFilename = fd->selectedFile();
494 toOverwrite = fv->isOverwrite();
498 else if ( isSTL ) // Export to STL
500 QMap<QString, int> aFilterMap;
501 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
502 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
505 QMap<QString, int>::const_iterator it = aFilterMap.begin();
506 for ( ; it != aFilterMap.end(); ++it )
507 filters.push_back( it.key() );
509 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
510 fd->setWindowTitle( aTitle );
511 fd->setNameFilters( filters );
512 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
513 if ( !anInitialPath.isEmpty() )
514 fd->setDirectory( anInitialPath );
515 fd->selectFile(aMeshName);
519 aFilename = fd->selectedFile();
520 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
525 else if ( isMED || isSAUV ) // Export to MED or SAUV
527 QMap<QString, SMESH::MED_VERSION> aFilterMap;
528 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
530 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
531 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
532 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
535 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
536 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
537 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
541 QString aDefaultFilter;
542 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
543 for ( ; it != aFilterMap.end(); ++it ) {
544 filters.push_back( it.key() );
545 if (it.value() == SMESH::MED_V2_2)
546 aDefaultFilter = it.key();
549 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
550 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
551 fd->setWindowTitle( aTitle );
552 fd->setNameFilters( filters );
553 fd->selectNameFilter(aDefaultFilter);
554 fd->SetChecked(toCreateGroups);
555 if ( !anInitialPath.isEmpty() )
556 fd->setDirectory( anInitialPath );
557 fd->selectFile(aMeshName);
559 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
560 fd->setValidator( fv );
565 aFilename = fd->selectedFile();
567 aFilename = QString::null;
570 aFormat = aFilterMap[fd->selectedNameFilter()];
571 toOverwrite = fv->isOverwrite();
573 if ( !aFilename.isEmpty() ) {
574 // med-2.1 does not support poly elements
575 if ( aFormat==SMESH::MED_V2_1 )
576 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
577 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
578 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
579 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
580 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
582 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
583 QObject::tr("SMESH_WRN_WARNING"),
584 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
585 QObject::tr("SMESH_BUT_YES"),
586 QObject::tr("SMESH_BUT_NO"), 0, 1);
594 // can't append to an existing using other format
595 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
596 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
597 if( !isVersionOk || aVersion != aFormat ) {
598 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
599 QObject::tr("SMESH_WRN_WARNING"),
600 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
601 QObject::tr("SMESH_BUT_YES"),
602 QObject::tr("SMESH_BUT_NO"), 0, 1);
609 QStringList aMeshNamesCollisionList;
610 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
611 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
612 QString anExistingMeshName( aMeshNames[ i ] );
613 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
614 QString anExportMeshName = (*aMeshIter).second;
615 if( anExportMeshName == anExistingMeshName ) {
616 aMeshNamesCollisionList.append( anExportMeshName );
621 if( !aMeshNamesCollisionList.isEmpty() ) {
622 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
623 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
624 QObject::tr("SMESH_WRN_WARNING"),
625 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
626 QObject::tr("SMESH_BUT_YES"),
627 QObject::tr("SMESH_BUT_NO"),
628 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
637 toCreateGroups = fd->IsChecked();
647 if ( !aFilename.isEmpty() ) {
648 // Check whether the file already exists and delete it if yes
649 QFile aFile( aFilename );
650 if ( aFile.exists() && toOverwrite )
652 SUIT_OverrideCursor wc;
655 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
656 // bool Renumber = false;
657 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
659 // Renumber= resMgr->booleanValue("SMESH","renumbering");
661 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
662 // aMeshEditor->RenumberNodes();
663 // aMeshEditor->RenumberElements();
664 // if ( SMESHGUI::automaticUpdate() )
665 // SMESH::UpdateView();
669 aMeshIter = aMeshList.begin();
670 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
672 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
673 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
674 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
675 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
676 aFormat, toOverwrite && aMeshIndex == 0 );
678 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
679 aFormat, toOverwrite && aMeshIndex == 0 );
684 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
686 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
687 if( !aMeshItem->_is_nil() )
688 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
693 if ( aMeshOrGroup->_is_equivalent( aMesh ))
694 aMesh->ExportDAT( aFilename.toLatin1().data() );
696 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
700 if ( aMeshOrGroup->_is_equivalent( aMesh ))
701 aMesh->ExportUNV( aFilename.toLatin1().data() );
703 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
707 if ( aMeshOrGroup->_is_equivalent( aMesh ))
708 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
710 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
714 aMeshIter = aMeshList.begin();
715 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
717 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
718 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
719 aMeshItem->ExportCGNS( aMeshOrGroup,
720 aFilename.toLatin1().data(),
721 toOverwrite && aMeshIndex == 0 );
725 catch (const SALOME::SALOME_Exception& S_ex){
727 SUIT_MessageBox::warning(SMESHGUI::desktop(),
728 QObject::tr("SMESH_WRN_WARNING"),
729 QObject::tr("SMESH_EXPORT_FAILED"));
735 inline void InverseEntityMode(unsigned int& theOutputMode,
736 unsigned int theMode)
738 bool anIsNotPresent = ~theOutputMode & theMode;
740 theOutputMode |= theMode;
742 theOutputMode &= ~theMode;
745 void SetDisplayEntity(int theCommandID){
746 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
747 SALOME_ListIO selected;
749 aSel->selectedObjects( selected );
751 if(selected.Extent() >= 1){
752 SALOME_ListIteratorOfListIO It( selected );
753 for( ; It.More(); It.Next()){
754 Handle(SALOME_InteractiveObject) IObject = It.Value();
755 if(IObject->hasEntry()){
756 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
757 unsigned int aMode = anActor->GetEntityMode();
758 switch(theCommandID){
760 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
763 InverseEntityMode(aMode,SMESH_Actor::eEdges);
766 InverseEntityMode(aMode,SMESH_Actor::eFaces);
769 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
772 aMode = SMESH_Actor::eAllEntity;
776 anActor->SetEntityMode(aMode);
784 SALOME_ListIO selected;
785 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
789 LightApp_SelectionMgr* aSel = app->selectionMgr();
790 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
791 if( !aSel || !appStudy )
794 aSel->selectedObjects( selected );
795 if( selected.IsEmpty() )
798 Handle(SALOME_InteractiveObject) anIObject = selected.First();
800 _PTR(Study) aStudy = appStudy->studyDS();
801 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
802 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
803 if( aMainObject->_is_nil() )
806 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
808 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
809 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
811 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
812 SALOMEDS::Color aColor = aGroupObject->GetColor();
813 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
815 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
816 if( aGroupObject->GetType() == SMESH::NODE )
817 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
818 else if( aGroupObject->GetType() == SMESH::EDGE )
819 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
820 else if( aGroupObject->GetType() == SMESH::ELEM0D )
821 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
825 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
826 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
832 SMESH::RepaintCurrentView();
835 QString functorToString( SMESH::Controls::FunctorPtr f )
837 QString type = QObject::tr( "UNKNOWN_CONTROL" );
838 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
839 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
840 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
841 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
842 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
843 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
844 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
845 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
846 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
847 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
848 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
849 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
850 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
851 type = QObject::tr( "WARP_ELEMENTS" );
852 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
853 type = QObject::tr( "TAPER_ELEMENTS" );
854 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
855 type = QObject::tr( "SKEW_ELEMENTS" );
856 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
857 type = QObject::tr( "AREA_ELEMENTS" );
858 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
859 type = QObject::tr( "LENGTH_EDGES" );
860 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
861 type = QObject::tr( "LENGTH2D_EDGES" );
862 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
863 type = QObject::tr( "MULTI_BORDERS" );
864 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
865 type = QObject::tr( "MULTI2D_BORDERS" );
866 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
867 type = QObject::tr( "FREE_NODES" );
868 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
869 type = QObject::tr( "FREE_EDGES" );
870 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
871 type = QObject::tr( "FREE_BORDERS" );
872 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
873 type = QObject::tr( "FREE_FACES" );
874 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
875 type = QObject::tr( "BARE_BORDER_VOLUME" );
876 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
877 type = QObject::tr( "BARE_BORDER_FACE" );
878 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
879 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
880 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
881 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
885 void SaveDistribution()
887 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
888 SALOME_ListIO selected;
890 aSel->selectedObjects( selected );
892 if ( selected.Extent() == 1 ) {
893 Handle(SALOME_InteractiveObject) anIO = selected.First();
894 if ( anIO->hasEntry() ) {
895 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
896 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
897 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
898 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
899 if ( aScalarBarActor && aFunctor ) {
900 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
902 std::vector<int> elements;
903 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
904 if ( mesh->_is_nil() ) {
905 SMESH::SMESH_IDSource_var idSource =
906 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
907 if ( !idSource->_is_nil() )
909 SMESH::long_array_var ids = idSource->GetIDs();
910 elements.resize( ids->length() );
911 for ( unsigned i = 0; i < elements.size(); ++i )
912 elements[i] = ids[i];
915 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
916 vtkLookupTable* lookupTable =
917 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
918 double * minmax = lookupTable->GetRange();
919 std::vector<int> nbEvents;
920 std::vector<double> funValues;
921 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
922 QString anInitialPath = "";
923 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
924 anInitialPath = QDir::currentPath();
925 QString aMeshName = anIO->getName();
927 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
928 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
929 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
930 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
931 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
934 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
936 if ( !aFilename.isEmpty() ) {
937 QFile f( aFilename );
938 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
939 QTextStream out( &f );
940 out << "# Mesh: " << aMeshName << endl;
941 out << "# Control: " << functorToString( aFunctor ) << endl;
943 out.setFieldWidth( 10 );
944 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
945 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
956 void ShowDistribution() {
957 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
958 SALOME_ListIO selected;
960 aSel->selectedObjects( selected );
962 if ( selected.Extent() == 1 ) {
963 Handle(SALOME_InteractiveObject) anIO = selected.First();
964 if ( anIO->hasEntry() ) {
965 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
966 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
967 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
968 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
974 #ifndef DISABLE_PLOT2DVIEWER
975 void PlotDistribution() {
976 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
980 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
981 SALOME_ListIO selected;
983 aSel->selectedObjects( selected );
985 if ( selected.Extent() == 1 ) {
986 Handle(SALOME_InteractiveObject) anIO = selected.First();
987 if ( anIO->hasEntry() ) {
988 //Find Actor by entry before getting Plot2d viewer,
989 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
990 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
992 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
997 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1001 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1005 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1006 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1007 QString functorName = functorToString( anActor->GetFunctor());
1008 QString aHistogramName("%1 : %2");
1009 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1010 aHistogram->setName(aHistogramName);
1011 aHistogram->setHorTitle(functorName);
1012 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1013 aPlot->displayObject(aHistogram, true);
1018 #endif //DISABLE_PLOT2DVIEWER
1020 void DisableAutoColor(){
1021 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1022 SALOME_ListIO selected;
1024 aSel->selectedObjects( selected );
1026 if(selected.Extent()){
1027 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1028 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1029 if ( !aMesh->_is_nil() ) {
1030 aMesh->SetAutoColor( false );
1035 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1036 SALOME_ListIO selected;
1037 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1041 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1042 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1043 if( !aSel || !appStudy )
1046 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1047 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1048 aModule->EmitSignalDeactivateDialog();
1049 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1050 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1055 _PTR(Study) aStudy = appStudy->studyDS();
1057 aSel->selectedObjects( selected );
1059 if(selected.Extent() >= 1){
1060 switch(theCommandID){
1062 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1063 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1067 QColor c, e, b, n, c0D, o, outl, selection, preselection;
1071 vtkFloatingPointType Shrink = 0.0;
1072 vtkFloatingPointType faces_orientation_scale = 0.0;
1073 bool faces_orientation_3dvectors = false;
1075 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1076 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1077 int aMarkerTextureCurrent = 0;
1079 SALOME_ListIteratorOfListIO It( selected );
1080 for( ; It.More(); It.Next()){
1081 Handle(SALOME_InteractiveObject) IObject = It.Value();
1082 if(IObject->hasEntry()){
1083 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1084 vtkFloatingPointType color[3];
1085 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1086 int c0 = int (color[0] * 255);
1087 int c1 = int (color[1] * 255);
1088 int c2 = int (color[2] * 255);
1089 c.setRgb(c0, c1, c2);
1091 vtkFloatingPointType edgecolor[3];
1092 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1093 c0 = int (edgecolor[0] * 255);
1094 c1 = int (edgecolor[1] * 255);
1095 c2 = int (edgecolor[2] * 255);
1096 e.setRgb(c0, c1, c2);
1098 vtkFloatingPointType nodecolor[3];
1099 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1100 c0 = int (nodecolor[0] * 255);
1101 c1 = int (nodecolor[1] * 255);
1102 c2 = int (nodecolor[2] * 255);
1103 n.setRgb(c0, c1, c2);
1105 vtkFloatingPointType color0D[3];
1106 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1107 c0 = int (color0D[0] * 255);
1108 c1 = int (color0D[1] * 255);
1109 c2 = int (color0D[2] * 255);
1110 c0D.setRgb(c0, c1, c2);
1112 vtkFloatingPointType outlineColor[3];
1113 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1114 c0 = int (outlineColor[0] * 255);
1115 c1 = int (outlineColor[1] * 255);
1116 c2 = int (outlineColor[2] * 255);
1117 outl.setRgb(c0, c1, c2);
1119 vtkFloatingPointType hColor[3];
1120 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1121 c0 = int (hColor[0] * 255);
1122 c1 = int (hColor[1] * 255);
1123 c2 = int (hColor[2] * 255);
1124 selection.setRgb(c0, c1, c2);
1126 vtkFloatingPointType phColor[3];
1127 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1128 c0 = int (phColor[0] * 255);
1129 c1 = int (phColor[1] * 255);
1130 c2 = int (phColor[2] * 255);
1131 preselection.setRgb(c0, c1, c2);
1133 size0D = (int)anActor->Get0DSize();
1136 Edgewidth = (int)anActor->GetLineWidth();
1139 Shrink = anActor->GetShrinkFactor();
1141 vtkFloatingPointType faces_orientation_color[3];
1142 anActor->GetFacesOrientationColor(faces_orientation_color);
1143 c0 = int (faces_orientation_color[0] * 255);
1144 c1 = int (faces_orientation_color[1] * 255);
1145 c2 = int (faces_orientation_color[2] * 255);
1146 o.setRgb(c0, c1, c2);
1148 faces_orientation_scale = anActor->GetFacesOrientationScale();
1149 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1151 aMarkerTypeCurrent = anActor->GetMarkerType();
1152 aMarkerScaleCurrent = anActor->GetMarkerScale();
1153 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1155 // even if there are multiple objects in the selection,
1156 // we need only the first one to get values for the dialog
1162 SMESHGUI_Preferences_ColorDlg *aDlg =
1163 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1164 aDlg->SetColor(1, c);
1165 aDlg->SetColor(2, e);
1166 aDlg->SetColor(3, n);
1167 aDlg->SetColor(4, outl);
1168 aDlg->SetDeltaBrightness(delta);
1169 aDlg->SetColor(5, c0D);
1170 aDlg->SetColor(6, o);
1171 aDlg->SetIntValue(1, Edgewidth);
1172 aDlg->SetIntValue(2, int(Shrink*100.));
1173 aDlg->SetIntValue(3, size0D);
1174 aDlg->SetDoubleValue(1, faces_orientation_scale);
1175 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1176 aDlg->SetColor(7, selection);
1177 aDlg->SetColor(8, preselection);
1179 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1181 if( aMarkerTypeCurrent != VTK::MT_USER )
1182 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1184 aDlg->setCustomMarker( aMarkerTextureCurrent );
1187 QColor color = aDlg->GetColor(1);
1188 QColor edgecolor = aDlg->GetColor(2);
1189 QColor nodecolor = aDlg->GetColor(3);
1190 QColor outlinecolor = aDlg->GetColor(4);
1191 QColor color0D = aDlg->GetColor(5);
1192 QColor faces_orientation_color = aDlg->GetColor(6);
1193 QColor selectioncolor = aDlg->GetColor(7);
1194 QColor preSelectioncolor = aDlg->GetColor(8);
1195 int delta = aDlg->GetDeltaBrightness();
1198 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1200 SALOME_ListIteratorOfListIO It( selected );
1201 for( ; It.More(); It.Next()){
1202 Handle(SALOME_InteractiveObject) IObject = It.Value();
1203 if(IObject->hasEntry()){
1204 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1205 /* actor color and backface color */
1206 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1207 vtkFloatingPointType (color.green()) / 255.,
1208 vtkFloatingPointType (color.blue()) / 255.,
1211 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1212 vtkFloatingPointType (edgecolor.green()) / 255.,
1213 vtkFloatingPointType (edgecolor.blue()) / 255.);
1215 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1216 vtkFloatingPointType (outlinecolor.green()) / 255.,
1217 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1220 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1221 vtkFloatingPointType (selectioncolor.green()) / 255.,
1222 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1224 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1225 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1226 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1229 /* Shrink factor and size edges */
1230 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1231 anActor->SetLineWidth(aDlg->GetIntValue(1));
1233 /* Nodes color and size */
1234 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1235 vtkFloatingPointType (nodecolor.green()) / 255.,
1236 vtkFloatingPointType (nodecolor.blue()) / 255.);
1239 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1240 vtkFloatingPointType (color0D.green()) / 255.,
1241 vtkFloatingPointType (color0D.blue()) / 255.);
1242 anActor->Set0DSize(aDlg->GetIntValue(3));
1244 /* Faces orientation */
1245 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1246 vtkFloatingPointType(faces_orientation_color.greenF()),
1247 vtkFloatingPointType(faces_orientation_color.blueF())};
1248 anActor->SetFacesOrientationColor(c);
1249 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1250 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1252 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1253 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1254 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1255 if( aMarkerTypeNew != VTK::MT_USER )
1256 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1258 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1259 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1260 if( anIter != aMarkerMap.end() )
1261 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1264 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1265 if( !aGroupObject->_is_nil() )
1267 SMESH::ElementType anElementType = aGroupObject->GetType();
1269 switch( anElementType )
1271 case SMESH::NODE: aColor = nodecolor; break;
1272 case SMESH::EDGE: aColor = edgecolor; break;
1273 default: aColor = color; break;
1276 SALOMEDS::Color aGroupColor;
1277 aGroupColor.R = (float)aColor.red() / 255.0;
1278 aGroupColor.G = (float)aColor.green() / 255.0;
1279 aGroupColor.B = (float)aColor.blue() / 255.0;
1280 aGroupObject->SetColor( aGroupColor );
1285 SMESH::RepaintCurrentView();
1291 SALOME_ListIteratorOfListIO It( selected );
1292 for( ; It.More(); It.Next()){
1293 Handle(SALOME_InteractiveObject) IObject = It.Value();
1294 if(IObject->hasEntry()){
1295 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1296 switch(theCommandID){
1298 anActor->SetRepresentation(SMESH_Actor::eEdge);
1301 anActor->SetRepresentation(SMESH_Actor::eSurface);
1304 if(anActor->IsShrunk())
1305 anActor->UnShrink();
1307 anActor->SetShrink();
1310 anActor->SetRepresentation(SMESH_Actor::ePoint);
1313 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1314 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1317 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1318 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1324 SMESH::RepaintCurrentView();
1328 void Control( int theCommandID )
1330 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1331 SALOME_ListIO selected;
1333 aSel->selectedObjects( selected );
1335 if( !selected.IsEmpty() ){
1336 Handle(SALOME_InteractiveObject) anIO = selected.First();
1338 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1339 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1340 switch ( theCommandID ){
1342 aControl = SMESH_Actor::eLength;
1345 aControl = SMESH_Actor::eLength2D;
1348 aControl = SMESH_Actor::eFreeEdges;
1351 aControl = SMESH_Actor::eFreeBorders;
1354 aControl = SMESH_Actor::eMultiConnection;
1357 aControl = SMESH_Actor::eFreeNodes;
1360 aControl = SMESH_Actor::eMultiConnection2D;
1363 aControl = SMESH_Actor::eArea;
1366 aControl = SMESH_Actor::eTaper;
1369 aControl = SMESH_Actor::eAspectRatio;
1372 aControl = SMESH_Actor::eAspectRatio3D;
1375 aControl = SMESH_Actor::eMinimumAngle;
1378 aControl = SMESH_Actor::eWarping;
1381 aControl = SMESH_Actor::eSkew;
1384 aControl = SMESH_Actor::eVolume3D;
1387 aControl = SMESH_Actor::eFreeFaces;
1390 aControl = SMESH_Actor::eMaxElementLength2D;
1393 aControl = SMESH_Actor::eMaxElementLength3D;
1396 aControl = SMESH_Actor::eBareBorderVolume;
1399 aControl = SMESH_Actor::eBareBorderFace;
1402 aControl = SMESH_Actor::eOverConstrainedVolume;
1405 aControl = SMESH_Actor::eOverConstrainedFace;
1408 anActor->SetControlMode(aControl);
1409 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1410 SMESH::RepaintCurrentView();
1411 #ifndef DISABLE_PLOT2DVIEWER
1412 if(anActor->GetPlot2Histogram()) {
1413 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1414 QString functorName = functorToString( anActor->GetFunctor());
1415 QString aHistogramName("%1 : %2");
1416 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1417 aHistogram->setName(aHistogramName);
1418 aHistogram->setHorTitle(functorName);
1419 SMESH::ProcessIn2DViewers(anActor);
1428 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1429 MeshObjectType theType,
1430 const QString theInTypeName,
1431 QString & theOutTypeName)
1433 SMESH_TypeFilter aTypeFilter( theType );
1435 if( !theIO.IsNull() )
1437 entry = theIO->getEntry();
1438 LightApp_DataOwner owner( entry );
1439 if ( aTypeFilter.isOk( &owner )) {
1440 theOutTypeName = theInTypeName;
1448 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1450 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1451 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1453 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1454 CORBA::String_var anID = aSComp->GetID().c_str();
1455 if (!strcmp(anID.in(),theIO->getEntry()))
1461 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1462 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1463 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1464 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1465 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1473 QString CheckHomogeneousSelection()
1475 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1476 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1477 SALOME_ListIO selected;
1479 aSel->selectedObjects( selected );
1481 QString RefType = CheckTypeObject(selected.First());
1482 SALOME_ListIteratorOfListIO It(selected);
1483 for ( ; It.More(); It.Next())
1485 Handle(SALOME_InteractiveObject) IObject = It.Value();
1486 QString Type = CheckTypeObject(IObject);
1487 if (Type.compare(RefType) != 0)
1488 return "Heterogeneous Selection";
1495 void SMESHGUI::OnEditDelete()
1497 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1498 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1499 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1501 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1502 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1503 _PTR(GenericAttribute) anAttr;
1504 _PTR(AttributeIOR) anIOR;
1506 int objectCount = 0;
1508 QString aParentComponent = QString::null;
1509 Handle(SALOME_InteractiveObject) anIO;
1510 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1512 anIO = anIt.Value();
1513 QString cur = anIO->getComponentDataType();
1514 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1516 // check if object is reference
1517 _PTR(SObject) aRefSObj;
1518 aNameList.append("\n - ");
1519 if ( aSO->ReferencedObject( aRefSObj ) ) {
1520 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1521 aNameList.append( aRefName );
1522 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1525 aNameList.append(anIO->getName());
1529 if( aParentComponent.isNull() )
1530 aParentComponent = cur;
1531 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1532 aParentComponent = "";
1535 if ( objectCount == 0 )
1536 return; // No Valid Objects Selected
1538 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1539 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1540 QObject::tr("ERR_ERROR"),
1541 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1544 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1545 if (SUIT_MessageBox::warning
1546 (SMESHGUI::desktop(),
1547 QObject::tr("SMESH_WRN_WARNING"),
1548 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1549 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1550 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1553 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1555 SALOME_ListIteratorOfListIO It(selected);
1557 aStudyBuilder->NewCommand(); // There is a transaction
1558 for( ; It.More(); It.Next()){ // loop on selected IO's
1559 Handle(SALOME_InteractiveObject) IObject = It.Value();
1560 if(IObject->hasEntry()) {
1561 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1563 // disable removal of "SMESH" component object
1564 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1566 if ( engineIOR() == anIOR->Value().c_str() )
1569 //Check the referenced object
1570 _PTR(SObject) aRefSObject;
1571 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1572 aSO = aRefSObject; // Delete main Object instead of reference
1574 // put the whole hierarchy of sub-objects of the selected SO into a list and
1575 // then treat them all starting from the deepest objects (at list back)
1577 std::list< _PTR(SObject) > listSO;
1578 listSO.push_back( aSO );
1579 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1580 for ( ; itSO != listSO.end(); ++itSO ) {
1581 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1582 for (it->InitEx(false); it->More(); it->Next())
1583 listSO.push_back( it->Value() );
1586 // treat SO's in the list starting from the back
1588 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1589 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1590 _PTR(SObject) SO = *ritSO;
1591 if ( !SO ) continue;
1592 std::string anEntry = SO->GetID();
1594 /** Erase graphical object **/
1595 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1596 ViewManagerList aViewMenegers = anApp->viewManagers();
1597 ViewManagerList::const_iterator it = aViewMenegers.begin();
1598 for( ; it != aViewMenegers.end(); it++) {
1599 SUIT_ViewManager* vm = *it;
1600 int nbSf = vm ? vm->getViewsCount() : 0;
1602 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1603 for(int i = 0; i < nbSf; i++){
1604 SUIT_ViewWindow *sf = aViews[i];
1605 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1606 SMESH::RemoveActor(sf,anActor);
1612 /** Remove an object from data structures **/
1613 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1614 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1615 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1616 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1617 aMesh->RemoveGroup( aGroup );
1619 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1620 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1621 aMesh->RemoveSubMesh( aSubMesh );
1623 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1625 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1628 IObject = new SALOME_InteractiveObject
1629 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1630 QString objType = CheckTypeObject(IObject);
1631 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1632 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1633 aStudyBuilder->RemoveObjectWithChildren( SO );
1635 else {// default action: remove SObject from the study
1636 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1637 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1639 aStudyBuilder->RemoveObjectWithChildren( SO );
1643 } /* listSO back loop */
1644 } /* IObject->hasEntry() */
1647 aStudyBuilder->CommitCommand();
1649 /* Clear any previous selection */
1651 aSel->setSelectedObjects( l1 );
1653 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1658 SMESHGUI_EXPORT CAM_Module* createModule()
1660 return new SMESHGUI();
1663 SMESHGUI_EXPORT char* getModuleVersion() {
1664 return (char*)SMESH_VERSION_STR;
1668 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1670 //=============================================================================
1674 //=============================================================================
1675 SMESHGUI::SMESHGUI() :
1676 SalomeApp_Module( "SMESH" ),
1677 LightApp_Module( "SMESH" )
1679 if ( CORBA::is_nil( myComponentSMESH ) )
1681 CORBA::Boolean anIsEmbeddedMode;
1682 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1683 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1685 // 0019923: EDF 765 SMESH : default values of hypothesis
1686 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1687 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1688 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1689 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1690 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1693 myActiveDialogBox = 0;
1694 myFilterLibraryDlg = 0;
1698 myEventCallbackCommand = vtkCallbackCommand::New();
1699 myEventCallbackCommand->Delete();
1700 myEventCallbackCommand->SetClientData( this );
1701 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1704 SMESH::GetFilterManager();
1705 SMESH::GetPattern();
1706 SMESH::GetMeasurements();
1708 /* load resources for all available meshers */
1709 SMESH::InitAvailableHypotheses();
1712 //=============================================================================
1716 //=============================================================================
1717 SMESHGUI::~SMESHGUI()
1719 #ifdef WITHGENERICOBJ
1720 SMESH::GetFilterManager()->UnRegister();
1721 SMESH::GetMeasurements()->UnRegister();
1723 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1724 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1727 //=============================================================================
1731 //=============================================================================
1732 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1734 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1736 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1741 //=============================================================================
1745 //=============================================================================
1746 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1748 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1752 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1753 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1754 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1755 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1756 return autoUpdate && !exceeded;
1759 //=============================================================================
1763 //=============================================================================
1764 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1766 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1769 //=============================================================================
1773 //=============================================================================
1774 SMESHGUI* SMESHGUI::GetSMESHGUI()
1776 SMESHGUI* smeshMod = 0;
1777 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1780 CAM_Module* module = app->module( "Mesh" );
1781 smeshMod = dynamic_cast<SMESHGUI*>( module );
1784 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1786 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1789 _PTR(Study) aStudy = study->studyDS();
1791 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1800 Standard_EXPORT SMESHGUI* GetComponentGUI()
1802 return SMESHGUI::GetSMESHGUI();
1806 //=============================================================================
1810 //=============================================================================
1811 void SMESHGUI::SetState(int aState)
1816 //=============================================================================
1820 //=============================================================================
1821 void SMESHGUI::ResetState()
1826 //=============================================================================
1830 //=============================================================================
1831 void SMESHGUI::EmitSignalDeactivateDialog()
1833 emit SignalDeactivateActiveDialog();
1836 //=============================================================================
1840 //=============================================================================
1841 void SMESHGUI::EmitSignalStudyFrameChanged()
1843 emit SignalStudyFrameChanged();
1846 //=============================================================================
1850 //=============================================================================
1851 void SMESHGUI::EmitSignalCloseAllDialogs()
1853 emit SignalCloseAllDialogs();
1856 //=============================================================================
1860 //=============================================================================
1861 void SMESHGUI::EmitSignalVisibilityChanged()
1863 emit SignalVisibilityChanged();
1866 //=============================================================================
1870 //=============================================================================
1871 QDialog *SMESHGUI::GetActiveDialogBox()
1873 return myActiveDialogBox;
1876 //=============================================================================
1880 //=============================================================================
1881 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1883 myActiveDialogBox = (QDialog *) aDlg;
1887 //=============================================================================
1891 //=============================================================================
1892 SUIT_Desktop* SMESHGUI::desktop()
1894 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1896 return app->desktop();
1901 //=============================================================================
1905 //=============================================================================
1906 SalomeApp_Study* SMESHGUI::activeStudy()
1908 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1910 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1915 //=============================================================================
1919 //=============================================================================
1920 void SMESHGUI::Modified( bool theIsUpdateActions )
1922 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1923 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1924 appStudy->Modified();
1925 if( theIsUpdateActions )
1926 app->updateActions();
1931 //=============================================================================
1935 //=============================================================================
1936 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1938 /* Here the position is on the bottom right corner - 10 */
1939 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1941 SUIT_Desktop *PP = desktop();
1942 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1943 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1947 //=============================================================================
1951 //=============================================================================
1952 static int isStudyLocked(_PTR(Study) theStudy){
1953 return theStudy->GetProperties()->IsLocked();
1956 static bool checkLock(_PTR(Study) theStudy) {
1957 if (isStudyLocked(theStudy)) {
1958 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1959 QObject::tr("WRN_WARNING"),
1960 QObject::tr("WRN_STUDY_LOCKED") );
1966 //=======================================================================
1967 //function : CheckActiveStudyLocked
1969 //=======================================================================
1971 bool SMESHGUI::isActiveStudyLocked()
1973 _PTR(Study) aStudy = activeStudy()->studyDS();
1974 return checkLock( aStudy );
1977 //=============================================================================
1981 //=============================================================================
1982 bool SMESHGUI::OnGUIEvent( int theCommandID )
1984 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1988 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1989 SUIT_ResourceMgr* mgr = resourceMgr();
1993 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1994 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1997 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1998 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2000 //QAction* act = action( theCommandID );
2002 switch (theCommandID) {
2004 if(checkLock(aStudy)) break;
2015 if(checkLock(aStudy)) break;
2016 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2020 case 150: //MED FILE INFORMATION
2022 SALOME_ListIO selected;
2023 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2025 aSel->selectedObjects( selected );
2026 if( selected.Extent() )
2028 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2029 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2030 if ( !aMesh->_is_nil() )
2032 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2039 case 122: // EXPORT MED
2052 ::ExportMeshToFile(theCommandID);
2056 case 200: // SCALAR BAR
2058 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2059 SALOME_ListIO selected;
2061 aSel->selectedObjects( selected );
2063 if( selected.Extent() ) {
2064 Handle(SALOME_InteractiveObject) anIO = selected.First();
2065 if( anIO->hasEntry() ) {
2066 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2067 anActor->SetControlMode( SMESH_Actor::eNone );
2068 #ifndef DISABLE_PLOT2DVIEWER
2069 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2078 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2083 // dump control distribution data to the text file
2084 ::SaveDistribution();
2090 // show/ distribution
2091 ::ShowDistribution();
2095 #ifndef DISABLE_PLOT2DVIEWER
2098 // plot distribution
2099 ::PlotDistribution();
2110 ::DisableAutoColor();
2113 case 1134: // Clipping
2114 case 1133: // Tranparency
2115 case 1132: // Colors / Size
2122 ::SetDisplayMode(theCommandID, myMarkerMap);
2125 //2D quadratic representation
2128 ::SetDisplayMode(theCommandID, myMarkerMap);
2132 case 216: // 0D elements
2135 case 219: // Volumes
2136 case 220: // All Entity
2137 ::SetDisplayEntity(theCommandID);
2140 case 221: // Orientation of faces
2142 LightApp_SelectionMgr* mgr = selectionMgr();
2143 SALOME_ListIO selected; mgr->selectedObjects( selected );
2145 SALOME_ListIteratorOfListIO it(selected);
2146 for( ; it.More(); it.Next()) {
2147 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2148 if(anIObject->hasEntry()) {
2149 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2150 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2159 if(checkLock(aStudy)) break;
2161 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2164 SMESH::UpdateView();
2166 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2167 SMESH::OnVisuException();
2169 catch (...) { // PAL16774 (Crash after display of many groups)
2170 SMESH::OnVisuException();
2174 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2175 aSel->selectedObjects( l );
2176 aSel->setSelectedObjects( l );
2181 case 301: // DISPLAY
2182 case 302: // DISPLAY ONLY
2184 SMESH::EDisplaing anAction;
2185 switch (theCommandID) {
2186 case 300: anAction = SMESH::eErase; break;
2187 case 301: anAction = SMESH::eDisplay; break;
2188 case 302: anAction = SMESH::eDisplayOnly; break;
2191 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2192 SALOME_ListIO sel_objects, to_process;
2194 aSel->selectedObjects( sel_objects );
2196 if( theCommandID==302 )
2198 MESSAGE("anAction = SMESH::eDisplayOnly");
2199 startOperation( myEraseAll );
2202 extractContainers( sel_objects, to_process );
2205 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2209 SALOME_ListIteratorOfListIO It( to_process );
2210 for ( ; It.More(); It.Next()) {
2212 Handle(SALOME_InteractiveObject) IOS = It.Value();
2213 if (IOS->hasEntry()) {
2215 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2216 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2217 break; // PAL16774 (Crash after display of many groups)
2219 if (anAction == SMESH::eDisplayOnly)
2221 MESSAGE("anAction = SMESH::eDisplayOnly");
2222 anAction = SMESH::eDisplay;
2228 // PAL13338 + PAL15161 -->
2229 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2230 MESSAGE("anAction = SMESH::eDisplayOnly");
2231 SMESH::UpdateView();
2232 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2234 // PAL13338 + PAL15161 <--
2236 catch (...) { // PAL16774 (Crash after display of many groups)
2237 SMESH::OnVisuException();
2240 if (anAction == SMESH::eErase) {
2241 MESSAGE("anAction == SMESH::eErase");
2243 aSel->setSelectedObjects( l1 );
2246 aSel->setSelectedObjects( to_process );
2253 if(checkLock(aStudy)) break;
2256 EmitSignalDeactivateDialog();
2258 ( new SMESHGUI_NodesDlg( this ) )->show();
2261 SUIT_MessageBox::warning(desktop(),
2262 tr("SMESH_WRN_WARNING"),
2263 tr("SMESH_WRN_VIEWER_VTK"));
2268 case 2151: // FILTER
2272 EmitSignalDeactivateDialog();
2273 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2278 case 701: // COMPUTE MESH
2279 case 711: // PRECOMPUTE MESH
2280 case 712: // EVALUATE MESH
2281 case 713: // MESH ORDER
2283 if (checkLock(aStudy)) break;
2284 startOperation( theCommandID );
2288 case 702: // Create mesh
2289 case 703: // Create sub-mesh
2290 case 704: // Edit mesh/sub-mesh
2291 startOperation( theCommandID );
2293 case 705: // copy mesh
2295 if (checkLock(aStudy)) break;
2296 EmitSignalDeactivateDialog();
2297 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2300 case 710: // Build compound mesh
2302 if (checkLock(aStudy)) break;
2303 EmitSignalDeactivateDialog();
2304 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2308 case 407: // DIAGONAL INVERSION
2309 case 408: // Delete diagonal
2313 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2314 tr( "NOT_A_VTK_VIEWER" ) );
2318 if ( checkLock( aStudy ) )
2321 /*Standard_Boolean aRes;
2322 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2323 if ( aMesh->_is_nil() )
2325 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2326 tr( "SMESH_BAD_SELECTION" ) );
2330 EmitSignalDeactivateDialog();
2331 if ( theCommandID == 407 )
2332 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2334 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2337 case 409: // Change orientation
2338 case 410: // Union of triangles
2339 case 411: // Cutting of quadrangles
2340 case 419: // Splitting volumes into tetrahedra
2344 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2345 tr( "NOT_A_VTK_VIEWER" ) );
2349 if ( checkLock( aStudy ) )
2352 EmitSignalDeactivateDialog();
2353 SMESHGUI_MultiEditDlg* aDlg = NULL;
2354 if ( theCommandID == 409 )
2355 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2356 else if ( theCommandID == 410 )
2357 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2358 else if ( theCommandID == 419 )
2359 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2361 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2366 case 412: // Smoothing
2368 if(checkLock(aStudy)) break;
2370 EmitSignalDeactivateDialog();
2371 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2374 SUIT_MessageBox::warning(desktop(),
2375 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2379 case 413: // Extrusion
2381 if (checkLock(aStudy)) break;
2383 EmitSignalDeactivateDialog();
2384 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2386 SUIT_MessageBox::warning(desktop(),
2387 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2391 case 414: // Revolution
2393 if(checkLock(aStudy)) break;
2395 EmitSignalDeactivateDialog();
2396 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2399 SUIT_MessageBox::warning(desktop(),
2400 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2404 case 415: // Pattern mapping
2406 if ( checkLock( aStudy ) )
2410 EmitSignalDeactivateDialog();
2411 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2414 SUIT_MessageBox::warning(desktop(),
2415 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2419 case 416: // Extrusion along a path
2421 if (checkLock(aStudy)) break;
2423 EmitSignalDeactivateDialog();
2424 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2426 SUIT_MessageBox::warning(desktop(),
2427 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2431 case 417: // Convert mesh to quadratic
2433 startOperation( 417 );
2434 /* if (checkLock(aStudy)) break;
2436 EmitSignalDeactivateDialog();
2437 new SMESHGUI_ConvToQuadDlg();
2439 SUIT_MessageBox::warning(desktop(),
2440 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2444 case 418: // create 2D mesh from 3D
2446 startOperation( 418 );
2449 case 806: // CREATE GEO GROUP
2451 startOperation( 806 );
2454 case 801: // CREATE GROUP
2458 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2459 tr( "NOT_A_VTK_VIEWER" ) );
2463 if(checkLock(aStudy)) break;
2464 EmitSignalDeactivateDialog();
2465 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2467 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2468 SALOME_ListIO selected;
2470 aSel->selectedObjects( selected );
2472 int nbSel = selected.Extent();
2474 // check if mesh is selected
2475 aMesh = SMESH::GetMeshByIO( selected.First() );
2477 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2482 case 802: // CONSTRUCT GROUP
2486 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2487 tr( "NOT_A_VTK_VIEWER" ) );
2491 if(checkLock(aStudy)) break;
2492 EmitSignalDeactivateDialog();
2494 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2495 SALOME_ListIO selected;
2497 aSel->selectedObjects( selected );
2499 int nbSel = selected.Extent();
2501 // check if submesh is selected
2502 Handle(SALOME_InteractiveObject) IObject = selected.First();
2503 if (IObject->hasEntry()) {
2504 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2506 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2507 if (!aSubMesh->_is_nil()) {
2509 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2510 // get submesh elements list by types
2511 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2512 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2513 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2514 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2515 // create group for each type o elements
2516 QString aName = IObject->getName();
2517 QStringList anEntryList;
2518 if (aNodes->length() > 0) {
2519 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2520 aGroup->Add(aNodes.inout());
2521 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2522 anEntryList.append( aSObject->GetID().c_str() );
2524 if (aEdges->length() > 0) {
2525 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2526 aGroup->Add(aEdges.inout());
2527 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2528 anEntryList.append( aSObject->GetID().c_str() );
2530 if (aFaces->length() > 0) {
2531 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2532 aGroup->Add(aFaces.inout());
2533 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2534 anEntryList.append( aSObject->GetID().c_str() );
2536 if (aVolumes->length() > 0) {
2537 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2538 aGroup->Add(aVolumes.inout());
2539 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2540 anEntryList.append( aSObject->GetID().c_str() );
2543 anApp->browseObjects( anEntryList );
2545 catch(const SALOME::SALOME_Exception & S_ex){
2546 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2553 SUIT_MessageBox::warning(desktop(),
2554 tr("SMESH_WRN_WARNING"),
2555 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2560 case 803: // EDIT GROUP
2564 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2565 tr( "NOT_A_VTK_VIEWER" ) );
2569 if(checkLock(aStudy)) break;
2570 EmitSignalDeactivateDialog();
2572 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2573 SALOME_ListIO selected;
2575 aSel->selectedObjects( selected );
2577 SALOME_ListIteratorOfListIO It (selected);
2578 int nbSelectedGroups = 0;
2579 for ( ; It.More(); It.Next() )
2581 SMESH::SMESH_GroupBase_var aGroup =
2582 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2583 if (!aGroup->_is_nil()) {
2585 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2589 if (nbSelectedGroups == 0)
2591 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2597 case 804: // Add elements to group
2599 if(checkLock(aStudy)) break;
2600 if (myState == 800) {
2601 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2602 if (aDlg) aDlg->onAdd();
2607 case 805: // Remove elements from group
2609 if(checkLock(aStudy)) break;
2610 if (myState == 800) {
2611 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2612 if (aDlg) aDlg->onRemove();
2617 case 815: // Edit GEOM GROUP as standalone
2621 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2622 tr( "NOT_A_VTK_VIEWER" ) );
2626 if(checkLock(aStudy)) break;
2627 EmitSignalDeactivateDialog();
2629 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2630 SALOME_ListIO selected;
2632 aSel->selectedObjects( selected );
2634 SALOME_ListIteratorOfListIO It (selected);
2635 for ( ; It.More(); It.Next() )
2637 SMESH::SMESH_GroupOnGeom_var aGroup =
2638 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2639 if (!aGroup->_is_nil()) {
2640 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2645 SMESH::SMESH_GroupOnFilter_var aGroup =
2646 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2647 if (!aGroup->_is_nil()) {
2648 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2656 case 810: // Union Groups
2657 case 811: // Intersect groups
2658 case 812: // Cut groups
2662 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2663 tr( "NOT_A_VTK_VIEWER" ) );
2667 if ( checkLock( aStudy ) )
2670 EmitSignalDeactivateDialog();
2672 SMESHGUI_GroupOpDlg* aDlg = 0;
2673 if ( theCommandID == 810 )
2674 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2675 else if ( theCommandID == 811 )
2676 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2678 aDlg = new SMESHGUI_CutGroupsDlg( this );
2685 case 814: // Create groups of entities from existing groups of superior dimensions
2687 if ( checkLock( aStudy ) )
2690 EmitSignalDeactivateDialog();
2691 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2697 case 813: // Delete groups with their contents
2701 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2702 tr( "NOT_A_VTK_VIEWER" ) );
2706 if ( checkLock( aStudy ) )
2709 EmitSignalDeactivateDialog();
2711 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2715 case 900: // MESH INFOS
2716 case 903: // WHAT IS
2718 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2719 EmitSignalDeactivateDialog();
2720 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2721 SALOME_ListIO selected;
2723 aSel->selectedObjects( selected );
2725 if ( selected.Extent() > 1 ) { // a dlg for each IO
2726 SALOME_ListIteratorOfListIO It( selected );
2727 for ( ; It.More(); It.Next() ) {
2728 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2729 dlg->showInfo( It.Value() );
2734 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2740 case 902: // STANDARD MESH INFOS
2742 EmitSignalDeactivateDialog();
2743 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2744 SALOME_ListIO selected;
2746 aSel->selectedObjects( selected );
2748 if ( selected.Extent() > 1 ) { // a dlg for each IO
2750 SALOME_ListIteratorOfListIO It (selected);
2751 for ( ; It.More(); It.Next() ) {
2753 IOs.Append( It.Value() );
2754 aSel->setSelectedObjects( IOs );
2755 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2757 // restore selection
2758 aSel->setSelectedObjects( selected );
2761 ( new SMESHGUI_StandardMeshInfosDlg( this ) )->show();
2764 case 903: // WHAT IS
2766 EmitSignalDeactivateDialog();
2767 ( new SMESHGUI_WhatIsDlg( this ) )->show();
2772 case 904: // FIND ELEM
2774 startOperation( theCommandID );
2778 case 1100: // EDIT HYPOTHESIS
2780 if(checkLock(aStudy)) break;
2782 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2783 SALOME_ListIO selected;
2785 aSel->selectedObjects( selected );
2787 int nbSel = selected.Extent();
2790 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2791 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2793 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2794 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2795 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2796 if ( !aHypothesis->_is_nil() )
2799 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2800 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2802 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2812 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2814 if(checkLock(aStudy)) break;
2815 SUIT_OverrideCursor wc;
2817 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2818 SALOME_ListIO selected;
2820 aSel->selectedObjects( selected, QString::null, false );
2822 SALOME_ListIteratorOfListIO It(selected);
2823 for (int i = 0; It.More(); It.Next(), i++) {
2824 Handle(SALOME_InteractiveObject) IObject = It.Value();
2825 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2828 aSel->setSelectedObjects( l1 );
2833 case 4009: // ELEM0D
2834 case 4010: // GEOM::EDGE
2835 case 4021: // TRIANGLE
2837 case 4023: // POLYGON
2841 if(checkLock(aStudy)) break;
2843 EmitSignalDeactivateDialog();
2844 SMDSAbs_ElementType type = SMDSAbs_Edge;
2846 switch (theCommandID) {
2847 case 4009: // ELEM0D
2848 type = SMDSAbs_0DElement; nbNodes = 1; break;
2849 case 4021: // TRIANGLE
2850 type = SMDSAbs_Face; nbNodes = 3; break;
2852 type = SMDSAbs_Face; nbNodes = 4; break;
2854 type = SMDSAbs_Volume; nbNodes = 4; break;
2855 case 4023: // POLYGON
2856 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2858 type = SMDSAbs_Volume; nbNodes = 8; break;
2859 case 4033: // POLYHEDRE
2860 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2863 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2866 SUIT_MessageBox::warning(desktop(),
2867 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2871 case 4033: // POLYHEDRON
2873 if(checkLock(aStudy)) break;
2875 EmitSignalDeactivateDialog();
2876 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2879 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2880 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2884 case 4034: // QUADRATIC EDGE
2885 case 4035: // QUADRATIC TRIANGLE
2886 case 4036: // QUADRATIC QUADRANGLE
2887 case 4037: // QUADRATIC TETRAHEDRON
2888 case 4038: // QUADRATIC PYRAMID
2889 case 4039: // QUADRATIC PENTAHEDRON
2890 case 4040: // QUADRATIC HEXAHEDRON
2892 if(checkLock(aStudy)) break;
2894 EmitSignalDeactivateDialog();
2897 switch (theCommandID) {
2899 type = QUAD_EDGE; break;
2901 type = QUAD_TRIANGLE; break;
2903 type = QUAD_QUADRANGLE; break;
2905 type = QUAD_TETRAHEDRON; break;
2907 type = QUAD_PYRAMID; break;
2909 type = QUAD_PENTAHEDRON; break;
2911 type = QUAD_HEXAHEDRON;
2915 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2918 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2919 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2923 case 4041: // REMOVES NODES
2925 if(checkLock(aStudy)) break;
2927 EmitSignalDeactivateDialog();
2928 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2931 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2932 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2936 case 4042: // REMOVES ELEMENTS
2938 if(checkLock(aStudy)) break;
2940 EmitSignalDeactivateDialog();
2941 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2945 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2946 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2950 case 4043: { // CLEAR_MESH
2952 if(checkLock(aStudy)) break;
2954 SALOME_ListIO selected;
2955 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2956 aSel->selectedObjects( selected );
2958 SUIT_OverrideCursor wc;
2959 SALOME_ListIteratorOfListIO It (selected);
2960 for ( ; It.More(); It.Next() )
2962 Handle(SALOME_InteractiveObject) IOS = It.Value();
2963 SMESH::SMESH_Mesh_var aMesh =
2964 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2965 if ( aMesh->_is_nil()) continue;
2967 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2969 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2970 SMESH::ModifiedMesh( aMeshSObj, false, true);
2971 // hide groups and submeshes
2972 _PTR(ChildIterator) anIter =
2973 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2974 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2976 _PTR(SObject) so = anIter->Value();
2977 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2980 catch (const SALOME::SALOME_Exception& S_ex){
2982 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2986 SMESH::UpdateView();
2990 case 4044: // REMOVE ORPHAN NODES
2992 if(checkLock(aStudy)) break;
2993 SALOME_ListIO selected;
2994 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2995 aSel->selectedObjects( selected );
2996 if ( selected.Extent() == 1 ) {
2997 Handle(SALOME_InteractiveObject) anIO = selected.First();
2998 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2999 if ( !aMesh->_is_nil() ) {
3000 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3001 tr( "SMESH_WARNING" ),
3002 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3003 SUIT_MessageBox::Yes |
3004 SUIT_MessageBox::No,
3005 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3008 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3009 int removed = aMeshEditor->RemoveOrphanNodes();
3010 SUIT_MessageBox::information(SMESHGUI::desktop(),
3011 tr("SMESH_INFORMATION"),
3012 tr("NB_NODES_REMOVED").arg(removed));
3013 if ( removed > 0 ) {
3014 SMESH::UpdateView();
3015 SMESHGUI::Modified();
3018 catch (const SALOME::SALOME_Exception& S_ex) {
3019 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3028 case 4051: // RENUMBERING NODES
3030 if(checkLock(aStudy)) break;
3032 EmitSignalDeactivateDialog();
3033 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3037 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3038 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3042 case 4052: // RENUMBERING ELEMENTS
3044 if(checkLock(aStudy)) break;
3046 EmitSignalDeactivateDialog();
3047 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3051 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3052 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3056 case 4061: // TRANSLATION
3058 if(checkLock(aStudy)) break;
3060 EmitSignalDeactivateDialog();
3061 ( new SMESHGUI_TranslationDlg( this ) )->show();
3064 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3065 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3069 case 4062: // ROTATION
3071 if(checkLock(aStudy)) break;
3073 EmitSignalDeactivateDialog();
3074 ( new SMESHGUI_RotationDlg( this ) )->show();
3077 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3078 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3082 case 4063: // SYMMETRY
3084 if(checkLock(aStudy)) break;
3086 EmitSignalDeactivateDialog();
3087 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3090 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3091 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3095 case 4064: // SEWING
3097 if(checkLock(aStudy)) break;
3099 EmitSignalDeactivateDialog();
3100 ( new SMESHGUI_SewingDlg( this ) )->show();
3103 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3104 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3108 case 4065: // MERGE NODES
3110 if(checkLock(aStudy)) break;
3112 EmitSignalDeactivateDialog();
3113 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3116 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3117 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3121 case 4066: // MERGE EQUAL ELEMENTS
3123 if (checkLock(aStudy)) break;
3125 EmitSignalDeactivateDialog();
3126 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3128 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3129 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3134 case 4067: // MAKE MESH PASS THROUGH POINT
3135 startOperation( 4067 );
3140 if(checkLock(aStudy)) break;
3142 EmitSignalDeactivateDialog();
3143 ( new SMESHGUI_ScaleDlg( this ) )->show();
3146 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3147 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3152 case 4069: // DUPLICATE NODES
3154 if(checkLock(aStudy)) break;
3156 EmitSignalDeactivateDialog();
3157 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3160 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3161 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3166 case 5105: // Library of selection filters
3168 static QList<int> aTypes;
3169 if ( aTypes.isEmpty() )
3171 aTypes.append( SMESH::NODE );
3172 aTypes.append( SMESH::EDGE );
3173 aTypes.append( SMESH::FACE );
3174 aTypes.append( SMESH::VOLUME );
3176 if (!myFilterLibraryDlg)
3177 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3178 else if (myFilterLibraryDlg->isHidden())
3179 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3180 myFilterLibraryDlg->raise();
3184 case 6017: // CONTROLS
3208 LightApp_SelectionMgr* mgr = selectionMgr();
3209 SALOME_ListIO selected; mgr->selectedObjects( selected );
3211 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3212 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3214 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3215 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3216 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3217 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3218 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3219 ::Control( theCommandID );
3224 SUIT_MessageBox::warning(desktop(),
3225 tr( "SMESH_WRN_WARNING" ),
3226 tr( "SMESH_BAD_SELECTION" ) );
3230 SUIT_MessageBox::warning(desktop(),
3231 tr( "SMESH_WRN_WARNING" ),
3232 tr( "NOT_A_VTK_VIEWER" ) );
3237 LightApp_SelectionMgr* mgr = selectionMgr();
3238 SALOME_ListIO selected; mgr->selectedObjects( selected );
3240 SALOME_ListIteratorOfListIO it(selected);
3241 for( ; it.More(); it.Next()) {
3242 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3243 if(anIObject->hasEntry()) {
3244 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3245 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3253 LightApp_SelectionMgr* mgr = selectionMgr();
3254 SALOME_ListIO selected; mgr->selectedObjects( selected );
3256 SALOME_ListIteratorOfListIO it(selected);
3257 for( ; it.More(); it.Next()) {
3258 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3259 if(anIObject->hasEntry())
3260 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3261 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3269 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3270 EmitSignalDeactivateDialog();
3271 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3277 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3278 //updateObjBrowser();
3282 //=============================================================================
3286 //=============================================================================
3287 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3292 //=============================================================================
3296 //=============================================================================
3297 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3302 //=============================================================================
3306 //=============================================================================
3307 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3312 //=============================================================================
3313 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3314 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3316 //=============================================================================
3317 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3318 SUIT_ViewWindow* wnd )
3320 if(theIO->hasEntry()){
3321 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3322 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3326 //=======================================================================
3327 // function : createSMESHAction
3329 //=======================================================================
3330 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3331 const int key, const bool toggle, const QString& shortcutAction )
3334 QWidget* parent = application()->desktop();
3335 SUIT_ResourceMgr* resMgr = resourceMgr();
3337 if ( !icon_id.isEmpty() )
3338 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3340 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3341 if ( !pix.isNull() )
3342 icon = QIcon( pix );
3344 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3345 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3346 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3348 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3349 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3352 //=======================================================================
3353 // function : createPopupItem
3355 //=======================================================================
3356 void SMESHGUI::createPopupItem( const int id,
3357 const QString& clients,
3358 const QString& types,
3359 const QString& theRule,
3364 parentId = popupMgr()->actionId( action( pId ) );
3366 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3367 popupMgr()->insert( action( id ), parentId, 0 );
3369 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3370 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3371 QString rule = "(%1) and (%2) and (%3)";
3372 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3373 if( clients.isEmpty() )
3374 rule = rule.arg( QString( "true" ) );
3376 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3377 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3380 bool cont = myRules.contains( id );
3382 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3384 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3385 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3388 //=======================================================================
3389 // function : initialize
3391 //=======================================================================
3392 void SMESHGUI::initialize( CAM_Application* app )
3394 SalomeApp_Module::initialize( app );
3396 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3398 /* Automatic Update flag */
3399 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3401 // ----- create actions --------------
3403 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3404 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3405 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3406 createSMESHAction( 114, "NUM" );
3407 createSMESHAction( 115, "STL" );
3408 createSMESHAction( 116, "CGNS" );
3409 createSMESHAction( 117, "SAUV" );
3410 createSMESHAction( 121, "DAT" );
3411 createSMESHAction( 122, "MED" );
3412 createSMESHAction( 123, "UNV" );
3413 createSMESHAction( 140, "STL" );
3414 createSMESHAction( 142, "CGNS" );
3415 createSMESHAction( 144, "SAUV" );
3416 createSMESHAction( 124, "EXPORT_DAT" );
3417 createSMESHAction( 125, "EXPORT_MED" );
3418 createSMESHAction( 126, "EXPORT_UNV" );
3419 createSMESHAction( 141, "EXPORT_STL" );
3420 createSMESHAction( 143, "EXPORT_CGNS" );
3421 createSMESHAction( 145, "EXPORT_SAUV" );
3422 createSMESHAction( 150, "FILE_INFO" );
3423 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3424 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3425 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3426 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3427 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3428 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3429 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3430 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3431 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3432 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3433 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3434 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3435 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3436 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3437 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3438 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3439 createSMESHAction( 804, "ADD" );
3440 createSMESHAction( 805, "REMOVE" );
3441 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3442 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3443 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3444 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3445 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3446 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3447 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3448 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3449 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3450 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3451 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3452 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3453 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3454 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3455 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3456 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3457 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3458 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3459 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3460 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3461 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3462 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3463 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3464 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3465 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3466 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3467 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3468 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3469 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3470 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3471 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3472 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3473 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3474 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3475 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3476 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3477 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3478 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3479 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3480 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3481 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3482 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3483 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3484 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3485 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3486 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3487 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3488 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3489 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3490 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3491 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3492 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3493 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3494 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3495 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3496 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3497 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3498 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3499 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3500 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3501 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3502 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3503 createSMESHAction( 415, "MAP", "ICON_MAP" );
3504 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3505 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3506 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3507 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3508 createSMESHAction( 200, "RESET" );
3509 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3510 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3511 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3512 #ifndef DISABLE_PLOT2DVIEWER
3513 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3515 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3516 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3517 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3518 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3519 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3520 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3521 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3522 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3523 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3524 createSMESHAction( 220, "ALL" );
3525 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3527 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3528 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3530 createSMESHAction( 1100, "EDIT_HYPO" );
3531 createSMESHAction( 1102, "UNASSIGN" );
3532 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3533 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3534 createSMESHAction( 1131, "DISPMODE" );
3535 createSMESHAction( 1132, "COLORS" );
3536 createSMESHAction( 1133, "TRANSP" );
3537 createSMESHAction( 1134, "CLIP" );
3538 createSMESHAction( 1135, "DISP_ENT" );
3539 createSMESHAction( 1136, "AUTO_COLOR" );
3540 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3541 createSMESHAction( 2000, "CTRL" );
3543 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3544 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3546 createSMESHAction( 300, "ERASE" );
3547 createSMESHAction( 301, "DISPLAY" );
3548 createSMESHAction( 302, "DISPLAY_ONLY" );
3549 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3550 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3551 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3552 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3553 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3554 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3555 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3556 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3558 // ----- create menu --------------
3559 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3560 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3561 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3562 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3563 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3564 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3565 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3566 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3568 createMenu( separator(), fileId );
3570 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3571 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3572 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3573 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3574 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3575 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3576 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3577 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3578 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3579 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3581 createMenu( 111, importId, -1 );
3582 createMenu( 112, importId, -1 );
3583 createMenu( 113, importId, -1 );
3584 createMenu( 115, importId, -1 );
3586 createMenu( 116, importId, -1 );
3588 createMenu( 117, importId, -1 );
3589 createMenu( 121, exportId, -1 );
3590 createMenu( 122, exportId, -1 );
3591 createMenu( 123, exportId, -1 );
3592 createMenu( 140, exportId, -1 ); // export to STL
3594 createMenu( 142, exportId, -1 ); // export to CGNS
3596 createMenu( 144, exportId, -1 ); // export to SAUV
3597 createMenu( separator(), fileId, 10 );
3599 createMenu( 33, editId, -1 );
3601 createMenu( 5105, toolsId, -1 );
3603 createMenu( 702, meshId, -1 ); // "Mesh" menu
3604 createMenu( 703, meshId, -1 );
3605 createMenu( 704, meshId, -1 );
3606 createMenu( 710, meshId, -1 );
3607 createMenu( 705, meshId, -1 );
3608 createMenu( separator(), meshId, -1 );
3609 createMenu( 701, meshId, -1 );
3610 createMenu( 711, meshId, -1 );
3611 createMenu( 712, meshId, -1 );
3612 createMenu( 713, meshId, -1 );
3613 createMenu( separator(), meshId, -1 );
3614 createMenu( 801, meshId, -1 );
3615 createMenu( 806, meshId, -1 );
3616 createMenu( 802, meshId, -1 );
3617 createMenu( 803, meshId, -1 );
3618 createMenu( 815, meshId, -1 );
3619 createMenu( separator(), meshId, -1 );
3620 createMenu( 810, meshId, -1 );
3621 createMenu( 811, meshId, -1 );
3622 createMenu( 812, meshId, -1 );
3623 createMenu( separator(), meshId, -1 );
3624 createMenu( 814, meshId, -1 );
3625 createMenu( separator(), meshId, -1 );
3626 createMenu( 900, meshId, -1 );
3627 //createMenu( 902, meshId, -1 );
3628 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3629 createMenu( 904, meshId, -1 );
3630 createMenu( separator(), meshId, -1 );
3632 createMenu( 6005, nodeId, -1 );
3633 createMenu( 6002, edgeId, -1 );
3634 createMenu( 6003, edgeId, -1 );
3635 createMenu( 6001, edgeId, -1 );
3636 createMenu( 6004, edgeId, -1 );
3637 createMenu( 6021, faceId, -1 );
3638 createMenu( 6025, faceId, -1 );
3639 createMenu( 6027, faceId, -1 );
3640 createMenu( 6018, faceId, -1 );
3641 createMenu( 6019, faceId, -1 );
3642 createMenu( 6011, faceId, -1 );
3643 createMenu( 6012, faceId, -1 );
3644 createMenu( 6013, faceId, -1 );
3645 createMenu( 6014, faceId, -1 );
3646 createMenu( 6015, faceId, -1 );
3647 createMenu( 6016, faceId, -1 );
3648 createMenu( 6022, faceId, -1 );
3649 createMenu( 6017, volumeId, -1 );
3650 createMenu( 6009, volumeId, -1 );
3651 createMenu( 6023, volumeId, -1 );
3652 createMenu( 6024, volumeId, -1 );
3653 createMenu( 6026, volumeId, -1 );
3655 createMenu( 4000, addId, -1 );
3656 createMenu( 4009, addId, -1 );
3657 createMenu( 4010, addId, -1 );
3658 createMenu( 4021, addId, -1 );
3659 createMenu( 4022, addId, -1 );
3660 createMenu( 4023, addId, -1 );
3661 createMenu( 4031, addId, -1 );
3662 createMenu( 4032, addId, -1 );
3663 createMenu( 4033, addId, -1 );
3664 createMenu( separator(), addId, -1 );
3665 createMenu( 4034, addId, -1 );
3666 createMenu( 4035, addId, -1 );
3667 createMenu( 4036, addId, -1 );
3668 createMenu( 4037, addId, -1 );
3669 createMenu( 4038, addId, -1 );
3670 createMenu( 4039, addId, -1 );
3671 createMenu( 4040, addId, -1 );
3673 createMenu( 4041, removeId, -1 );
3674 createMenu( 4042, removeId, -1 );
3675 createMenu( 4044, removeId, -1 );
3676 createMenu( separator(), removeId, -1 );
3677 createMenu( 813, removeId, -1 );
3678 createMenu( separator(), removeId, -1 );
3679 createMenu( 4043, removeId, -1 );
3681 createMenu( 4051, renumId, -1 );
3682 createMenu( 4052, renumId, -1 );
3684 createMenu( 4061, transfId, -1 );
3685 createMenu( 4062, transfId, -1 );
3686 createMenu( 4063, transfId, -1 );
3687 createMenu( 4068, transfId, -1 );
3688 createMenu( 4064, transfId, -1 );
3689 createMenu( 4065, transfId, -1 );
3690 createMenu( 4066, transfId, -1 );
3691 createMenu( 4069, transfId, -1 );
3693 createMenu( 4067,modifyId, -1 );
3694 createMenu( 407, modifyId, -1 );
3695 createMenu( 408, modifyId, -1 );
3696 createMenu( 409, modifyId, -1 );
3697 createMenu( 410, modifyId, -1 );
3698 createMenu( 411, modifyId, -1 );
3699 createMenu( 419, modifyId, -1 );
3700 createMenu( 412, modifyId, -1 );
3701 createMenu( 413, modifyId, -1 );
3702 createMenu( 416, modifyId, -1 );
3703 createMenu( 414, modifyId, -1 );
3704 createMenu( 415, modifyId, -1 );
3705 createMenu( 417, modifyId, -1 );
3706 createMenu( 418, modifyId, -1 );
3708 createMenu( 501, measureId, -1 );
3709 createMenu( 502, measureId, -1 );
3710 createMenu( 214, viewId, -1 );
3712 // ----- create toolbars --------------
3713 int meshTb = createTool( tr( "TB_MESH" ) ),
3714 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3715 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3716 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3717 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3719 createTool( 702, meshTb );
3720 createTool( 703, meshTb );
3721 createTool( 704, meshTb );
3722 createTool( 710, meshTb );
3723 createTool( 705, meshTb );
3724 createTool( separator(), meshTb );
3725 createTool( 701, meshTb );
3726 createTool( 711, meshTb );
3727 createTool( 712, meshTb );
3728 createTool( 713, meshTb );
3729 createTool( separator(), meshTb );
3730 createTool( 801, meshTb );
3731 createTool( 806, meshTb );
3732 createTool( 802, meshTb );
3733 createTool( 803, meshTb );
3734 //createTool( 815, meshTb );
3735 createTool( separator(), meshTb );
3736 createTool( 900, meshTb );
3737 //createTool( 902, meshTb );
3738 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3739 createTool( 904, meshTb );
3740 createTool( separator(), meshTb );
3742 createTool( 6005, ctrlTb );
3743 createTool( separator(), ctrlTb );
3744 createTool( 6002, ctrlTb );
3745 createTool( 6003, ctrlTb );
3746 createTool( 6001, ctrlTb );
3747 createTool( 6004, ctrlTb );
3748 createTool( separator(), ctrlTb );
3749 createTool( 6021, ctrlTb );
3750 createTool( 6025, ctrlTb );
3751 createTool( 6027, ctrlTb );
3752 createTool( 6018, ctrlTb );
3753 createTool( 6019, ctrlTb );
3754 createTool( 6011, ctrlTb );
3755 createTool( 6012, ctrlTb );
3756 createTool( 6013, ctrlTb );
3757 createTool( 6014, ctrlTb );
3758 createTool( 6015, ctrlTb );
3759 createTool( 6016, ctrlTb );
3760 createTool( 6022, ctrlTb );
3761 createTool( separator(), ctrlTb );
3762 createTool( 6017, ctrlTb );
3763 createTool( 6009, ctrlTb );
3764 createTool( 6023, ctrlTb );
3765 createTool( 6024, ctrlTb );
3766 createTool( 6026, ctrlTb );
3767 createTool( separator(), ctrlTb );
3769 createTool( 4000, addRemTb );
3770 createTool( 4009, addRemTb );
3771 createTool( 4010, addRemTb );
3772 createTool( 4021, addRemTb );
3773 createTool( 4022, addRemTb );
3774 createTool( 4023, addRemTb );
3775 createTool( 4031, addRemTb );
3776 createTool( 4032, addRemTb );
3777 createTool( 4033, addRemTb );
3778 createTool( separator(), addRemTb );
3779 createTool( 4034, addRemTb );
3780 createTool( 4035, addRemTb );
3781 createTool( 4036, addRemTb );
3782 createTool( 4037, addRemTb );
3783 createTool( 4038, addRemTb );
3784 createTool( 4039, addRemTb );
3785 createTool( 4040, addRemTb );
3786 createTool( separator(), addRemTb );
3787 createTool( 4041, addRemTb );
3788 createTool( 4042, addRemTb );
3789 createTool( 4044, addRemTb );
3790 createTool( 4043, addRemTb );
3791 createTool( separator(), addRemTb );
3792 createTool( 4051, addRemTb );
3793 createTool( 4052, addRemTb );
3794 createTool( separator(), addRemTb );
3795 createTool( 4061, addRemTb );
3796 createTool( 4062, addRemTb );
3797 createTool( 4063, addRemTb );
3798 createTool( 4068, addRemTb );
3799 createTool( 4064, addRemTb );
3800 createTool( 4065, addRemTb );
3801 createTool( 4066, addRemTb );
3802 createTool( 4069, addRemTb );
3803 createTool( separator(), addRemTb );
3805 createTool( 4067,modifyTb );
3806 createTool( 407, modifyTb );
3807 createTool( 408, modifyTb );
3808 createTool( 409, modifyTb );
3809 createTool( 410, modifyTb );
3810 createTool( 411, modifyTb );
3811 createTool( 419, modifyTb );
3812 createTool( 412, modifyTb );
3813 createTool( 413, modifyTb );
3814 createTool( 416, modifyTb );
3815 createTool( 414, modifyTb );
3816 createTool( 415, modifyTb );
3817 createTool( 417, modifyTb );
3818 createTool( 418, modifyTb );
3820 createTool( 214, dispModeTb );
3822 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3823 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3826 QString OB = "'ObjectBrowser'",
3827 View = "'" + SVTK_Viewer::Type() + "'",
3829 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3830 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3831 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3832 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3833 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3834 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3835 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3836 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3837 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3838 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3839 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3841 mesh_part = mesh + " " + subMesh + " " + group,
3842 mesh_group = mesh + " " + group,
3843 hyp_alg = hypo + " " + algo;
3845 // popup for object browser
3847 isInvisible("not( isVisible )"),
3848 isEmpty("numberOfNodes = 0"),
3849 isNotEmpty("numberOfNodes <> 0"),
3851 // has nodes, edges, etc in VISIBLE! actor
3852 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3853 hasElems("(count( elemTypes ) > 0)"),
3854 hasDifferentElems("(count( elemTypes ) > 1)"),
3855 hasElems0d("({'Elem0d'} in elemTypes)"),
3856 hasEdges("({'Edge'} in elemTypes)"),
3857 hasFaces("({'Face'} in elemTypes)"),
3858 hasVolumes("({'Volume'} in elemTypes)");
3860 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3861 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3862 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3863 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3864 createPopupItem( 803, OB, group ); // EDIT_GROUP
3865 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3867 popupMgr()->insert( separator(), -1, 0 );
3868 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3869 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3870 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3871 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3872 createPopupItem( 214, OB, mesh_part ); // UPDATE
3873 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3874 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3875 popupMgr()->insert( separator(), -1, 0 );
3876 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3877 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3878 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3879 popupMgr()->insert( separator(), -1, 0 );
3880 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3881 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3882 popupMgr()->insert( separator(), -1, 0 );
3883 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3884 popupMgr()->insert( separator(), -1, 0 );
3885 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3886 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3888 popupMgr()->insert( separator(), -1, 0 );
3890 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3891 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3892 QString only_one_2D = only_one_non_empty + " && dim>1";
3894 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3895 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3896 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3898 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3900 createPopupItem( 145, OB, mesh_group, multiple_non_empty ); // EXPORT_SAUV
3901 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3902 popupMgr()->insert( separator(), -1, 0 );
3905 createPopupItem( 803, View, group ); // EDIT_GROUP
3906 createPopupItem( 804, View, elems ); // ADD
3907 createPopupItem( 805, View, elems ); // REMOVE
3909 popupMgr()->insert( separator(), -1, 0 );
3910 createPopupItem( 214, View, mesh_part ); // UPDATE
3911 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3912 createPopupItem( 904, View, mesh ); // FIND_ELEM
3913 popupMgr()->insert( separator(), -1, 0 );
3915 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3916 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3917 popupMgr()->insert( separator(), -1, 0 );
3920 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3921 QString aType = QString( "%1type in {%2}" ).arg( lc );
3922 aType = aType.arg( mesh_part );
3923 QString aMeshInVTK = aClient + "&&" + aType;
3925 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3926 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3927 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3929 //-------------------------------------------------
3931 //-------------------------------------------------
3932 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3934 popupMgr()->insert( action( 9010 ), anId, -1 );
3935 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3936 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3938 popupMgr()->insert( action( 9011 ), anId, -1 );
3939 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3940 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3942 popupMgr()->insert( separator(), -1, -1 );
3944 //-------------------------------------------------
3946 //-------------------------------------------------
3947 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3949 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3950 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3951 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3953 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3954 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3955 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3957 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3958 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3959 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3961 popupMgr()->insert( separator(), anId, -1 );
3963 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3964 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3965 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3967 //-------------------------------------------------
3969 //-------------------------------------------------
3970 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3972 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3974 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3975 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3976 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3978 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3979 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3980 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3982 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3983 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3984 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3986 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3987 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3988 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3990 popupMgr()->insert( separator(), anId, -1 );
3992 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3993 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3996 //-------------------------------------------------
3997 // Representation of the 2D Quadratic elements
3998 //-------------------------------------------------
3999 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4000 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4001 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4002 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4004 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4005 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4006 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4008 //-------------------------------------------------
4009 // Orientation of faces
4010 //-------------------------------------------------
4011 popupMgr()->insert( action( 221 ), -1, -1 );
4012 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4013 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4015 //-------------------------------------------------
4017 //-------------------------------------------------
4018 popupMgr()->insert( action( 1132 ), -1, -1 );
4019 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4021 //-------------------------------------------------
4023 //-------------------------------------------------
4024 popupMgr()->insert( action( 1133 ), -1, -1 );
4025 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4027 //-------------------------------------------------
4029 //-------------------------------------------------
4031 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4032 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4033 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4034 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4036 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4038 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4039 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4041 popupMgr()->insert( separator(), anId, -1 );
4043 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4045 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4046 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4047 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4049 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4051 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4052 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4053 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4055 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4056 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4057 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4059 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4060 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4061 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4063 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4064 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4065 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4067 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4069 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4070 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4071 QtxPopupMgr::VisibleRule );
4072 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4074 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4075 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4076 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4078 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4079 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4080 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4082 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4083 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4084 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4086 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4087 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4088 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4090 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4091 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4092 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4094 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4095 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4096 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4098 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4099 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4100 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4102 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4103 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4104 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4106 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4107 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4108 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4110 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4111 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4112 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4114 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4115 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4116 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4118 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4120 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4121 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4122 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4124 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4125 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4126 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4128 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4129 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4130 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4132 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4133 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4134 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4136 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4137 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4138 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4140 popupMgr()->insert( separator(), anId, -1 );
4142 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4143 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4145 popupMgr()->insert( separator(), anId, -1 );
4147 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4149 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4150 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4152 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4153 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4154 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4156 #ifndef DISABLE_PLOT2DVIEWER
4157 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4158 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4161 //-------------------------------------------------
4163 //-------------------------------------------------
4164 popupMgr()->insert( separator(), -1, -1 );
4165 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4166 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4167 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4168 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4170 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4171 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4173 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4174 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4176 popupMgr()->insert( separator(), -1, -1 );
4178 //-------------------------------------------------
4180 //-------------------------------------------------
4181 popupMgr()->insert( action( 1134 ), -1, -1 );
4182 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4184 popupMgr()->insert( separator(), -1, -1 );
4186 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4187 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4189 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4190 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4193 //================================================================================
4195 * \brief Return true if SMESH or GEOM objects are selected.
4196 * Is called form LightApp_Module::activateModule() which clear selection if
4197 * not isSelectionCompatible()
4199 //================================================================================
4201 bool SMESHGUI::isSelectionCompatible()
4203 bool isCompatible = true;
4204 SALOME_ListIO selected;
4205 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4206 Sel->selectedObjects( selected );
4208 SALOME_ListIteratorOfListIO It( selected );
4209 for ( ; isCompatible && It.More(); It.Next())
4211 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4212 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4214 return isCompatible;
4218 bool SMESHGUI::reusableOperation( const int id )
4220 // compute, evaluate and precompute are not reusable operations
4221 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4224 bool SMESHGUI::activateModule( SUIT_Study* study )
4226 bool res = SalomeApp_Module::activateModule( study );
4228 setMenuShown( true );
4229 setToolShown( true );
4231 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4232 PyGILState_STATE gstate = PyGILState_Ensure();
4233 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4234 if(pluginsmanager==NULL)
4238 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4243 PyGILState_Release(gstate);
4244 // end of GEOM plugins loading
4246 // Reset actions accelerator keys
4247 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4248 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4249 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4251 action( 33)->setEnabled(true); // Delete: Key_Delete
4253 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4254 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4255 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4256 if ( _PTR(Study) aStudy = s->studyDS()) {
4257 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4258 updateObjBrowser(); // objects can be removed
4261 // get all view currently opened in the study and connect their signals to
4262 // the corresponding slots of the class.
4263 SUIT_Desktop* aDesk = study->application()->desktop();
4265 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4266 SUIT_ViewWindow* wnd;
4267 foreach ( wnd, wndList )
4274 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4276 setMenuShown( false );
4277 setToolShown( false );
4279 EmitSignalCloseAllDialogs();
4281 // Unset actions accelerator keys
4282 action(111)->setShortcut(QKeySequence()); // Import DAT
4283 action(112)->setShortcut(QKeySequence()); // Import UNV
4284 action(113)->setShortcut(QKeySequence()); // Import MED
4286 action( 33)->setEnabled(false); // Delete: Key_Delete
4288 return SalomeApp_Module::deactivateModule( study );
4291 void SMESHGUI::studyClosed( SUIT_Study* s )
4293 SMESH::RemoveVisuData( s->id() );
4294 SalomeApp_Module::studyClosed( s );
4297 void SMESHGUI::OnGUIEvent()
4299 const QObject* obj = sender();
4300 if ( !obj || !obj->inherits( "QAction" ) )
4302 int id = actionId((QAction*)obj);
4307 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4309 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4310 if ( CORBA::is_nil( myComponentSMESH ) )
4312 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4314 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4315 return aGUI.myComponentSMESH;
4318 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4319 return myComponentSMESH;
4322 QString SMESHGUI::engineIOR() const
4324 CORBA::ORB_var anORB = getApp()->orb();
4325 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4326 return QString( anIOR.in() );
4329 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4331 SalomeApp_Module::contextMenuPopup( client, menu, title );
4333 selectionMgr()->selectedObjects( lst );
4334 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4335 Handle(SALOME_InteractiveObject) io = lst.First();
4336 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4337 _PTR(Study) study = appStudy->studyDS();
4338 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4340 QString aName = QString( obj->GetName().c_str() );
4341 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4342 aName.remove( (aName.length() - 1), 1 );
4348 LightApp_Selection* SMESHGUI::createSelection() const
4350 return new SMESHGUI_Selection();
4353 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4355 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4356 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4359 void SMESHGUI::viewManagers( QStringList& list ) const
4361 list.append( SVTK_Viewer::Type() );
4364 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4366 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4367 SMESH::UpdateSelectionProp( this );
4369 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4370 for(int i = 0; i < aViews.count() ; i++){
4371 SUIT_ViewWindow *sf = aViews[i];
4377 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4379 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4380 myClippingPlaneInfoMap.erase( theViewManager );
4383 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4385 theActor->AddObserver( SMESH::DeleteActorEvent,
4386 myEventCallbackCommand.GetPointer(),
4390 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4391 unsigned long theEvent,
4392 void* theClientData,
4395 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4396 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4397 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4398 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4399 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4400 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4401 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4402 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4403 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4404 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4405 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4406 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4407 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4408 if( anActor == *anIter3 ) {
4409 anActorList.erase( anIter3 );
4420 void SMESHGUI::createPreferences()
4422 // General tab ------------------------------------------------------------------------
4423 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4425 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4426 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4427 setPreferenceProperty( lim, "min", 0 );
4428 setPreferenceProperty( lim, "max", 100000000 );
4429 setPreferenceProperty( lim, "step", 1000 );
4430 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4432 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4433 setPreferenceProperty( qaGroup, "columns", 2 );
4434 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4435 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4436 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4437 setPreferenceProperty( prec, "min", 0 );
4438 setPreferenceProperty( prec, "max", 16 );
4440 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4441 setPreferenceProperty( dispgroup, "columns", 2 );
4442 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4444 modes.append( tr("MEN_WIRE") );
4445 modes.append( tr("MEN_SHADE") );
4446 modes.append( tr("MEN_NODES") );
4447 modes.append( tr("MEN_SHRINK") );
4448 QList<QVariant> indices;
4449 indices.append( 0 );
4450 indices.append( 1 );
4451 indices.append( 2 );
4452 indices.append( 3 );
4453 setPreferenceProperty( dispmode, "strings", modes );
4454 setPreferenceProperty( dispmode, "indexes", indices );
4456 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4457 setPreferenceProperty( arcgroup, "columns", 2 );
4458 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4459 QStringList quadraticModes;
4460 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4461 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4463 indices.append( 0 );
4464 indices.append( 1 );
4465 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4466 setPreferenceProperty( quadraticmode, "indexes", indices );
4468 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4469 "SMESH", "max_angle" );
4470 setPreferenceProperty( maxAngle, "min", 1 );
4471 setPreferenceProperty( maxAngle, "max", 90 );
4475 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4476 setPreferenceProperty( exportgroup, "columns", 2 );
4477 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4478 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4480 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4481 setPreferenceProperty( computeGroup, "columns", 2 );
4482 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4484 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4485 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4486 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4488 indices.append( 0 );
4489 indices.append( 1 );
4490 indices.append( 2 );
4491 setPreferenceProperty( notifyMode, "strings", modes );
4492 setPreferenceProperty( notifyMode, "indexes", indices );
4494 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4495 setPreferenceProperty( infoGroup, "columns", 4 );
4496 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4498 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4499 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4501 indices.append( 0 );
4502 indices.append( 1 );
4503 setPreferenceProperty( elemInfo, "strings", modes );
4504 setPreferenceProperty( elemInfo, "indexes", indices );
4505 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4506 setPreferenceProperty( nodesLim, "min", 0 );
4507 setPreferenceProperty( nodesLim, "max", 10000000 );
4508 setPreferenceProperty( nodesLim, "step", 10000 );
4509 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4511 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4512 setPreferenceProperty( segGroup, "columns", 2 );
4513 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4514 "SMESH", "segmentation" );
4515 setPreferenceProperty( segLen, "min", 1 );
4516 setPreferenceProperty( segLen, "max", 10000000 );
4517 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4518 "SMESH", "nb_segments_per_edge" );
4519 setPreferenceProperty( nbSeg, "min", 1 );
4520 setPreferenceProperty( nbSeg, "max", 10000000 );
4522 // Quantities with individual precision settings
4523 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4524 setPreferenceProperty( precGroup, "columns", 2 );
4526 const int nbQuantities = 6;
4527 int precs[nbQuantities], ii = 0;
4528 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4529 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4530 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4531 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4532 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4533 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4534 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4535 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4536 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4537 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4538 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4539 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4541 // Set property for precision value for spinboxes
4542 for ( ii = 0; ii < nbQuantities; ii++ ){
4543 setPreferenceProperty( precs[ii], "min", -14 );
4544 setPreferenceProperty( precs[ii], "max", 14 );
4545 setPreferenceProperty( precs[ii], "precision", 2 );
4548 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4549 setPreferenceProperty( previewGroup, "columns", 2 );
4550 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4551 setPreferenceProperty( chunkSize, "min", 0 );
4552 setPreferenceProperty( chunkSize, "max", 1000 );
4553 setPreferenceProperty( chunkSize, "step", 50 );
4555 // Mesh tab ------------------------------------------------------------------------
4556 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4557 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4558 setPreferenceProperty( nodeGroup, "columns", 3 );
4560 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4562 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4564 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4565 QList<QVariant> aMarkerTypeIndicesList;
4566 QList<QVariant> aMarkerTypeIconsList;
4567 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4568 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4569 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4570 aMarkerTypeIndicesList << i;
4571 aMarkerTypeIconsList << pixmap;
4573 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4574 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4576 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4578 QList<QVariant> aMarkerScaleIndicesList;
4579 QStringList aMarkerScaleValuesList;
4580 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4581 aMarkerScaleIndicesList << i;
4582 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4584 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4585 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4587 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4588 setPreferenceProperty( elemGroup, "columns", 2 );
4590 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4591 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4593 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4594 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4596 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4598 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4599 setPreferenceProperty( grpGroup, "columns", 2 );
4601 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4603 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4604 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4605 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4606 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4607 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4608 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4610 setPreferenceProperty( size0d, "min", 1 );
4611 setPreferenceProperty( size0d, "max", 10 );
4613 setPreferenceProperty( elemW, "min", 1 );
4614 setPreferenceProperty( elemW, "max", 5 );
4616 setPreferenceProperty( shrink, "min", 0 );
4617 setPreferenceProperty( shrink, "max", 100 );
4619 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4620 setPreferenceProperty( orientGroup, "columns", 1 );
4622 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4623 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4625 setPreferenceProperty( orientScale, "min", 0.05 );
4626 setPreferenceProperty( orientScale, "max", 0.5 );
4627 setPreferenceProperty( orientScale, "step", 0.05 );
4629 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4631 // Selection tab ------------------------------------------------------------------------
4632 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4634 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4635 setPreferenceProperty( selGroup, "columns", 2 );
4637 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4638 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4639 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4641 setPreferenceProperty( selW, "min", 1 );
4642 setPreferenceProperty( selW, "max", 5 );
4644 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4645 setPreferenceProperty( preGroup, "columns", 2 );
4647 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4648 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4650 setPreferenceProperty( preW, "min", 1 );
4651 setPreferenceProperty( preW, "max", 5 );
4653 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4654 setPreferenceProperty( precSelGroup, "columns", 2 );
4656 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4657 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4658 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4660 // Scalar Bar tab ------------------------------------------------------------------------
4661 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4662 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4663 setPreferenceProperty( fontGr, "columns", 2 );
4665 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4666 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4668 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4669 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4671 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4672 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4674 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4675 setPreferenceProperty( numcol, "min", 2 );
4676 setPreferenceProperty( numcol, "max", 256 );
4678 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4679 setPreferenceProperty( numlab, "min", 2 );
4680 setPreferenceProperty( numlab, "max", 65 );
4682 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4683 setPreferenceProperty( orientGr, "columns", 2 );
4684 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4685 QStringList orients;
4686 orients.append( tr( "SMESH_VERTICAL" ) );
4687 orients.append( tr( "SMESH_HORIZONTAL" ) );
4688 indices.clear(); indices.append( 0 ); indices.append( 1 );
4689 setPreferenceProperty( orient, "strings", orients );
4690 setPreferenceProperty( orient, "indexes", indices );
4692 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4693 setPreferenceProperty( posVSizeGr, "columns", 2 );
4694 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4695 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4696 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4697 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4698 setPreferenceProperty( xv, "step", 0.1 );
4699 setPreferenceProperty( xv, "min", 0.0 );
4700 setPreferenceProperty( xv, "max", 1.0 );
4701 setPreferenceProperty( yv, "step", 0.1 );
4702 setPreferenceProperty( yv, "min", 0.0 );
4703 setPreferenceProperty( yv, "max", 1.0 );
4704 setPreferenceProperty( wv, "step", 0.1 );
4705 setPreferenceProperty( wv, "min", 0.0 );
4706 setPreferenceProperty( wv, "max", 1.0 );
4707 setPreferenceProperty( hv, "min", 0.0 );
4708 setPreferenceProperty( hv, "max", 1.0 );
4709 setPreferenceProperty( hv, "step", 0.1 );
4711 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4712 setPreferenceProperty( posHSizeGr, "columns", 2 );
4713 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4714 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4715 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4716 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4717 setPreferenceProperty( xv, "min", 0.0 );
4718 setPreferenceProperty( xv, "max", 1.0 );
4719 setPreferenceProperty( xv, "step", 0.1 );
4720 setPreferenceProperty( xh, "min", 0.0 );
4721 setPreferenceProperty( xh, "max", 1.0 );
4722 setPreferenceProperty( xh, "step", 0.1 );
4723 setPreferenceProperty( yh, "min", 0.0 );
4724 setPreferenceProperty( yh, "max", 1.0 );
4725 setPreferenceProperty( yh, "step", 0.1 );
4726 setPreferenceProperty( wh, "min", 0.0 );
4727 setPreferenceProperty( wh, "max", 1.0 );
4728 setPreferenceProperty( wh, "step", 0.1 );
4729 setPreferenceProperty( hh, "min", 0.0 );
4730 setPreferenceProperty( hh, "max", 1.0 );
4731 setPreferenceProperty( hh, "step", 0.1 );
4733 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4734 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4735 setPreferenceProperty( distributionGr, "columns", 3 );
4737 types.append( tr( "SMESH_MONOCOLOR" ) );
4738 types.append( tr( "SMESH_MULTICOLOR" ) );
4739 indices.clear(); indices.append( 0 ); indices.append( 1 );
4740 setPreferenceProperty( coloringType, "strings", types );
4741 setPreferenceProperty( coloringType, "indexes", indices );
4742 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4746 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4748 if( sect=="SMESH" ) {
4749 float sbX1,sbY1,sbW,sbH;
4750 float aTol = 1.00000009999999;
4751 std::string aWarning;
4752 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4753 if( name=="selection_object_color" || name=="selection_element_color" ||
4754 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4755 name=="selection_precision_node" || name=="selection_precision_element" ||
4756 name=="selection_precision_object")
4757 SMESH::UpdateSelectionProp( this );
4758 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4759 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4760 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4761 if(sbX1+sbW > aTol){
4762 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4765 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4766 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4769 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4770 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4771 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4772 if(sbY1+sbH > aTol){
4773 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4774 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4775 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4778 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4779 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4780 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4781 if(sbX1+sbW > aTol){
4782 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4785 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4786 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4789 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4790 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4791 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4792 if(sbY1+sbH > aTol){
4793 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4796 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4797 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4800 else if ( name == "segmentation" ) {
4801 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4802 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4804 else if ( name == "nb_segments_per_edge" ) {
4805 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4806 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4809 if(aWarning.size() != 0){
4810 aWarning += "The default values are applied instead.";
4811 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4812 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4813 QObject::tr(aWarning.c_str()));
4818 //================================================================================
4820 * \brief Update something in accordance with update flags
4821 * \param theFlags - update flags
4823 * Update viewer or/and object browser etc. in accordance with update flags ( see
4824 * LightApp_UpdateFlags enumeration ).
4826 //================================================================================
4827 void SMESHGUI::update( const int flags )
4829 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4830 SMESH::UpdateView();
4832 SalomeApp_Module::update( flags );
4835 //================================================================================
4837 * \brief Set default selection mode
4839 * SLOT called when operation commited. Sets default selection mode
4841 //================================================================================
4842 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4844 SVTK_ViewWindow* vtkWnd =
4845 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4847 vtkWnd->SetSelectionMode( ActorSelection );
4850 //================================================================================
4852 * \brief Set default selection mode
4854 * SLOT called when operation aborted. Sets default selection mode
4856 //================================================================================
4857 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4859 SVTK_ViewWindow* vtkWnd =
4860 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4862 vtkWnd->SetSelectionMode( ActorSelection );
4865 //================================================================================
4867 * \brief Creates operation with given identifier
4868 * \param id - identifier of operation to be started
4869 * \return Pointer on created operation or NULL if operation is not created
4871 * Virtual method redefined from the base class creates operation with given id.
4872 * It is called called automatically from startOperation method of base class.
4874 //================================================================================
4875 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4877 LightApp_Operation* op = 0;
4878 // to do : create operation here
4881 case 417: //convert to quadratic
4882 op = new SMESHGUI_ConvToQuadOp();
4884 case 418: // create 2D mesh as boundary on 3D
4885 op = new SMESHGUI_Make2DFrom3DOp();
4887 case 701: // Compute mesh
4888 op = new SMESHGUI_ComputeOp();
4890 case 702: // Create mesh
4891 op = new SMESHGUI_MeshOp( true, true );
4893 case 703: // Create sub-mesh
4894 op = new SMESHGUI_MeshOp( true, false );
4896 case 704: // Edit mesh/sub-mesh
4897 op = new SMESHGUI_MeshOp( false );
4899 case 711: // Precompute mesh
4900 op = new SMESHGUI_PrecomputeOp();
4902 case 712: // Evaluate mesh
4903 op = new SMESHGUI_EvaluateOp();
4905 case 713: // Evaluate mesh
4906 op = new SMESHGUI_MeshOrderOp();
4908 case 806: // Create group on geom
4909 op = new SMESHGUI_GroupOnShapeOp();
4911 case 904: // Find element
4912 op = new SMESHGUI_FindElemByPointOp();
4914 case 4067: // make mesh pass through point
4915 op = new SMESHGUI_MakeNodeAtPointOp();
4922 op = SalomeApp_Module::createOperation( id );
4926 //================================================================================
4928 * \brief Stops current operations and starts a given one
4929 * \param id - The id of the operation to start
4931 //================================================================================
4933 void SMESHGUI::switchToOperation(int id)
4935 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4936 activeStudy()->abortAllOperations();
4937 startOperation( id );
4940 LightApp_Displayer* SMESHGUI::displayer()
4943 myDisplayer = new SMESHGUI_Displayer( getApp() );
4947 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4950 int aTolerance = 64;
4951 int anIterations = 0;
4957 if( anIterations % aPeriod == 0 )
4960 if( aTolerance < 1 )
4964 aHue = (int)( 360.0 * rand() / RAND_MAX );
4967 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4968 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4969 for( ; it != itEnd; ++it )
4971 SALOMEDS::Color anAutoColor = *it;
4972 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4975 aQColor.getHsv( &h, &s, &v );
4976 if( abs( h - aHue ) < aTolerance )
4988 aColor.setHsv( aHue, 255, 255 );
4990 SALOMEDS::Color aSColor;
4991 aSColor.R = (double)aColor.red() / 255.0;
4992 aSColor.G = (double)aColor.green() / 255.0;
4993 aSColor.B = (double)aColor.blue() / 255.0;
4998 const char gSeparator = '_'; // character used to separate parameter names
4999 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
5000 const char gPathSep = '|'; // character used to separate paths
5003 * \brief Store visual parameters
5005 * This method is called just before the study document is saved.
5006 * Store visual parameters in AttributeParameter attribue(s)
5008 void SMESHGUI::storeVisualParameters (int savePoint)
5010 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5011 if (!appStudy || !appStudy->studyDS())
5013 _PTR(Study) studyDS = appStudy->studyDS();
5015 // componentName is used for encoding of entries when storing them in IParameters
5016 std::string componentName = myComponentSMESH->ComponentDataType();
5017 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5018 //if (!aSComponent) return;
5021 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5022 componentName.c_str(),
5024 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5026 // store map of custom markers
5027 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5028 if( !aMarkerMap.empty() )
5030 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5031 for( ; anIter != aMarkerMap.end(); anIter++ )
5033 int anId = anIter->first;
5034 VTK::MarkerData aMarkerData = anIter->second;
5035 std::string aMarkerFileName = aMarkerData.first;
5036 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5037 if( aMarkerTexture.size() < 3 )
5038 continue; // should contain at least width, height and the first value
5040 QString aPropertyName( "texture" );
5041 aPropertyName += gSeparator;
5042 aPropertyName += QString::number( anId );
5044 QString aPropertyValue = aMarkerFileName.c_str();
5045 aPropertyValue += gPathSep;
5047 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5048 ushort aWidth = *aTextureIter++;
5049 ushort aHeight = *aTextureIter++;
5050 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5051 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5052 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5053 aPropertyValue += QString::number( *aTextureIter );
5055 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5059 // viewers counters are used for storing view_numbers in IParameters
5062 // main cycle to store parameters of displayed objects
5063 QList<SUIT_ViewManager*> lst;
5064 QList<SUIT_ViewManager*>::Iterator it;
5065 getApp()->viewManagers(lst);
5066 for (it = lst.begin(); it != lst.end(); it++)
5068 SUIT_ViewManager* vman = *it;
5069 QString vType = vman->getType();
5071 // saving VTK actors properties
5072 if (vType == SVTK_Viewer::Type())
5074 // store the clipping planes attached to the view manager
5075 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5076 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5077 if( anIter != myClippingPlaneInfoMap.end() )
5078 aClippingPlaneInfoList = anIter->second;
5080 if( !aClippingPlaneInfoList.empty() ) {
5081 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5082 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5084 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5085 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5087 QString aPropertyName( "ClippingPlane" );
5088 aPropertyName += gSeparator;
5089 aPropertyName += QString::number( vtkViewers );
5090 aPropertyName += gSeparator;
5091 aPropertyName += QString::number( anId );
5093 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5094 aPropertyValue += gDigitsSep;
5095 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5096 aPropertyValue += gDigitsSep;
5097 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5098 aPropertyValue += gDigitsSep;
5099 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5101 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5105 QVector<SUIT_ViewWindow*> views = vman->getViews();
5106 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5108 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5110 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5111 vtkActorCollection* allActors = aCopy.GetActors();
5112 allActors->InitTraversal();
5113 while (vtkActor* actor = allActors->GetNextActor())
5115 if (actor->GetVisibility()) // store only visible actors
5117 SMESH_Actor* aSmeshActor = 0;
5118 if (actor->IsA("SMESH_Actor"))
5119 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5120 if (aSmeshActor && aSmeshActor->hasIO())
5122 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5125 // entry is "encoded" = it does NOT contain component adress,
5126 // since it is a subject to change on next component loading
5127 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5129 std::string param, vtkParam = vType.toLatin1().data();
5130 vtkParam += gSeparator;
5131 vtkParam += QString::number(vtkViewers).toLatin1().data();
5132 vtkParam += gSeparator;
5135 param = vtkParam + "Visibility";
5136 ip->setParameter(entry, param, "On");
5139 param = vtkParam + "Representation";
5140 ip->setParameter(entry, param, QString::number
5141 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5144 param = vtkParam + "IsShrunk";
5145 ip->setParameter(entry, param, QString::number
5146 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5148 // Displayed entities
5149 unsigned int aMode = aSmeshActor->GetEntityMode();
5150 bool isE = aMode & SMESH_Actor::eEdges;
5151 bool isF = aMode & SMESH_Actor::eFaces;
5152 bool isV = aMode & SMESH_Actor::eVolumes;
5154 QString modeStr ("e");
5155 modeStr += gDigitsSep; modeStr += QString::number(isE);
5156 modeStr += gDigitsSep; modeStr += "f";
5157 modeStr += gDigitsSep; modeStr += QString::number(isF);
5158 modeStr += gDigitsSep; modeStr += "v";
5159 modeStr += gDigitsSep; modeStr += QString::number(isV);
5161 param = vtkParam + "Entities";
5162 ip->setParameter(entry, param, modeStr.toLatin1().data());
5164 // Colors (surface:edge:)
5165 vtkFloatingPointType r, g, b;
5168 aSmeshActor->GetSufaceColor(r, g, b, delta);
5169 QString colorStr ("surface");
5170 colorStr += gDigitsSep; colorStr += QString::number(r);
5171 colorStr += gDigitsSep; colorStr += QString::number(g);
5172 colorStr += gDigitsSep; colorStr += QString::number(b);
5174 colorStr += gDigitsSep; colorStr += "backsurface";
5175 colorStr += gDigitsSep; colorStr += QString::number(delta);
5178 aSmeshActor->GetEdgeColor(r, g, b);
5179 colorStr += gDigitsSep; colorStr += "edge";
5180 colorStr += gDigitsSep; colorStr += QString::number(r);
5181 colorStr += gDigitsSep; colorStr += QString::number(g);
5182 colorStr += gDigitsSep; colorStr += QString::number(b);
5184 aSmeshActor->GetNodeColor(r, g, b);
5185 colorStr += gDigitsSep; colorStr += "node";
5186 colorStr += gDigitsSep; colorStr += QString::number(r);
5187 colorStr += gDigitsSep; colorStr += QString::number(g);
5188 colorStr += gDigitsSep; colorStr += QString::number(b);
5190 aSmeshActor->GetOutlineColor(r, g, b);
5191 colorStr += gDigitsSep; colorStr += "outline";
5192 colorStr += gDigitsSep; colorStr += QString::number(r);
5193 colorStr += gDigitsSep; colorStr += QString::number(g);
5194 colorStr += gDigitsSep; colorStr += QString::number(b);
5196 param = vtkParam + "Colors";
5197 ip->setParameter(entry, param, colorStr.toLatin1().data());
5199 // Sizes of lines and points
5200 QString sizeStr ("line");
5201 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5202 sizeStr += gDigitsSep; sizeStr += "shrink";
5203 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5205 param = vtkParam + "Sizes";
5206 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5211 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5212 if( aMarkerType == VTK::MT_USER ) {
5213 markerStr += "custom";
5214 markerStr += gDigitsSep;
5215 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5219 markerStr += gDigitsSep;
5220 markerStr += QString::number( (int)aMarkerType );
5221 markerStr += gDigitsSep;
5222 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5225 param = vtkParam + "PointMarker";
5226 ip->setParameter(entry, param, markerStr.toLatin1().data());
5229 param = vtkParam + "Opacity";
5230 ip->setParameter(entry, param,
5231 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5234 param = vtkParam + "ClippingPlane";
5236 if( !aClippingPlaneInfoList.empty() ) {
5237 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5238 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5240 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5241 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5242 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5243 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5244 if( aSmeshActor == *anIter2 ) {
5245 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5246 QString::number( anId ).toLatin1().constData() );
5253 ip->setParameter( entry, param, "Off" );
5254 } // if (io->hasEntry())
5255 } // SMESH_Actor && hasIO
5257 } // while.. actors traversal
5261 } // if (SVTK view model)
5262 } // for (viewManagers)
5265 // data structures for clipping planes processing
5268 vtkIdType Orientation;
5269 vtkFloatingPointType Distance;
5270 vtkFloatingPointType Angle[2];
5272 typedef std::list<TPlaneData> TPlaneDataList;
5273 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5275 typedef std::list<vtkActor*> TActorList;
5278 TActorList ActorList;
5279 SUIT_ViewManager* ViewManager;
5281 typedef std::list<TPlaneInfo> TPlaneInfoList;
5282 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5285 * \brief Restore visual parameters
5287 * This method is called after the study document is opened.
5288 * Restore visual parameters from AttributeParameter attribue(s)
5290 void SMESHGUI::restoreVisualParameters (int savePoint)
5292 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5293 if (!appStudy || !appStudy->studyDS())
5295 _PTR(Study) studyDS = appStudy->studyDS();
5297 // componentName is used for encoding of entries when storing them in IParameters
5298 std::string componentName = myComponentSMESH->ComponentDataType();
5299 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5300 //if (!aSComponent) return;
5303 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5304 componentName.c_str(),
5306 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5308 // restore map of custom markers and map of clipping planes
5309 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5310 TPlaneDataMap aPlaneDataMap;
5312 std::vector<std::string> properties = ip->getProperties();
5313 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5315 std::string property = *propIt;
5316 QString aPropertyName( property.c_str() );
5317 QString aPropertyValue( ip->getProperty( property ).c_str() );
5319 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5320 if( aPropertyNameList.isEmpty() )
5323 QString aPropertyType = aPropertyNameList[0];
5324 if( aPropertyType == "texture" )
5326 if( aPropertyNameList.size() != 2 )
5330 int anId = aPropertyNameList[1].toInt( &ok );
5331 if( !ok || anId < 1 )
5334 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5335 if( aPropertyValueList.size() != 2 )
5338 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5339 QString aMarkerTextureString = aPropertyValueList[1];
5340 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5341 if( aMarkerTextureStringList.size() != 3 )
5345 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5350 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5354 VTK::MarkerTexture aMarkerTexture;
5355 aMarkerTexture.push_back( aWidth );
5356 aMarkerTexture.push_back( aHeight );
5358 QString aMarkerTextureData = aMarkerTextureStringList[2];
5359 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5361 QChar aChar = aMarkerTextureData.at( i );
5362 if( aChar.isDigit() )
5363 aMarkerTexture.push_back( aChar.digitValue() );
5366 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5368 else if( aPropertyType == "ClippingPlane" )
5370 if( aPropertyNameList.size() != 3 )
5374 int aViewId = aPropertyNameList[1].toInt( &ok );
5375 if( !ok || aViewId < 0 )
5379 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5380 if( !ok || aClippingPlaneId < 0 )
5383 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5384 if( aPropertyValueList.size() != 4 )
5387 TPlaneData aPlaneData;
5388 aPlaneData.Id = aClippingPlaneId;
5391 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5396 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5401 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5406 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5410 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5411 aPlaneDataList.push_back( aPlaneData );
5415 TPlaneInfoMap aPlaneInfoMap;
5417 std::vector<std::string> entries = ip->getEntries();
5419 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5421 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5422 QString entry (ip->decodeEntry(*entIt).c_str());
5424 // Check that the entry corresponds to a real object in the Study
5425 // as the object may be deleted or modified after the visual state is saved.
5426 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5427 if (!so) continue; //Skip the not existent entry
5429 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5430 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5432 std::vector<std::string>::iterator namesIt = paramNames.begin();
5433 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5435 // actors are stored in a map after displaying of them for
5436 // quicker access in the future: map < viewID to actor >
5437 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5439 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5441 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5442 // '_' is used as separator and should not be used in viewer type or parameter names.
5443 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5444 if (lst.size() != 3)
5447 QString viewerTypStr = lst[0];
5448 QString viewIndexStr = lst[1];
5449 QString paramNameStr = lst[2];
5452 int viewIndex = viewIndexStr.toUInt(&ok);
5453 if (!ok) // bad conversion of view index to integer
5457 if (viewerTypStr == SVTK_Viewer::Type())
5459 SMESH_Actor* aSmeshActor = 0;
5460 if (vtkActors.IsBound(viewIndex))
5461 aSmeshActor = vtkActors.Find(viewIndex);
5463 QList<SUIT_ViewManager*> lst;
5464 getApp()->viewManagers(viewerTypStr, lst);
5466 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5467 SUIT_ViewManager* vman = NULL;
5468 if (viewIndex >= 0 && viewIndex < lst.count())
5469 vman = lst.at(viewIndex);
5471 if (paramNameStr == "Visibility")
5473 if (!aSmeshActor && displayer() && vman)
5475 SUIT_ViewModel* vmodel = vman->getViewModel();
5476 // SVTK view model can be casted to SALOME_View
5477 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5479 // store displayed actor in a temporary map for quicker
5480 // access later when restoring other parameters
5481 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5482 vtkRenderer* Renderer = vtkView->getRenderer();
5483 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5484 vtkActorCollection* theActors = aCopy.GetActors();
5485 theActors->InitTraversal();
5486 bool isFound = false;
5487 vtkActor *ac = theActors->GetNextActor();
5488 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5489 if (ac->IsA("SMESH_Actor")) {
5490 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5491 if (aGeomAc->hasIO()) {
5492 Handle(SALOME_InteractiveObject) io =
5493 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5494 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5496 vtkActors.Bind(viewIndex, aGeomAc);
5502 } // if (paramNameStr == "Visibility")
5505 // the rest properties "work" with SMESH_Actor
5508 QString val ((*valuesIt).c_str());
5511 if (paramNameStr == "Representation") {
5512 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5515 else if (paramNameStr == "IsShrunk") {
5517 if (!aSmeshActor->IsShrunk())
5518 aSmeshActor->SetShrink();
5521 if (aSmeshActor->IsShrunk())
5522 aSmeshActor->UnShrink();
5525 // Displayed entities
5526 else if (paramNameStr == "Entities") {
5527 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5528 if (mode.count() == 6) {
5529 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5530 MESSAGE("Invalid order of data in Entities, must be: "
5531 "e:0/1:f:0/1:v:0/1");
5534 unsigned int aMode = aSmeshActor->GetEntityMode();
5535 unsigned int aNewMode =
5536 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5537 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5538 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5539 if (aNewMode != aMode)
5540 aSmeshActor->SetEntityMode(aNewMode);
5545 else if (paramNameStr == "Colors") {
5546 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5547 if (colors.count() == 16 || colors.count() == 18 ) {
5548 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5549 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
5550 (colors.count() == 18 && colors[14] != "outline")) {
5551 MESSAGE("Invalid order of data in Colors, must be: "
5552 "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");
5558 vtkFloatingPointType otr,otg,otb;
5559 //Old case backsurface color is independent
5560 if( colors.count() == 16 ) {
5562 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5563 er = colors[9].toFloat();
5564 eg = colors[10].toFloat();
5565 eb = colors[11].toFloat();
5567 nr = colors[13].toFloat();
5568 ng = colors[14].toFloat();
5569 nb = colors[15].toFloat();
5570 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5572 //New case backsurface color depends on surface color
5573 delta = colors[5].toInt();
5575 er = colors[7].toFloat();
5576 eg = colors[8].toFloat();
5577 eb = colors[9].toFloat();
5579 nr = colors[11].toFloat();
5580 ng = colors[12].toFloat();
5581 nb = colors[13].toFloat();
5583 otr = colors[15].toFloat();
5584 otg = colors[16].toFloat();
5585 otb = colors[17].toFloat();
5587 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5588 aSmeshActor->SetEdgeColor(er,eg,eb);
5589 aSmeshActor->SetNodeColor(nr,ng,nb);
5590 aSmeshActor->SetOutlineColor(otr,otg,otb);
5594 // Sizes of lines and points
5595 else if (paramNameStr == "Sizes") {
5596 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5597 if (sizes.count() == 4) {
5598 if (sizes[0] != "line" || sizes[2] != "shrink") {
5599 MESSAGE("Invalid order of data in Sizes, must be: "
5600 "line:int:shrink:float");
5603 aSmeshActor->SetLineWidth(sizes[1].toInt());
5604 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5607 else if (sizes.count() == 6) { // just to support old format
5608 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5609 MESSAGE("Invalid order of data in Sizes, must be: "
5610 "line:int:node:int:shrink:float");
5613 aSmeshActor->SetLineWidth(sizes[1].toInt());
5614 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5615 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5620 else if (paramNameStr == "PointMarker") {
5621 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5622 if( data.count() >= 2 ) {
5624 int aParam1 = data[1].toInt( &ok );
5626 if( data[0] == "std" && data.count() == 3 ) {
5627 int aParam2 = data[2].toInt( &ok );
5628 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5630 else if( data[0] == "custom" ) {
5631 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5632 if( markerIt != aMarkerMap.end() ) {
5633 VTK::MarkerData aMarkerData = markerIt->second;
5634 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5641 else if (paramNameStr == "Opacity") {
5642 aSmeshActor->SetOpacity(val.toFloat());
5645 else if (paramNameStr.startsWith("ClippingPlane")) {
5646 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5647 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5648 // new format - val looks like "Off" or "0" (plane id)
5649 // (note: in new format "Off" value is used only for consistency,
5650 // so it is processed together with values in old format)
5651 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5652 if( anIsOldFormat ) {
5653 if (paramNameStr == "ClippingPlane1" || val == "Off")
5654 aSmeshActor->RemoveAllClippingPlanes();
5656 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5657 double aDistance = vals[1].toFloat();
5658 vtkFloatingPointType anAngle[2];
5659 anAngle[0] = vals[2].toFloat();
5660 anAngle[1] = vals[3].toFloat();
5662 QList<SUIT_ViewManager*> lst;
5663 getApp()->viewManagers(viewerTypStr, lst);
5664 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5665 if (viewIndex >= 0 && viewIndex < lst.count()) {
5666 SUIT_ViewManager* vman = lst.at(viewIndex);
5667 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5669 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5671 SMESH::TActorList anActorList;
5672 anActorList.push_back( aSmeshActor );
5673 SMESH::OrientedPlane* aPlane =
5674 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5676 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5677 aClippingPlaneInfo.Plane = aPlane;
5678 aClippingPlaneInfo.ActorList = anActorList;
5679 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5686 int aPlaneId = val.toInt( &ok );
5687 if( ok && aPlaneId >= 0 ) {
5688 bool anIsDefinedPlane = false;
5689 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5690 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5691 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5692 TPlaneInfo& aPlaneInfo = *anIter;
5693 if( aPlaneInfo.PlaneId == aPlaneId ) {
5694 aPlaneInfo.ActorList.push_back( aSmeshActor );
5695 anIsDefinedPlane = true;
5699 if( !anIsDefinedPlane ) {
5700 TPlaneInfo aPlaneInfo;
5701 aPlaneInfo.PlaneId = aPlaneId;
5702 aPlaneInfo.ActorList.push_back( aSmeshActor );
5703 aPlaneInfo.ViewManager = vman;
5705 // to make the list sorted by plane id
5706 anIter = aPlaneInfoList.begin();
5707 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5708 const TPlaneInfo& aPlaneInfoRef = *anIter;
5709 if( aPlaneInfoRef.PlaneId > aPlaneId )
5712 aPlaneInfoList.insert( anIter, aPlaneInfo );
5717 } // if (aSmeshActor)
5718 } // other parameters than Visibility
5720 } // for names/parameters iterator
5721 } // for entries iterator
5723 // take into account planes with empty list of actors referred to them
5724 QList<SUIT_ViewManager*> aVMList;
5725 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5727 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5728 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5729 int aViewId = aPlaneDataIter->first;
5730 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5731 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5733 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5735 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5736 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5737 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5738 const TPlaneData& aPlaneData = *anIter2;
5739 int aPlaneId = aPlaneData.Id;
5741 bool anIsFound = false;
5742 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5743 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5744 const TPlaneInfo& aPlaneInfo = *anIter3;
5745 if( aPlaneInfo.PlaneId == aPlaneId ) {
5752 TPlaneInfo aPlaneInfo; // ActorList field is empty
5753 aPlaneInfo.PlaneId = aPlaneId;
5754 aPlaneInfo.ViewManager = aViewManager;
5756 // to make the list sorted by plane id
5757 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5758 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5759 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5760 if( aPlaneInfoRef.PlaneId > aPlaneId )
5763 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5769 // add clipping planes to actors according to the restored parameters
5770 // and update the clipping plane map
5771 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5772 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5773 int aViewId = anIter1->first;
5774 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5776 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5777 if( anIter2 == aPlaneDataMap.end() )
5779 const TPlaneDataList& aPlaneDataList = anIter2->second;
5781 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5782 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5783 const TPlaneInfo& aPlaneInfo = *anIter3;
5784 int aPlaneId = aPlaneInfo.PlaneId;
5785 const TActorList& anActorList = aPlaneInfo.ActorList;
5786 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5790 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5794 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5796 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5797 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5798 const TPlaneData& aPlaneData = *anIter4;
5799 if( aPlaneData.Id == aPlaneId ) {
5800 SMESH::OrientedPlane* aPlane =
5801 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5803 (SMESH::Orientation)aPlaneData.Orientation,
5804 aPlaneData.Distance,
5807 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5808 aClippingPlaneInfo.Plane = aPlane;
5809 aClippingPlaneInfo.ActorList = anActorList;
5810 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5818 // update all VTK views
5819 QList<SUIT_ViewManager*> lst;
5820 getApp()->viewManagers(lst);
5821 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5822 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5823 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5824 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5825 vtkView->getRenderer()->ResetCameraClippingRange();
5832 \brief Adds preferences for dfont of VTK viewer
5834 \param pIf group identifier
5835 \param param parameter
5836 \return identifier of preferences
5838 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5840 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5842 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5845 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5846 fam.append( tr( "SMESH_FONT_COURIER" ) );
5847 fam.append( tr( "SMESH_FONT_TIMES" ) );
5849 setPreferenceProperty( tfont, "fonts", fam );
5851 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5852 setPreferenceProperty( tfont, "features", f );
5858 \brief Actions after hypothesis edition
5859 Updates object browser after hypothesis edition
5861 void SMESHGUI::onHypothesisEdit( int result )
5864 SMESHGUI::Modified();
5865 updateObjBrowser( true );
5870 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5871 \param pview view being closed
5873 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5874 #ifndef DISABLE_PLOT2DVIEWER
5875 //Crear all Plot2d Viewers if need.
5876 SMESH::ClearPlot2Viewers(pview);
5881 \brief Connects or disconnects signals about activating and cloning view on the module slots
5882 \param pview view which is connected/disconnected
5884 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5888 SUIT_ViewManager* viewMgr = pview->getViewManager();
5890 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5891 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5893 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5894 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5899 \brief Return \c true if object can be renamed
5901 bool SMESHGUI::renameAllowed( const QString& entry) const {
5902 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5906 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5910 bool appRes = SalomeApp_Module::renameAllowed(entry);
5914 // check type to prevent renaming of inappropriate objects
5915 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5916 if (aType == MESH || aType == GROUP ||
5917 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5918 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5919 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5920 aType == HYPOTHESIS || aType == ALGORITHM)
5927 Rename object by entry.
5928 \param entry entry of the object
5929 \param name new name of the object
5930 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5932 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5934 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5938 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5942 bool appRes = SalomeApp_Module::renameObject(entry,name);
5946 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5947 _PTR(GenericAttribute) anAttr;
5948 _PTR(AttributeName) aName;
5950 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5952 // check type to prevent renaming of inappropriate objects
5953 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5954 if (aType == MESH || aType == GROUP ||
5955 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5956 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5957 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5958 aType == HYPOTHESIS || aType == ALGORITHM) {
5959 if ( !name.isEmpty() ) {
5960 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5962 // update name of group object and its actor
5963 Handle(SALOME_InteractiveObject) IObject =
5964 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5966 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5967 if( !aGroupObject->_is_nil() ) {
5968 aGroupObject->SetName( qPrintable(name) );
5969 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5970 anActor->setName( qPrintable(name) );