1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
32 #include "SMESHGUI_AddMeshElementDlg.h"
33 #include "SMESHGUI_AddQuadraticElementDlg.h"
34 #include "SMESHGUI_BuildCompoundDlg.h"
35 #include "SMESHGUI_ClippingDlg.h"
36 #include "SMESHGUI_ComputeDlg.h"
37 #include "SMESHGUI_ConvToQuadOp.h"
38 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
39 #include "SMESHGUI_DeleteGroupDlg.h"
40 #include "SMESHGUI_Displayer.h"
41 #include "SMESHGUI_MergeDlg.h"
42 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
43 #include "SMESHGUI_ExtrusionDlg.h"
44 #include "SMESHGUI_FileInfoDlg.h"
45 #include "SMESHGUI_FileValidator.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_FindElemByPointDlg.h"
49 #include "SMESHGUI_GroupDlg.h"
50 #include "SMESHGUI_GroupOnShapeDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_Hypotheses.h"
53 #include "SMESHGUI_Make2DFrom3DOp.h"
54 #include "SMESHGUI_MakeNodeAtPointDlg.h"
55 #include "SMESHGUI_Measurements.h"
56 #include "SMESHGUI_MeshInfo.h"
57 #include "SMESHGUI_MeshOp.h"
58 #include "SMESHGUI_MeshOrderOp.h"
59 #include "SMESHGUI_MeshPatternDlg.h"
60 #include "SMESHGUI_MultiEditDlg.h"
61 #include "SMESHGUI_NodesDlg.h"
62 #include "SMESHGUI_Preferences_ColorDlg.h"
63 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
64 #include "SMESHGUI_RemoveElementsDlg.h"
65 #include "SMESHGUI_RemoveNodesDlg.h"
66 #include "SMESHGUI_RenumberingDlg.h"
67 #include "SMESHGUI_RevolutionDlg.h"
68 #include "SMESHGUI_RotationDlg.h"
69 #include "SMESHGUI_Selection.h"
70 #include "SMESHGUI_SewingDlg.h"
71 #include "SMESHGUI_SingleEditDlg.h"
72 #include "SMESHGUI_SmoothingDlg.h"
73 #include "SMESHGUI_SymmetryDlg.h"
74 #include "SMESHGUI_TranslationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_TransparencyDlg.h"
77 //#include "SMESHGUI_WhatIsDlg.h"
78 #include "SMESHGUI_DuplicateNodesDlg.h"
79 #include "SMESHGUI_CopyMeshDlg.h"
81 #include "SMESHGUI_Utils.h"
82 #include "SMESHGUI_MeshUtils.h"
83 #include "SMESHGUI_GroupUtils.h"
84 #include "SMESHGUI_FilterUtils.h"
85 #include "SMESHGUI_PatternUtils.h"
86 #include "SMESHGUI_VTKUtils.h"
87 #include "SMESHGUI_HypothesesUtils.h"
89 #include <SMESH_version.h>
91 #include <SMESH_Client.hxx>
92 #include <SMESH_Actor.h>
93 #include <SMESH_ScalarBarActor.h>
94 #include <SMESH_ActorUtils.h>
95 #include <SMESH_TypeFilter.hxx>
96 #include "SMESH_ControlsDef.hxx"
98 // SALOME GUI includes
99 #include <SalomeApp_Tools.h>
100 #include <SalomeApp_Study.h>
101 #include <SalomeApp_Application.h>
102 #include <SalomeApp_CheckFileDlg.h>
104 #include <LightApp_DataOwner.h>
105 #include <LightApp_Preferences.h>
106 #include <LightApp_SelectionMgr.h>
107 #include <LightApp_UpdateFlags.h>
108 #include <LightApp_NameDlg.h>
110 #include <SVTK_ViewWindow.h>
111 #include <SVTK_ViewModel.h>
112 #include <SVTK_ViewManager.h>
114 #include <VTKViewer_Algorithm.h>
116 #include <SUIT_MessageBox.h>
117 #include <SUIT_ResourceMgr.h>
118 #include <SUIT_FileDlg.h>
119 #include <SUIT_Desktop.h>
120 #include <SUIT_OverrideCursor.h>
121 #include <SUIT_Session.h>
123 #include <QtxPopupMgr.h>
124 #include <QtxFontEdit.h>
126 #include <SALOME_ListIO.hxx>
127 #include <SALOME_ListIteratorOfListIO.hxx>
129 #ifndef DISABLE_PLOT2DVIEWER
130 #include <SPlot2d_ViewModel.h>
131 #include <SPlot2d_Histogram.h>
135 #include <SALOMEconfig.h>
136 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
137 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
138 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
141 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
143 #include <QTextStream>
146 #include <boost/shared_ptr.hpp>
149 #include <vtkCamera.h>
150 #include <vtkRenderer.h>
151 #include <vtkPlane.h>
152 #include <vtkCallbackCommand.h>
153 #include <vtkLookupTable.h>
155 // SALOME KERNEL includes
156 #include <SALOMEDS_Study.hxx>
157 #include <SALOMEDSClient_StudyBuilder.hxx>
158 #include <SALOMEDSClient_SComponent.hxx>
159 #include <SALOMEDSClient_ClientFactory.hxx>
160 #include <SALOMEDSClient_IParameters.hxx>
163 #include <Standard_ErrorHandler.hxx>
164 #include <NCollection_DataMap.hxx>
166 //To disable automatic genericobj management, the following line should be commented.
167 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
168 #define WITHGENERICOBJ
172 //=============================================================
173 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
176 void ExportMeshToFile(int theCommandID);
178 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
180 void SetDisplayEntity(int theCommandID);
182 void Control( int theCommandID );
186 //=============================================================
187 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
191 std::string myExtension;
193 if ( theCommandID == 113 ) {
194 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
195 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
197 else if ( theCommandID == 112 ) {
198 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
200 else if ( theCommandID == 111 ) {
201 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
203 else if ( theCommandID == 115 ) {
204 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
206 else if ( theCommandID == 116 ) {
207 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
209 else if ( theCommandID == 117 ) {
210 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
211 filter.append( QObject::tr( "All files (*)" ) );
214 QString anInitialPath = "";
215 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
216 anInitialPath = QDir::currentPath();
218 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
221 QObject::tr( "SMESH_IMPORT_MESH" ) );
222 if ( filenames.count() > 0 ) {
223 SUIT_OverrideCursor wc;
224 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
227 QStringList anEntryList;
228 bool isEmpty = false;
229 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
230 QString filename = *it;
231 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
233 switch ( theCommandID ) {
236 // DAT format (currently unsupported)
237 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
238 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
244 aMeshes->length( 1 );
245 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
246 if ( aMeshes[0]->_is_nil() )
247 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
248 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
254 SMESH::DriverMED_ReadStatus res;
255 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
256 if ( res != SMESH::DRS_OK ) {
257 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
258 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
265 aMeshes->length( 1 );
266 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
267 if ( aMeshes[0]->_is_nil() ) {
268 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
269 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
276 SMESH::DriverMED_ReadStatus res;
277 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
278 if ( res != SMESH::DRS_OK ) {
279 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
280 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
287 SMESH::DriverMED_ReadStatus res;
288 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
289 if ( res != SMESH::DRS_OK ) {
290 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
291 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
297 catch ( const SALOME::SALOME_Exception& S_ex ) {
298 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
299 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
302 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
303 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
305 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
306 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
307 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
308 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
309 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
311 anEntryList.append( aMeshSO->GetID().c_str() );
313 #ifdef WITHGENERICOBJ
314 // obj has been published in study. Its refcount has been incremented.
315 // It is safe to decrement its refcount
316 // so that it will be destroyed when the entry in study will be removed
317 aMeshes[i]->UnRegister();
326 // update Object browser
327 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
329 // browse to the published meshes
330 if( LightApp_Application* anApp =
331 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
332 anApp->browseObjects( anEntryList );
334 // show Error message box if there were errors
335 if ( errors.count() > 0 ) {
336 SUIT_MessageBox::critical( SMESHGUI::desktop(),
337 QObject::tr( "SMESH_ERROR" ),
338 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
341 // show warning message box, if some imported mesh is empty
343 SUIT_MessageBox::warning( SMESHGUI::desktop(),
344 QObject::tr( "SMESH_WRN_WARNING" ),
345 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
350 //================================================================================
352 * \brief Export selected meshes or groups into a file
354 //================================================================================
356 void ExportMeshToFile( int theCommandID )
358 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
359 SALOME_ListIO selected;
361 aSel->selectedObjects( selected );
363 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
364 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
365 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
366 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
367 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
368 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
370 // actually, the following condition can't be met (added for insurance)
371 if( selected.Extent() == 0 ||
372 ( selected.Extent() > 1 && !isMED && !isSTL ))
375 // get mesh object from selection and check duplication of their names
376 bool hasDuplicatedMeshNames = false;
377 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
378 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
379 SALOME_ListIteratorOfListIO It( selected );
380 for( ; It.More(); It.Next() )
382 Handle(SALOME_InteractiveObject) anIObject = It.Value();
383 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
384 if ( aMeshItem->_is_nil() ) {
385 SUIT_MessageBox::warning( SMESHGUI::desktop(),
386 QObject::tr( "SMESH_WRN_WARNING" ),
387 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
391 QString aMeshName = anIObject->getName();
393 // check for name duplications
394 if ( !hasDuplicatedMeshNames )
395 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
396 if( aMeshName == (*aMeshIter).second ) {
397 hasDuplicatedMeshNames = true;
402 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
405 if( hasDuplicatedMeshNames && isMED ) {
406 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
407 QObject::tr("SMESH_WRN_WARNING"),
408 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
409 QObject::tr("SMESH_BUT_YES"),
410 QObject::tr("SMESH_BUT_NO"), 0, 1);
415 aMeshIter = aMeshList.begin();
416 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
417 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
418 QString aMeshName = (*aMeshIter).second;
420 if ( isMED || isCGNS || isSAUV )
422 // check for equal group names within each mesh
423 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
424 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
425 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
426 int aRet = SUIT_MessageBox::warning
427 (SMESHGUI::desktop(),
428 QObject::tr("SMESH_WRN_WARNING"),
429 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
430 QObject::tr("SMESH_BUT_YES"),
431 QObject::tr("SMESH_BUT_NO"), 0, 1);
439 // warn the user about presence of not supported elements
440 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
441 int nbPyramids = nbElems[ SMESH::Entity_Pyramid ] + nbElems[ SMESH::Entity_Quad_Pyramid ];
442 if ( nbPyramids > 0 ) {
443 int aRet = SUIT_MessageBox::warning
444 (SMESHGUI::desktop(),
445 QObject::tr("SMESH_WRN_WARNING"),
446 QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
447 QObject::tr("SMESH_BUT_YES"),
448 QObject::tr("SMESH_BUT_NO"), 0, 1);
454 // Get parameters of export operation
457 SMESH::MED_VERSION aFormat;
458 // Init the parameters with the default values
459 bool aIsASCII_STL = true;
460 bool toCreateGroups = false;
461 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
463 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
464 bool toOverwrite = true;
466 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
467 QString anInitialPath = "";
468 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
469 anInitialPath = QDir::currentPath();
471 if ( isUNV || isDAT )
474 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
476 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
477 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
478 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
479 anInitialPath + QString("/") + aMeshName,
480 aFilter, aTitle, false);
482 else if ( isCGNS )// Export to CGNS
484 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
485 fd->setWindowTitle( aTitle );
486 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
487 if ( !anInitialPath.isEmpty() )
488 fd->setDirectory( anInitialPath );
489 fd->selectFile(aMeshName);
490 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
491 fd->setValidator( fv );
494 aFilename = fd->selectedFile();
495 toOverwrite = fv->isOverwrite();
499 else if ( isSTL ) // Export to STL
501 QMap<QString, int> aFilterMap;
502 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
503 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
506 QMap<QString, int>::const_iterator it = aFilterMap.begin();
507 for ( ; it != aFilterMap.end(); ++it )
508 filters.push_back( it.key() );
510 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
511 fd->setWindowTitle( aTitle );
512 fd->setNameFilters( filters );
513 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
514 if ( !anInitialPath.isEmpty() )
515 fd->setDirectory( anInitialPath );
516 fd->selectFile(aMeshName);
520 aFilename = fd->selectedFile();
521 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
526 else if ( isMED || isSAUV ) // Export to MED or SAUV
528 QMap<QString, SMESH::MED_VERSION> aFilterMap;
529 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
531 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
532 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
533 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
536 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
537 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
538 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
542 QString aDefaultFilter;
543 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
544 for ( ; it != aFilterMap.end(); ++it ) {
545 filters.push_back( it.key() );
546 if (it.value() == SMESH::MED_V2_2)
547 aDefaultFilter = it.key();
550 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
551 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
552 fd->setWindowTitle( aTitle );
553 fd->setNameFilters( filters );
554 fd->selectNameFilter(aDefaultFilter);
555 fd->SetChecked(toCreateGroups);
556 if ( !anInitialPath.isEmpty() )
557 fd->setDirectory( anInitialPath );
558 fd->selectFile(aMeshName);
560 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
561 fd->setValidator( fv );
566 aFilename = fd->selectedFile();
568 aFilename = QString::null;
571 aFormat = aFilterMap[fd->selectedNameFilter()];
572 toOverwrite = fv->isOverwrite();
574 if ( !aFilename.isEmpty() ) {
575 // med-2.1 does not support poly elements
576 if ( aFormat==SMESH::MED_V2_1 )
577 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
578 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
579 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
580 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
581 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
583 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
584 QObject::tr("SMESH_WRN_WARNING"),
585 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
586 QObject::tr("SMESH_BUT_YES"),
587 QObject::tr("SMESH_BUT_NO"), 0, 1);
595 // can't append to an existing using other format
596 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
597 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
598 if( !isVersionOk || aVersion != aFormat ) {
599 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
600 QObject::tr("SMESH_WRN_WARNING"),
601 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
602 QObject::tr("SMESH_BUT_YES"),
603 QObject::tr("SMESH_BUT_NO"), 0, 1);
610 QStringList aMeshNamesCollisionList;
611 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
612 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
613 QString anExistingMeshName( aMeshNames[ i ] );
614 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
615 QString anExportMeshName = (*aMeshIter).second;
616 if( anExportMeshName == anExistingMeshName ) {
617 aMeshNamesCollisionList.append( anExportMeshName );
622 if( !aMeshNamesCollisionList.isEmpty() ) {
623 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
624 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
625 QObject::tr("SMESH_WRN_WARNING"),
626 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
627 QObject::tr("SMESH_BUT_YES"),
628 QObject::tr("SMESH_BUT_NO"),
629 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
638 toCreateGroups = fd->IsChecked();
648 if ( !aFilename.isEmpty() ) {
649 // Check whether the file already exists and delete it if yes
650 QFile aFile( aFilename );
651 if ( aFile.exists() && toOverwrite )
653 SUIT_OverrideCursor wc;
656 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
657 // bool Renumber = false;
658 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
660 // Renumber= resMgr->booleanValue("SMESH","renumbering");
662 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
663 // aMeshEditor->RenumberNodes();
664 // aMeshEditor->RenumberElements();
665 // if ( SMESHGUI::automaticUpdate() )
666 // SMESH::UpdateView();
670 aMeshIter = aMeshList.begin();
671 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
673 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
674 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
675 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
676 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
677 aFormat, toOverwrite && aMeshIndex == 0 );
679 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
680 aFormat, toOverwrite && aMeshIndex == 0 );
685 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
687 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
688 if( !aMeshItem->_is_nil() )
689 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
694 if ( aMeshOrGroup->_is_equivalent( aMesh ))
695 aMesh->ExportDAT( aFilename.toLatin1().data() );
697 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
701 if ( aMeshOrGroup->_is_equivalent( aMesh ))
702 aMesh->ExportUNV( aFilename.toLatin1().data() );
704 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
708 if ( aMeshOrGroup->_is_equivalent( aMesh ))
709 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
711 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
715 aMeshIter = aMeshList.begin();
716 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
718 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
719 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
720 aMeshItem->ExportCGNS( aMeshOrGroup,
721 aFilename.toLatin1().data(),
722 toOverwrite && aMeshIndex == 0 );
726 catch (const SALOME::SALOME_Exception& S_ex){
728 SUIT_MessageBox::warning(SMESHGUI::desktop(),
729 QObject::tr("SMESH_WRN_WARNING"),
730 QObject::tr("SMESH_EXPORT_FAILED"));
736 inline void InverseEntityMode(unsigned int& theOutputMode,
737 unsigned int theMode)
739 bool anIsNotPresent = ~theOutputMode & theMode;
741 theOutputMode |= theMode;
743 theOutputMode &= ~theMode;
746 void SetDisplayEntity(int theCommandID){
747 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
748 SALOME_ListIO selected;
750 aSel->selectedObjects( selected );
752 if(selected.Extent() >= 1){
753 SALOME_ListIteratorOfListIO It( selected );
754 for( ; It.More(); It.Next()){
755 Handle(SALOME_InteractiveObject) IObject = It.Value();
756 if(IObject->hasEntry()){
757 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
758 unsigned int aMode = anActor->GetEntityMode();
759 switch(theCommandID){
761 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
764 InverseEntityMode(aMode,SMESH_Actor::eEdges);
767 InverseEntityMode(aMode,SMESH_Actor::eFaces);
770 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
773 aMode = SMESH_Actor::eAllEntity;
777 anActor->SetEntityMode(aMode);
785 SALOME_ListIO selected;
786 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
790 LightApp_SelectionMgr* aSel = app->selectionMgr();
791 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
792 if( !aSel || !appStudy )
795 aSel->selectedObjects( selected );
796 if( selected.IsEmpty() )
799 Handle(SALOME_InteractiveObject) anIObject = selected.First();
801 _PTR(Study) aStudy = appStudy->studyDS();
802 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
803 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
804 if( aMainObject->_is_nil() )
807 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
809 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
810 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
812 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
813 SALOMEDS::Color aColor = aGroupObject->GetColor();
814 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
816 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
817 if( aGroupObject->GetType() == SMESH::NODE )
818 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
819 else if( aGroupObject->GetType() == SMESH::EDGE )
820 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
821 else if( aGroupObject->GetType() == SMESH::ELEM0D )
822 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
826 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
827 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
833 SMESH::RepaintCurrentView();
836 QString functorToString( SMESH::Controls::FunctorPtr f )
838 QString type = QObject::tr( "UNKNOWN_CONTROL" );
839 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
840 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
841 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
842 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
843 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
844 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
845 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
846 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
847 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
848 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
849 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
850 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
851 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
852 type = QObject::tr( "WARP_ELEMENTS" );
853 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
854 type = QObject::tr( "TAPER_ELEMENTS" );
855 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
856 type = QObject::tr( "SKEW_ELEMENTS" );
857 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
858 type = QObject::tr( "AREA_ELEMENTS" );
859 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
860 type = QObject::tr( "LENGTH_EDGES" );
861 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
862 type = QObject::tr( "LENGTH2D_EDGES" );
863 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
864 type = QObject::tr( "MULTI_BORDERS" );
865 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
866 type = QObject::tr( "MULTI2D_BORDERS" );
867 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
868 type = QObject::tr( "FREE_NODES" );
869 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
870 type = QObject::tr( "FREE_EDGES" );
871 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
872 type = QObject::tr( "FREE_BORDERS" );
873 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
874 type = QObject::tr( "FREE_FACES" );
875 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
876 type = QObject::tr( "BARE_BORDER_VOLUME" );
877 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
878 type = QObject::tr( "BARE_BORDER_FACE" );
879 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
880 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
881 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
882 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
886 void SaveDistribution()
888 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
889 SALOME_ListIO selected;
891 aSel->selectedObjects( selected );
893 if ( selected.Extent() == 1 ) {
894 Handle(SALOME_InteractiveObject) anIO = selected.First();
895 if ( anIO->hasEntry() ) {
896 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
897 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
898 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
899 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
900 if ( aScalarBarActor && aFunctor ) {
901 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
903 std::vector<int> elements;
904 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
905 if ( mesh->_is_nil() ) {
906 SMESH::SMESH_IDSource_var idSource =
907 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
908 if ( !idSource->_is_nil() )
910 SMESH::long_array_var ids = idSource->GetIDs();
911 elements.resize( ids->length() );
912 for ( unsigned i = 0; i < elements.size(); ++i )
913 elements[i] = ids[i];
916 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
917 vtkLookupTable* lookupTable =
918 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
919 double * minmax = lookupTable->GetRange();
920 std::vector<int> nbEvents;
921 std::vector<double> funValues;
922 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
923 QString anInitialPath = "";
924 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
925 anInitialPath = QDir::currentPath();
926 QString aMeshName = anIO->getName();
928 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
929 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
930 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
931 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
932 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
935 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
937 if ( !aFilename.isEmpty() ) {
938 QFile f( aFilename );
939 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
940 QTextStream out( &f );
941 out << "# Mesh: " << aMeshName << endl;
942 out << "# Control: " << functorToString( aFunctor ) << endl;
944 out.setFieldWidth( 10 );
945 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
946 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
957 void ShowDistribution() {
958 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
959 SALOME_ListIO selected;
961 aSel->selectedObjects( selected );
963 if ( selected.Extent() == 1 ) {
964 Handle(SALOME_InteractiveObject) anIO = selected.First();
965 if ( anIO->hasEntry() ) {
966 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
967 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
968 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
969 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
975 #ifndef DISABLE_PLOT2DVIEWER
976 void PlotDistribution() {
977 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
981 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
982 SALOME_ListIO selected;
984 aSel->selectedObjects( selected );
986 if ( selected.Extent() == 1 ) {
987 Handle(SALOME_InteractiveObject) anIO = selected.First();
988 if ( anIO->hasEntry() ) {
989 //Find Actor by entry before getting Plot2d viewer,
990 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
991 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
993 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
998 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1002 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1006 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1007 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1008 QString functorName = functorToString( anActor->GetFunctor());
1009 QString aHistogramName("%1 : %2");
1010 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1011 aHistogram->setName(aHistogramName);
1012 aHistogram->setHorTitle(functorName);
1013 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1014 aPlot->displayObject(aHistogram, true);
1019 #endif //DISABLE_PLOT2DVIEWER
1021 void DisableAutoColor(){
1022 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1023 SALOME_ListIO selected;
1025 aSel->selectedObjects( selected );
1027 if(selected.Extent()){
1028 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1029 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1030 if ( !aMesh->_is_nil() ) {
1031 aMesh->SetAutoColor( false );
1036 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap){
1037 SALOME_ListIO selected;
1038 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1042 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1043 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1044 if( !aSel || !appStudy )
1047 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1048 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1049 aModule->EmitSignalDeactivateDialog();
1050 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1051 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1056 _PTR(Study) aStudy = appStudy->studyDS();
1058 aSel->selectedObjects( selected );
1060 if(selected.Extent() >= 1){
1061 switch(theCommandID){
1063 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1064 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1068 QColor c, e, b, n, c0D, o, outl, selection, preselection;
1072 vtkFloatingPointType Shrink = 0.0;
1073 vtkFloatingPointType faces_orientation_scale = 0.0;
1074 bool faces_orientation_3dvectors = false;
1076 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1077 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1078 int aMarkerTextureCurrent = 0;
1080 SALOME_ListIteratorOfListIO It( selected );
1081 for( ; It.More(); It.Next()){
1082 Handle(SALOME_InteractiveObject) IObject = It.Value();
1083 if(IObject->hasEntry()){
1084 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1085 vtkFloatingPointType color[3];
1086 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1087 int c0 = int (color[0] * 255);
1088 int c1 = int (color[1] * 255);
1089 int c2 = int (color[2] * 255);
1090 c.setRgb(c0, c1, c2);
1092 vtkFloatingPointType edgecolor[3];
1093 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1094 c0 = int (edgecolor[0] * 255);
1095 c1 = int (edgecolor[1] * 255);
1096 c2 = int (edgecolor[2] * 255);
1097 e.setRgb(c0, c1, c2);
1099 vtkFloatingPointType nodecolor[3];
1100 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1101 c0 = int (nodecolor[0] * 255);
1102 c1 = int (nodecolor[1] * 255);
1103 c2 = int (nodecolor[2] * 255);
1104 n.setRgb(c0, c1, c2);
1106 vtkFloatingPointType color0D[3];
1107 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1108 c0 = int (color0D[0] * 255);
1109 c1 = int (color0D[1] * 255);
1110 c2 = int (color0D[2] * 255);
1111 c0D.setRgb(c0, c1, c2);
1113 vtkFloatingPointType outlineColor[3];
1114 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1115 c0 = int (outlineColor[0] * 255);
1116 c1 = int (outlineColor[1] * 255);
1117 c2 = int (outlineColor[2] * 255);
1118 outl.setRgb(c0, c1, c2);
1120 vtkFloatingPointType hColor[3];
1121 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1122 c0 = int (hColor[0] * 255);
1123 c1 = int (hColor[1] * 255);
1124 c2 = int (hColor[2] * 255);
1125 selection.setRgb(c0, c1, c2);
1127 vtkFloatingPointType phColor[3];
1128 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1129 c0 = int (phColor[0] * 255);
1130 c1 = int (phColor[1] * 255);
1131 c2 = int (phColor[2] * 255);
1132 preselection.setRgb(c0, c1, c2);
1134 size0D = (int)anActor->Get0DSize();
1137 Edgewidth = (int)anActor->GetLineWidth();
1140 Shrink = anActor->GetShrinkFactor();
1142 vtkFloatingPointType faces_orientation_color[3];
1143 anActor->GetFacesOrientationColor(faces_orientation_color);
1144 c0 = int (faces_orientation_color[0] * 255);
1145 c1 = int (faces_orientation_color[1] * 255);
1146 c2 = int (faces_orientation_color[2] * 255);
1147 o.setRgb(c0, c1, c2);
1149 faces_orientation_scale = anActor->GetFacesOrientationScale();
1150 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1152 aMarkerTypeCurrent = anActor->GetMarkerType();
1153 aMarkerScaleCurrent = anActor->GetMarkerScale();
1154 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1156 // even if there are multiple objects in the selection,
1157 // we need only the first one to get values for the dialog
1163 SMESHGUI_Preferences_ColorDlg *aDlg =
1164 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1165 aDlg->SetColor(1, c);
1166 aDlg->SetColor(2, e);
1167 aDlg->SetColor(3, n);
1168 aDlg->SetColor(4, outl);
1169 aDlg->SetDeltaBrightness(delta);
1170 aDlg->SetColor(5, c0D);
1171 aDlg->SetColor(6, o);
1172 aDlg->SetIntValue(1, Edgewidth);
1173 aDlg->SetIntValue(2, int(Shrink*100.));
1174 aDlg->SetIntValue(3, size0D);
1175 aDlg->SetDoubleValue(1, faces_orientation_scale);
1176 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1177 aDlg->SetColor(7, selection);
1178 aDlg->SetColor(8, preselection);
1180 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1182 if( aMarkerTypeCurrent != VTK::MT_USER )
1183 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1185 aDlg->setCustomMarker( aMarkerTextureCurrent );
1188 QColor color = aDlg->GetColor(1);
1189 QColor edgecolor = aDlg->GetColor(2);
1190 QColor nodecolor = aDlg->GetColor(3);
1191 QColor outlinecolor = aDlg->GetColor(4);
1192 QColor color0D = aDlg->GetColor(5);
1193 QColor faces_orientation_color = aDlg->GetColor(6);
1194 QColor selectioncolor = aDlg->GetColor(7);
1195 QColor preSelectioncolor = aDlg->GetColor(8);
1196 int delta = aDlg->GetDeltaBrightness();
1199 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1201 SALOME_ListIteratorOfListIO It( selected );
1202 for( ; It.More(); It.Next()){
1203 Handle(SALOME_InteractiveObject) IObject = It.Value();
1204 if(IObject->hasEntry()){
1205 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1206 /* actor color and backface color */
1207 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1208 vtkFloatingPointType (color.green()) / 255.,
1209 vtkFloatingPointType (color.blue()) / 255.,
1212 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1213 vtkFloatingPointType (edgecolor.green()) / 255.,
1214 vtkFloatingPointType (edgecolor.blue()) / 255.);
1216 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1217 vtkFloatingPointType (outlinecolor.green()) / 255.,
1218 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1221 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1222 vtkFloatingPointType (selectioncolor.green()) / 255.,
1223 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1225 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1226 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1227 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1230 /* Shrink factor and size edges */
1231 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1232 anActor->SetLineWidth(aDlg->GetIntValue(1));
1234 /* Nodes color and size */
1235 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1236 vtkFloatingPointType (nodecolor.green()) / 255.,
1237 vtkFloatingPointType (nodecolor.blue()) / 255.);
1240 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1241 vtkFloatingPointType (color0D.green()) / 255.,
1242 vtkFloatingPointType (color0D.blue()) / 255.);
1243 anActor->Set0DSize(aDlg->GetIntValue(3));
1245 /* Faces orientation */
1246 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1247 vtkFloatingPointType(faces_orientation_color.greenF()),
1248 vtkFloatingPointType(faces_orientation_color.blueF())};
1249 anActor->SetFacesOrientationColor(c);
1250 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1251 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1253 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1254 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1255 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1256 if( aMarkerTypeNew != VTK::MT_USER )
1257 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1259 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1260 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1261 if( anIter != aMarkerMap.end() )
1262 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1265 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1266 if( !aGroupObject->_is_nil() )
1268 SMESH::ElementType anElementType = aGroupObject->GetType();
1270 switch( anElementType )
1272 case SMESH::NODE: aColor = nodecolor; break;
1273 case SMESH::EDGE: aColor = edgecolor; break;
1274 default: aColor = color; break;
1277 SALOMEDS::Color aGroupColor;
1278 aGroupColor.R = (float)aColor.red() / 255.0;
1279 aGroupColor.G = (float)aColor.green() / 255.0;
1280 aGroupColor.B = (float)aColor.blue() / 255.0;
1281 aGroupObject->SetColor( aGroupColor );
1286 SMESH::RepaintCurrentView();
1292 SALOME_ListIteratorOfListIO It( selected );
1293 for( ; It.More(); It.Next()){
1294 Handle(SALOME_InteractiveObject) IObject = It.Value();
1295 if(IObject->hasEntry()){
1296 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1297 switch(theCommandID){
1299 anActor->SetRepresentation(SMESH_Actor::eEdge);
1302 anActor->SetRepresentation(SMESH_Actor::eSurface);
1305 if(anActor->IsShrunk())
1306 anActor->UnShrink();
1308 anActor->SetShrink();
1311 anActor->SetRepresentation(SMESH_Actor::ePoint);
1314 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1315 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1318 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1319 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1325 SMESH::RepaintCurrentView();
1329 void Control( int theCommandID )
1331 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1332 SALOME_ListIO selected;
1334 aSel->selectedObjects( selected );
1336 if( !selected.IsEmpty() ){
1337 Handle(SALOME_InteractiveObject) anIO = selected.First();
1339 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1340 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
1341 switch ( theCommandID ){
1343 aControl = SMESH_Actor::eLength;
1346 aControl = SMESH_Actor::eLength2D;
1349 aControl = SMESH_Actor::eFreeEdges;
1352 aControl = SMESH_Actor::eFreeBorders;
1355 aControl = SMESH_Actor::eMultiConnection;
1358 aControl = SMESH_Actor::eFreeNodes;
1361 aControl = SMESH_Actor::eMultiConnection2D;
1364 aControl = SMESH_Actor::eArea;
1367 aControl = SMESH_Actor::eTaper;
1370 aControl = SMESH_Actor::eAspectRatio;
1373 aControl = SMESH_Actor::eAspectRatio3D;
1376 aControl = SMESH_Actor::eMinimumAngle;
1379 aControl = SMESH_Actor::eWarping;
1382 aControl = SMESH_Actor::eSkew;
1385 aControl = SMESH_Actor::eVolume3D;
1388 aControl = SMESH_Actor::eFreeFaces;
1391 aControl = SMESH_Actor::eMaxElementLength2D;
1394 aControl = SMESH_Actor::eMaxElementLength3D;
1397 aControl = SMESH_Actor::eBareBorderVolume;
1400 aControl = SMESH_Actor::eBareBorderFace;
1403 aControl = SMESH_Actor::eOverConstrainedVolume;
1406 aControl = SMESH_Actor::eOverConstrainedFace;
1409 anActor->SetControlMode(aControl);
1410 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1411 SMESH::RepaintCurrentView();
1412 #ifndef DISABLE_PLOT2DVIEWER
1413 if(anActor->GetPlot2Histogram()) {
1414 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1415 QString functorName = functorToString( anActor->GetFunctor());
1416 QString aHistogramName("%1 : %2");
1417 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1418 aHistogram->setName(aHistogramName);
1419 aHistogram->setHorTitle(functorName);
1420 SMESH::ProcessIn2DViewers(anActor);
1429 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1430 MeshObjectType theType,
1431 const QString theInTypeName,
1432 QString & theOutTypeName)
1434 SMESH_TypeFilter aTypeFilter( theType );
1436 if( !theIO.IsNull() )
1438 entry = theIO->getEntry();
1439 LightApp_DataOwner owner( entry );
1440 if ( aTypeFilter.isOk( &owner )) {
1441 theOutTypeName = theInTypeName;
1449 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1451 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1452 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1454 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1455 CORBA::String_var anID = aSComp->GetID().c_str();
1456 if (!strcmp(anID.in(),theIO->getEntry()))
1462 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1463 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1464 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1465 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1466 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1474 QString CheckHomogeneousSelection()
1476 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1477 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1478 SALOME_ListIO selected;
1480 aSel->selectedObjects( selected );
1482 QString RefType = CheckTypeObject(selected.First());
1483 SALOME_ListIteratorOfListIO It(selected);
1484 for ( ; It.More(); It.Next())
1486 Handle(SALOME_InteractiveObject) IObject = It.Value();
1487 QString Type = CheckTypeObject(IObject);
1488 if (Type.compare(RefType) != 0)
1489 return "Heterogeneous Selection";
1496 void SMESHGUI::OnEditDelete()
1498 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1499 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1500 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1502 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1503 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1504 _PTR(GenericAttribute) anAttr;
1505 _PTR(AttributeIOR) anIOR;
1507 int objectCount = 0;
1509 QString aParentComponent = QString::null;
1510 Handle(SALOME_InteractiveObject) anIO;
1511 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1513 anIO = anIt.Value();
1514 QString cur = anIO->getComponentDataType();
1515 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1517 // check if object is reference
1518 _PTR(SObject) aRefSObj;
1519 aNameList.append("\n - ");
1520 if ( aSO->ReferencedObject( aRefSObj ) ) {
1521 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1522 aNameList.append( aRefName );
1523 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1526 aNameList.append(anIO->getName());
1530 if( aParentComponent.isNull() )
1531 aParentComponent = cur;
1532 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1533 aParentComponent = "";
1536 if ( objectCount == 0 )
1537 return; // No Valid Objects Selected
1539 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1540 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1541 QObject::tr("ERR_ERROR"),
1542 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1545 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1546 if (SUIT_MessageBox::warning
1547 (SMESHGUI::desktop(),
1548 QObject::tr("SMESH_WRN_WARNING"),
1549 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1550 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1551 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1554 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1556 SALOME_ListIteratorOfListIO It(selected);
1558 aStudyBuilder->NewCommand(); // There is a transaction
1559 for( ; It.More(); It.Next()){ // loop on selected IO's
1560 Handle(SALOME_InteractiveObject) IObject = It.Value();
1561 if(IObject->hasEntry()) {
1562 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1564 // disable removal of "SMESH" component object
1565 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1567 if ( engineIOR() == anIOR->Value().c_str() )
1570 //Check the referenced object
1571 _PTR(SObject) aRefSObject;
1572 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1573 aSO = aRefSObject; // Delete main Object instead of reference
1575 // put the whole hierarchy of sub-objects of the selected SO into a list and
1576 // then treat them all starting from the deepest objects (at list back)
1578 std::list< _PTR(SObject) > listSO;
1579 listSO.push_back( aSO );
1580 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1581 for ( ; itSO != listSO.end(); ++itSO ) {
1582 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1583 for (it->InitEx(false); it->More(); it->Next())
1584 listSO.push_back( it->Value() );
1587 // treat SO's in the list starting from the back
1589 std::list< _PTR(SObject) >::reverse_iterator ritSO = listSO.rbegin();
1590 for ( ; ritSO != listSO.rend(); ++ritSO ) {
1591 _PTR(SObject) SO = *ritSO;
1592 if ( !SO ) continue;
1593 std::string anEntry = SO->GetID();
1595 /** Erase graphical object **/
1596 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1597 ViewManagerList aViewMenegers = anApp->viewManagers();
1598 ViewManagerList::const_iterator it = aViewMenegers.begin();
1599 for( ; it != aViewMenegers.end(); it++) {
1600 SUIT_ViewManager* vm = *it;
1601 int nbSf = vm ? vm->getViewsCount() : 0;
1603 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1604 for(int i = 0; i < nbSf; i++){
1605 SUIT_ViewWindow *sf = aViews[i];
1606 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1607 SMESH::RemoveActor(sf,anActor);
1613 /** Remove an object from data structures **/
1614 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1615 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1616 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1617 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1618 aMesh->RemoveGroup( aGroup );
1620 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1621 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1622 aMesh->RemoveSubMesh( aSubMesh );
1624 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1626 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1629 IObject = new SALOME_InteractiveObject
1630 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1631 QString objType = CheckTypeObject(IObject);
1632 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1633 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1634 aStudyBuilder->RemoveObjectWithChildren( SO );
1636 else {// default action: remove SObject from the study
1637 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1638 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1640 aStudyBuilder->RemoveObjectWithChildren( SO );
1644 } /* listSO back loop */
1645 } /* IObject->hasEntry() */
1648 aStudyBuilder->CommitCommand();
1650 /* Clear any previous selection */
1652 aSel->setSelectedObjects( l1 );
1654 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1659 SMESHGUI_EXPORT CAM_Module* createModule()
1661 return new SMESHGUI();
1664 SMESHGUI_EXPORT char* getModuleVersion() {
1665 return (char*)SMESH_VERSION_STR;
1669 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1671 //=============================================================================
1675 //=============================================================================
1676 SMESHGUI::SMESHGUI() :
1677 SalomeApp_Module( "SMESH" ),
1678 LightApp_Module( "SMESH" )
1680 if ( CORBA::is_nil( myComponentSMESH ) )
1682 CORBA::Boolean anIsEmbeddedMode;
1683 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1684 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1686 // 0019923: EDF 765 SMESH : default values of hypothesis
1687 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1688 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1689 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1690 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1691 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1694 myActiveDialogBox = 0;
1695 myFilterLibraryDlg = 0;
1699 myEventCallbackCommand = vtkCallbackCommand::New();
1700 myEventCallbackCommand->Delete();
1701 myEventCallbackCommand->SetClientData( this );
1702 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1705 SMESH::GetFilterManager();
1706 SMESH::GetPattern();
1707 SMESH::GetMeasurements();
1709 /* load resources for all available meshers */
1710 SMESH::InitAvailableHypotheses();
1713 //=============================================================================
1717 //=============================================================================
1718 SMESHGUI::~SMESHGUI()
1720 #ifdef WITHGENERICOBJ
1721 SMESH::GetFilterManager()->UnRegister();
1722 SMESH::GetMeasurements()->UnRegister();
1724 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1725 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1728 //=============================================================================
1732 //=============================================================================
1733 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1735 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1737 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1742 //=============================================================================
1746 //=============================================================================
1747 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1749 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1753 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1754 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1755 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1756 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1757 return autoUpdate && !exceeded;
1760 //=============================================================================
1764 //=============================================================================
1765 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1767 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1770 //=============================================================================
1774 //=============================================================================
1775 SMESHGUI* SMESHGUI::GetSMESHGUI()
1777 SMESHGUI* smeshMod = 0;
1778 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1781 CAM_Module* module = app->module( "Mesh" );
1782 smeshMod = dynamic_cast<SMESHGUI*>( module );
1785 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1787 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1790 _PTR(Study) aStudy = study->studyDS();
1792 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1801 Standard_EXPORT SMESHGUI* GetComponentGUI()
1803 return SMESHGUI::GetSMESHGUI();
1807 //=============================================================================
1811 //=============================================================================
1812 void SMESHGUI::SetState(int aState)
1817 //=============================================================================
1821 //=============================================================================
1822 void SMESHGUI::ResetState()
1827 //=============================================================================
1831 //=============================================================================
1832 void SMESHGUI::EmitSignalDeactivateDialog()
1834 emit SignalDeactivateActiveDialog();
1837 //=============================================================================
1841 //=============================================================================
1842 void SMESHGUI::EmitSignalStudyFrameChanged()
1844 emit SignalStudyFrameChanged();
1847 //=============================================================================
1851 //=============================================================================
1852 void SMESHGUI::EmitSignalCloseAllDialogs()
1854 emit SignalCloseAllDialogs();
1857 //=============================================================================
1861 //=============================================================================
1862 void SMESHGUI::EmitSignalVisibilityChanged()
1864 emit SignalVisibilityChanged();
1867 //=============================================================================
1871 //=============================================================================
1872 QDialog *SMESHGUI::GetActiveDialogBox()
1874 return myActiveDialogBox;
1877 //=============================================================================
1881 //=============================================================================
1882 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
1884 myActiveDialogBox = (QDialog *) aDlg;
1888 //=============================================================================
1892 //=============================================================================
1893 SUIT_Desktop* SMESHGUI::desktop()
1895 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1897 return app->desktop();
1902 //=============================================================================
1906 //=============================================================================
1907 SalomeApp_Study* SMESHGUI::activeStudy()
1909 SUIT_Application* app = SUIT_Session::session()->activeApplication();
1911 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1916 //=============================================================================
1920 //=============================================================================
1921 void SMESHGUI::Modified( bool theIsUpdateActions )
1923 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
1924 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
1925 appStudy->Modified();
1926 if( theIsUpdateActions )
1927 app->updateActions();
1932 //=============================================================================
1936 //=============================================================================
1937 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
1939 /* Here the position is on the bottom right corner - 10 */
1940 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
1942 SUIT_Desktop *PP = desktop();
1943 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
1944 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
1948 //=============================================================================
1952 //=============================================================================
1953 static int isStudyLocked(_PTR(Study) theStudy){
1954 return theStudy->GetProperties()->IsLocked();
1957 static bool checkLock(_PTR(Study) theStudy) {
1958 if (isStudyLocked(theStudy)) {
1959 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1960 QObject::tr("WRN_WARNING"),
1961 QObject::tr("WRN_STUDY_LOCKED") );
1967 //=======================================================================
1968 //function : CheckActiveStudyLocked
1970 //=======================================================================
1972 bool SMESHGUI::isActiveStudyLocked()
1974 _PTR(Study) aStudy = activeStudy()->studyDS();
1975 return checkLock( aStudy );
1978 //=============================================================================
1982 //=============================================================================
1983 bool SMESHGUI::OnGUIEvent( int theCommandID )
1985 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
1989 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
1990 SUIT_ResourceMgr* mgr = resourceMgr();
1994 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
1995 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
1998 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
1999 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2001 //QAction* act = action( theCommandID );
2003 switch (theCommandID) {
2005 if(checkLock(aStudy)) break;
2016 if(checkLock(aStudy)) break;
2017 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2021 case 150: //MED FILE INFORMATION
2023 SALOME_ListIO selected;
2024 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2026 aSel->selectedObjects( selected );
2027 if( selected.Extent() )
2029 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2030 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2031 if ( !aMesh->_is_nil() )
2033 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2040 case 122: // EXPORT MED
2053 ::ExportMeshToFile(theCommandID);
2057 case 200: // SCALAR BAR
2059 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2060 SALOME_ListIO selected;
2062 aSel->selectedObjects( selected );
2064 if( selected.Extent() ) {
2065 Handle(SALOME_InteractiveObject) anIO = selected.First();
2066 if( anIO->hasEntry() ) {
2067 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2068 anActor->SetControlMode( SMESH_Actor::eNone );
2069 #ifndef DISABLE_PLOT2DVIEWER
2070 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2079 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2084 // dump control distribution data to the text file
2085 ::SaveDistribution();
2091 // show/ distribution
2092 ::ShowDistribution();
2096 #ifndef DISABLE_PLOT2DVIEWER
2099 // plot distribution
2100 ::PlotDistribution();
2111 ::DisableAutoColor();
2114 case 1134: // Clipping
2115 case 1133: // Tranparency
2116 case 1132: // Colors / Size
2123 ::SetDisplayMode(theCommandID, myMarkerMap);
2126 //2D quadratic representation
2129 ::SetDisplayMode(theCommandID, myMarkerMap);
2133 case 216: // 0D elements
2136 case 219: // Volumes
2137 case 220: // All Entity
2138 ::SetDisplayEntity(theCommandID);
2141 case 221: // Orientation of faces
2143 LightApp_SelectionMgr* mgr = selectionMgr();
2144 SALOME_ListIO selected; mgr->selectedObjects( selected );
2146 SALOME_ListIteratorOfListIO it(selected);
2147 for( ; it.More(); it.Next()) {
2148 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2149 if(anIObject->hasEntry()) {
2150 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2151 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2160 if(checkLock(aStudy)) break;
2162 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2165 SMESH::UpdateView();
2167 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2168 SMESH::OnVisuException();
2170 catch (...) { // PAL16774 (Crash after display of many groups)
2171 SMESH::OnVisuException();
2175 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2176 aSel->selectedObjects( l );
2177 aSel->setSelectedObjects( l );
2182 case 301: // DISPLAY
2183 case 302: // DISPLAY ONLY
2185 SMESH::EDisplaing anAction;
2186 switch (theCommandID) {
2187 case 300: anAction = SMESH::eErase; break;
2188 case 301: anAction = SMESH::eDisplay; break;
2189 case 302: anAction = SMESH::eDisplayOnly; break;
2192 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2193 SALOME_ListIO sel_objects, to_process;
2195 aSel->selectedObjects( sel_objects );
2197 if( theCommandID==302 )
2199 MESSAGE("anAction = SMESH::eDisplayOnly");
2200 startOperation( myEraseAll );
2203 extractContainers( sel_objects, to_process );
2206 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2210 SALOME_ListIteratorOfListIO It( to_process );
2211 for ( ; It.More(); It.Next()) {
2213 Handle(SALOME_InteractiveObject) IOS = It.Value();
2214 if (IOS->hasEntry()) {
2216 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2217 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2218 break; // PAL16774 (Crash after display of many groups)
2220 if (anAction == SMESH::eDisplayOnly)
2222 MESSAGE("anAction = SMESH::eDisplayOnly");
2223 anAction = SMESH::eDisplay;
2229 // PAL13338 + PAL15161 -->
2230 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2231 MESSAGE("anAction = SMESH::eDisplayOnly");
2232 SMESH::UpdateView();
2233 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2235 // PAL13338 + PAL15161 <--
2237 catch (...) { // PAL16774 (Crash after display of many groups)
2238 SMESH::OnVisuException();
2241 if (anAction == SMESH::eErase) {
2242 MESSAGE("anAction == SMESH::eErase");
2244 aSel->setSelectedObjects( l1 );
2247 aSel->setSelectedObjects( to_process );
2254 if(checkLock(aStudy)) break;
2257 EmitSignalDeactivateDialog();
2259 ( new SMESHGUI_NodesDlg( this ) )->show();
2262 SUIT_MessageBox::warning(desktop(),
2263 tr("SMESH_WRN_WARNING"),
2264 tr("SMESH_WRN_VIEWER_VTK"));
2269 case 2151: // FILTER
2273 EmitSignalDeactivateDialog();
2274 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2279 case 701: // COMPUTE MESH
2280 case 711: // PRECOMPUTE MESH
2281 case 712: // EVALUATE MESH
2282 case 713: // MESH ORDER
2284 if (checkLock(aStudy)) break;
2285 startOperation( theCommandID );
2289 case 702: // Create mesh
2290 case 703: // Create sub-mesh
2291 case 704: // Edit mesh/sub-mesh
2292 startOperation( theCommandID );
2294 case 705: // copy mesh
2296 if (checkLock(aStudy)) break;
2297 EmitSignalDeactivateDialog();
2298 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2301 case 710: // Build compound mesh
2303 if (checkLock(aStudy)) break;
2304 EmitSignalDeactivateDialog();
2305 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2309 case 407: // DIAGONAL INVERSION
2310 case 408: // Delete diagonal
2314 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2315 tr( "NOT_A_VTK_VIEWER" ) );
2319 if ( checkLock( aStudy ) )
2322 /*Standard_Boolean aRes;
2323 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2324 if ( aMesh->_is_nil() )
2326 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2327 tr( "SMESH_BAD_SELECTION" ) );
2331 EmitSignalDeactivateDialog();
2332 if ( theCommandID == 407 )
2333 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2335 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2338 case 409: // Change orientation
2339 case 410: // Union of triangles
2340 case 411: // Cutting of quadrangles
2341 case 419: // Splitting volumes into tetrahedra
2345 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2346 tr( "NOT_A_VTK_VIEWER" ) );
2350 if ( checkLock( aStudy ) )
2353 EmitSignalDeactivateDialog();
2354 SMESHGUI_MultiEditDlg* aDlg = NULL;
2355 if ( theCommandID == 409 )
2356 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2357 else if ( theCommandID == 410 )
2358 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2359 else if ( theCommandID == 419 )
2360 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2362 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2367 case 412: // Smoothing
2369 if(checkLock(aStudy)) break;
2371 EmitSignalDeactivateDialog();
2372 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2375 SUIT_MessageBox::warning(desktop(),
2376 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2380 case 413: // Extrusion
2382 if (checkLock(aStudy)) break;
2384 EmitSignalDeactivateDialog();
2385 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2387 SUIT_MessageBox::warning(desktop(),
2388 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2392 case 414: // Revolution
2394 if(checkLock(aStudy)) break;
2396 EmitSignalDeactivateDialog();
2397 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2400 SUIT_MessageBox::warning(desktop(),
2401 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2405 case 415: // Pattern mapping
2407 if ( checkLock( aStudy ) )
2411 EmitSignalDeactivateDialog();
2412 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2415 SUIT_MessageBox::warning(desktop(),
2416 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2420 case 416: // Extrusion along a path
2422 if (checkLock(aStudy)) break;
2424 EmitSignalDeactivateDialog();
2425 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2427 SUIT_MessageBox::warning(desktop(),
2428 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2432 case 417: // Convert mesh to quadratic
2434 startOperation( 417 );
2435 /* if (checkLock(aStudy)) break;
2437 EmitSignalDeactivateDialog();
2438 new SMESHGUI_ConvToQuadDlg();
2440 SUIT_MessageBox::warning(desktop(),
2441 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2445 case 418: // create 2D mesh from 3D
2447 startOperation( 418 );
2450 case 806: // CREATE GEO GROUP
2452 startOperation( 806 );
2455 case 801: // CREATE GROUP
2459 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2460 tr( "NOT_A_VTK_VIEWER" ) );
2464 if(checkLock(aStudy)) break;
2465 EmitSignalDeactivateDialog();
2466 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2468 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2469 SALOME_ListIO selected;
2471 aSel->selectedObjects( selected );
2473 int nbSel = selected.Extent();
2475 // check if mesh is selected
2476 aMesh = SMESH::GetMeshByIO( selected.First() );
2478 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2483 case 802: // CONSTRUCT GROUP
2487 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2488 tr( "NOT_A_VTK_VIEWER" ) );
2492 if(checkLock(aStudy)) break;
2493 EmitSignalDeactivateDialog();
2495 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2496 SALOME_ListIO selected;
2498 aSel->selectedObjects( selected );
2500 int nbSel = selected.Extent();
2502 // check if submesh is selected
2503 Handle(SALOME_InteractiveObject) IObject = selected.First();
2504 if (IObject->hasEntry()) {
2505 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2507 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2508 if (!aSubMesh->_is_nil()) {
2510 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2511 // get submesh elements list by types
2512 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2513 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2514 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2515 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2516 // create group for each type o elements
2517 QString aName = IObject->getName();
2518 QStringList anEntryList;
2519 if (aNodes->length() > 0) {
2520 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2521 aGroup->Add(aNodes.inout());
2522 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2523 anEntryList.append( aSObject->GetID().c_str() );
2525 if (aEdges->length() > 0) {
2526 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2527 aGroup->Add(aEdges.inout());
2528 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2529 anEntryList.append( aSObject->GetID().c_str() );
2531 if (aFaces->length() > 0) {
2532 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2533 aGroup->Add(aFaces.inout());
2534 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2535 anEntryList.append( aSObject->GetID().c_str() );
2537 if (aVolumes->length() > 0) {
2538 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2539 aGroup->Add(aVolumes.inout());
2540 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2541 anEntryList.append( aSObject->GetID().c_str() );
2544 anApp->browseObjects( anEntryList );
2546 catch(const SALOME::SALOME_Exception & S_ex){
2547 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2554 SUIT_MessageBox::warning(desktop(),
2555 tr("SMESH_WRN_WARNING"),
2556 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2561 case 803: // EDIT GROUP
2565 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2566 tr( "NOT_A_VTK_VIEWER" ) );
2570 if(checkLock(aStudy)) break;
2571 EmitSignalDeactivateDialog();
2573 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2574 SALOME_ListIO selected;
2576 aSel->selectedObjects( selected );
2578 SALOME_ListIteratorOfListIO It (selected);
2579 int nbSelectedGroups = 0;
2580 for ( ; It.More(); It.Next() )
2582 SMESH::SMESH_GroupBase_var aGroup =
2583 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2584 if (!aGroup->_is_nil()) {
2586 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2590 if (nbSelectedGroups == 0)
2592 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2598 case 804: // Add elements to group
2600 if(checkLock(aStudy)) break;
2601 if (myState == 800) {
2602 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2603 if (aDlg) aDlg->onAdd();
2608 case 805: // Remove elements from group
2610 if(checkLock(aStudy)) break;
2611 if (myState == 800) {
2612 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2613 if (aDlg) aDlg->onRemove();
2618 case 815: // Edit GEOM GROUP as standalone
2622 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2623 tr( "NOT_A_VTK_VIEWER" ) );
2627 if(checkLock(aStudy)) break;
2628 EmitSignalDeactivateDialog();
2630 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2631 SALOME_ListIO selected;
2633 aSel->selectedObjects( selected );
2635 SALOME_ListIteratorOfListIO It (selected);
2636 for ( ; It.More(); It.Next() )
2638 SMESH::SMESH_GroupOnGeom_var aGroup =
2639 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2640 if (!aGroup->_is_nil()) {
2641 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2646 SMESH::SMESH_GroupOnFilter_var aGroup =
2647 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2648 if (!aGroup->_is_nil()) {
2649 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2657 case 810: // Union Groups
2658 case 811: // Intersect groups
2659 case 812: // Cut groups
2663 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2664 tr( "NOT_A_VTK_VIEWER" ) );
2668 if ( checkLock( aStudy ) )
2671 EmitSignalDeactivateDialog();
2673 SMESHGUI_GroupOpDlg* aDlg = 0;
2674 if ( theCommandID == 810 )
2675 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2676 else if ( theCommandID == 811 )
2677 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2679 aDlg = new SMESHGUI_CutGroupsDlg( this );
2686 case 814: // Create groups of entities from existing groups of superior dimensions
2688 if ( checkLock( aStudy ) )
2691 EmitSignalDeactivateDialog();
2692 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2698 case 813: // Delete groups with their contents
2702 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2703 tr( "NOT_A_VTK_VIEWER" ) );
2707 if ( checkLock( aStudy ) )
2710 EmitSignalDeactivateDialog();
2712 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2716 case 900: // MESH INFOS
2717 case 903: // WHAT IS
2719 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2720 EmitSignalDeactivateDialog();
2721 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2722 SALOME_ListIO selected;
2724 aSel->selectedObjects( selected );
2726 if ( selected.Extent() > 1 ) { // a dlg for each IO
2727 SALOME_ListIteratorOfListIO It( selected );
2728 for ( ; It.More(); It.Next() ) {
2729 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2730 dlg->showInfo( It.Value() );
2735 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2741 case 904: // FIND ELEM
2743 startOperation( theCommandID );
2747 case 1100: // EDIT HYPOTHESIS
2749 if(checkLock(aStudy)) break;
2751 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2752 SALOME_ListIO selected;
2754 aSel->selectedObjects( selected );
2756 int nbSel = selected.Extent();
2759 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2760 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2762 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2763 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2764 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2765 if ( !aHypothesis->_is_nil() )
2768 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2769 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2771 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2781 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2783 if(checkLock(aStudy)) break;
2784 SUIT_OverrideCursor wc;
2786 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2787 SALOME_ListIO selected;
2789 aSel->selectedObjects( selected, QString::null, false );
2791 SALOME_ListIteratorOfListIO It(selected);
2792 for (int i = 0; It.More(); It.Next(), i++) {
2793 Handle(SALOME_InteractiveObject) IObject = It.Value();
2794 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2797 aSel->setSelectedObjects( l1 );
2802 case 4009: // ELEM0D
2803 case 4010: // GEOM::EDGE
2804 case 4021: // TRIANGLE
2806 case 4023: // POLYGON
2810 if(checkLock(aStudy)) break;
2812 EmitSignalDeactivateDialog();
2813 SMDSAbs_ElementType type = SMDSAbs_Edge;
2815 switch (theCommandID) {
2816 case 4009: // ELEM0D
2817 type = SMDSAbs_0DElement; nbNodes = 1; break;
2818 case 4021: // TRIANGLE
2819 type = SMDSAbs_Face; nbNodes = 3; break;
2821 type = SMDSAbs_Face; nbNodes = 4; break;
2823 type = SMDSAbs_Volume; nbNodes = 4; break;
2824 case 4023: // POLYGON
2825 type = SMDSAbs_Face; nbNodes = 5; break; // 5 - identificator for POLYGON
2827 type = SMDSAbs_Volume; nbNodes = 8; break;
2828 case 4033: // POLYHEDRE
2829 type = SMDSAbs_Volume; nbNodes = 9; break; // 9 - identificator for POLYHEDRE
2832 ( new SMESHGUI_AddMeshElementDlg( this, type, nbNodes ) )->show();
2835 SUIT_MessageBox::warning(desktop(),
2836 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2840 case 4033: // POLYHEDRON
2842 if(checkLock(aStudy)) break;
2844 EmitSignalDeactivateDialog();
2845 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2848 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2849 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2853 case 4034: // QUADRATIC EDGE
2854 case 4035: // QUADRATIC TRIANGLE
2855 case 4036: // QUADRATIC QUADRANGLE
2856 case 4037: // QUADRATIC TETRAHEDRON
2857 case 4038: // QUADRATIC PYRAMID
2858 case 4039: // QUADRATIC PENTAHEDRON
2859 case 4040: // QUADRATIC HEXAHEDRON
2861 if(checkLock(aStudy)) break;
2863 EmitSignalDeactivateDialog();
2866 switch (theCommandID) {
2868 type = QUAD_EDGE; break;
2870 type = QUAD_TRIANGLE; break;
2872 type = QUAD_QUADRANGLE; break;
2874 type = QUAD_TETRAHEDRON; break;
2876 type = QUAD_PYRAMID; break;
2878 type = QUAD_PENTAHEDRON; break;
2880 type = QUAD_HEXAHEDRON;
2884 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
2887 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2888 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2892 case 4041: // REMOVES NODES
2894 if(checkLock(aStudy)) break;
2896 EmitSignalDeactivateDialog();
2897 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
2900 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2901 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2905 case 4042: // REMOVES ELEMENTS
2907 if(checkLock(aStudy)) break;
2909 EmitSignalDeactivateDialog();
2910 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
2914 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2915 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2919 case 4043: { // CLEAR_MESH
2921 if(checkLock(aStudy)) break;
2923 SALOME_ListIO selected;
2924 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2925 aSel->selectedObjects( selected );
2927 SUIT_OverrideCursor wc;
2928 SALOME_ListIteratorOfListIO It (selected);
2929 for ( ; It.More(); It.Next() )
2931 Handle(SALOME_InteractiveObject) IOS = It.Value();
2932 SMESH::SMESH_Mesh_var aMesh =
2933 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
2934 if ( aMesh->_is_nil()) continue;
2936 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
2938 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
2939 SMESH::ModifiedMesh( aMeshSObj, false, true);
2940 // hide groups and submeshes
2941 _PTR(ChildIterator) anIter =
2942 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
2943 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
2945 _PTR(SObject) so = anIter->Value();
2946 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
2949 catch (const SALOME::SALOME_Exception& S_ex){
2951 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2955 SMESH::UpdateView();
2959 case 4044: // REMOVE ORPHAN NODES
2961 if(checkLock(aStudy)) break;
2962 SALOME_ListIO selected;
2963 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
2964 aSel->selectedObjects( selected );
2965 if ( selected.Extent() == 1 ) {
2966 Handle(SALOME_InteractiveObject) anIO = selected.First();
2967 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
2968 if ( !aMesh->_is_nil() ) {
2969 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
2970 tr( "SMESH_WARNING" ),
2971 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
2972 SUIT_MessageBox::Yes |
2973 SUIT_MessageBox::No,
2974 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
2977 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
2978 int removed = aMeshEditor->RemoveOrphanNodes();
2979 SUIT_MessageBox::information(SMESHGUI::desktop(),
2980 tr("SMESH_INFORMATION"),
2981 tr("NB_NODES_REMOVED").arg(removed));
2982 if ( removed > 0 ) {
2983 SMESH::UpdateView();
2984 SMESHGUI::Modified();
2987 catch (const SALOME::SALOME_Exception& S_ex) {
2988 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2997 case 4051: // RENUMBERING NODES
2999 if(checkLock(aStudy)) break;
3001 EmitSignalDeactivateDialog();
3002 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3006 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3007 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3011 case 4052: // RENUMBERING ELEMENTS
3013 if(checkLock(aStudy)) break;
3015 EmitSignalDeactivateDialog();
3016 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3020 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3021 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3025 case 4061: // TRANSLATION
3027 if(checkLock(aStudy)) break;
3029 EmitSignalDeactivateDialog();
3030 ( new SMESHGUI_TranslationDlg( this ) )->show();
3033 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3034 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3038 case 4062: // ROTATION
3040 if(checkLock(aStudy)) break;
3042 EmitSignalDeactivateDialog();
3043 ( new SMESHGUI_RotationDlg( this ) )->show();
3046 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3047 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3051 case 4063: // SYMMETRY
3053 if(checkLock(aStudy)) break;
3055 EmitSignalDeactivateDialog();
3056 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3059 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3060 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3064 case 4064: // SEWING
3066 if(checkLock(aStudy)) break;
3068 EmitSignalDeactivateDialog();
3069 ( new SMESHGUI_SewingDlg( this ) )->show();
3072 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3073 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3077 case 4065: // MERGE NODES
3079 if(checkLock(aStudy)) break;
3081 EmitSignalDeactivateDialog();
3082 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3085 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3086 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3090 case 4066: // MERGE EQUAL ELEMENTS
3092 if (checkLock(aStudy)) break;
3094 EmitSignalDeactivateDialog();
3095 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3097 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3098 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3103 case 4067: // MAKE MESH PASS THROUGH POINT
3104 startOperation( 4067 );
3109 if(checkLock(aStudy)) break;
3111 EmitSignalDeactivateDialog();
3112 ( new SMESHGUI_ScaleDlg( this ) )->show();
3115 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3116 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3121 case 4069: // DUPLICATE NODES
3123 if(checkLock(aStudy)) break;
3125 EmitSignalDeactivateDialog();
3126 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3129 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3130 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3135 case 5105: // Library of selection filters
3137 static QList<int> aTypes;
3138 if ( aTypes.isEmpty() )
3140 aTypes.append( SMESH::NODE );
3141 aTypes.append( SMESH::EDGE );
3142 aTypes.append( SMESH::FACE );
3143 aTypes.append( SMESH::VOLUME );
3145 if (!myFilterLibraryDlg)
3146 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3147 else if (myFilterLibraryDlg->isHidden())
3148 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3149 myFilterLibraryDlg->raise();
3153 case 6017: // CONTROLS
3177 LightApp_SelectionMgr* mgr = selectionMgr();
3178 SALOME_ListIO selected; mgr->selectedObjects( selected );
3180 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3181 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3183 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3184 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3185 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3186 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3187 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3188 ::Control( theCommandID );
3193 SUIT_MessageBox::warning(desktop(),
3194 tr( "SMESH_WRN_WARNING" ),
3195 tr( "SMESH_BAD_SELECTION" ) );
3199 SUIT_MessageBox::warning(desktop(),
3200 tr( "SMESH_WRN_WARNING" ),
3201 tr( "NOT_A_VTK_VIEWER" ) );
3206 LightApp_SelectionMgr* mgr = selectionMgr();
3207 SALOME_ListIO selected; mgr->selectedObjects( selected );
3209 SALOME_ListIteratorOfListIO it(selected);
3210 for( ; it.More(); it.Next()) {
3211 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3212 if(anIObject->hasEntry()) {
3213 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3214 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3222 LightApp_SelectionMgr* mgr = selectionMgr();
3223 SALOME_ListIO selected; mgr->selectedObjects( selected );
3225 SALOME_ListIteratorOfListIO it(selected);
3226 for( ; it.More(); it.Next()) {
3227 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3228 if(anIObject->hasEntry())
3229 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3230 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3238 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3239 EmitSignalDeactivateDialog();
3240 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3246 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3247 //updateObjBrowser();
3251 //=============================================================================
3255 //=============================================================================
3256 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3261 //=============================================================================
3265 //=============================================================================
3266 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3271 //=============================================================================
3275 //=============================================================================
3276 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3281 //=============================================================================
3282 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3283 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3285 //=============================================================================
3286 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3287 SUIT_ViewWindow* wnd )
3289 if(theIO->hasEntry()){
3290 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3291 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3295 //=======================================================================
3296 // function : createSMESHAction
3298 //=======================================================================
3299 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3300 const int key, const bool toggle, const QString& shortcutAction )
3303 QWidget* parent = application()->desktop();
3304 SUIT_ResourceMgr* resMgr = resourceMgr();
3306 if ( !icon_id.isEmpty() )
3307 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3309 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3310 if ( !pix.isNull() )
3311 icon = QIcon( pix );
3313 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3314 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3315 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3317 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3318 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3321 //=======================================================================
3322 // function : createPopupItem
3324 //=======================================================================
3325 void SMESHGUI::createPopupItem( const int id,
3326 const QString& clients,
3327 const QString& types,
3328 const QString& theRule,
3333 parentId = popupMgr()->actionId( action( pId ) );
3335 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3336 popupMgr()->insert( action( id ), parentId, 0 );
3338 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3339 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3340 QString rule = "(%1) and (%2) and (%3)";
3341 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3342 if( clients.isEmpty() )
3343 rule = rule.arg( QString( "true" ) );
3345 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3346 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3349 bool cont = myRules.contains( id );
3351 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3353 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3354 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3357 //=======================================================================
3358 // function : initialize
3360 //=======================================================================
3361 void SMESHGUI::initialize( CAM_Application* app )
3363 SalomeApp_Module::initialize( app );
3365 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3367 /* Automatic Update flag */
3368 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3370 // ----- create actions --------------
3372 createSMESHAction( 111, "DAT", "", (Qt::CTRL+Qt::Key_B) );
3373 createSMESHAction( 112, "UNV", "", (Qt::CTRL+Qt::Key_U) );
3374 createSMESHAction( 113, "MED", "", (Qt::CTRL+Qt::Key_M) );
3375 createSMESHAction( 114, "NUM" );
3376 createSMESHAction( 115, "STL" );
3377 createSMESHAction( 116, "CGNS" );
3378 createSMESHAction( 117, "SAUV" );
3379 createSMESHAction( 121, "DAT" );
3380 createSMESHAction( 122, "MED" );
3381 createSMESHAction( 123, "UNV" );
3382 createSMESHAction( 140, "STL" );
3383 createSMESHAction( 142, "CGNS" );
3384 createSMESHAction( 144, "SAUV" );
3385 createSMESHAction( 124, "EXPORT_DAT" );
3386 createSMESHAction( 125, "EXPORT_MED" );
3387 createSMESHAction( 126, "EXPORT_UNV" );
3388 createSMESHAction( 141, "EXPORT_STL" );
3389 createSMESHAction( 143, "EXPORT_CGNS" );
3390 createSMESHAction( 145, "EXPORT_SAUV" );
3391 createSMESHAction( 150, "FILE_INFO" );
3392 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3393 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3394 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3395 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3396 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3397 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3398 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3399 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3400 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3401 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3402 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3403 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3404 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3405 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3406 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3407 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3408 createSMESHAction( 804, "ADD" );
3409 createSMESHAction( 805, "REMOVE" );
3410 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3411 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3412 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3413 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3414 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3415 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3416 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3417 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3418 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3419 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3420 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3421 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3422 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3423 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3424 createSMESHAction( 6024, "BARE_BORDER_VOLUME","ICON_BARE_BORDER_VOLUME", 0, true );
3425 createSMESHAction( 6025, "BARE_BORDER_FACE","ICON_BARE_BORDER_FACE", 0, true );
3426 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3427 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE","ICON_OVER_CONSTRAINED_FACE", 0, true );
3428 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3429 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3430 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3431 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3432 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3433 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3434 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3435 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3436 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3437 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3438 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3439 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3440 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3441 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3442 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3443 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3444 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3445 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3446 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3447 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3448 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3449 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3450 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3451 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3452 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3453 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3454 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3455 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3456 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3457 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3458 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3459 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3460 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3461 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3462 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3463 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3464 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3465 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3466 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3467 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3468 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3469 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3470 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3471 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3472 createSMESHAction( 415, "MAP", "ICON_MAP" );
3473 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3474 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3475 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3476 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3477 createSMESHAction( 200, "RESET" );
3478 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3479 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3480 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3481 #ifndef DISABLE_PLOT2DVIEWER
3482 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3484 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3485 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3486 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3487 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3488 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3489 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3490 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3491 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3492 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3493 createSMESHAction( 220, "ALL" );
3494 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3496 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3497 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3499 createSMESHAction( 1100, "EDIT_HYPO" );
3500 createSMESHAction( 1102, "UNASSIGN" );
3501 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3502 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3503 createSMESHAction( 1131, "DISPMODE" );
3504 createSMESHAction( 1132, "COLORS" );
3505 createSMESHAction( 1133, "TRANSP" );
3506 createSMESHAction( 1134, "CLIP" );
3507 createSMESHAction( 1135, "DISP_ENT" );
3508 createSMESHAction( 1136, "AUTO_COLOR" );
3509 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3510 createSMESHAction( 2000, "CTRL" );
3512 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3513 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3515 createSMESHAction( 300, "ERASE" );
3516 createSMESHAction( 301, "DISPLAY" );
3517 createSMESHAction( 302, "DISPLAY_ONLY" );
3518 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3519 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3520 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3521 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3522 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3523 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3524 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3525 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3527 // ----- create menu --------------
3528 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3529 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3530 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3531 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3532 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3533 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3534 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3535 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3537 createMenu( separator(), fileId );
3539 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3540 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3541 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3542 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3543 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3544 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3545 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3546 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3547 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3548 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3550 createMenu( 111, importId, -1 );
3551 createMenu( 112, importId, -1 );
3552 createMenu( 113, importId, -1 );
3553 createMenu( 115, importId, -1 );
3555 createMenu( 116, importId, -1 );
3557 createMenu( 117, importId, -1 );
3558 createMenu( 121, exportId, -1 );
3559 createMenu( 122, exportId, -1 );
3560 createMenu( 123, exportId, -1 );
3561 createMenu( 140, exportId, -1 ); // export to STL
3563 createMenu( 142, exportId, -1 ); // export to CGNS
3565 createMenu( 144, exportId, -1 ); // export to SAUV
3566 createMenu( separator(), fileId, 10 );
3568 createMenu( 33, editId, -1 );
3570 createMenu( 5105, toolsId, -1 );
3572 createMenu( 702, meshId, -1 ); // "Mesh" menu
3573 createMenu( 703, meshId, -1 );
3574 createMenu( 704, meshId, -1 );
3575 createMenu( 710, meshId, -1 );
3576 createMenu( 705, meshId, -1 );
3577 createMenu( separator(), meshId, -1 );
3578 createMenu( 701, meshId, -1 );
3579 createMenu( 711, meshId, -1 );
3580 createMenu( 712, meshId, -1 );
3581 createMenu( 713, meshId, -1 );
3582 createMenu( separator(), meshId, -1 );
3583 createMenu( 801, meshId, -1 );
3584 createMenu( 806, meshId, -1 );
3585 createMenu( 802, meshId, -1 );
3586 createMenu( 803, meshId, -1 );
3587 createMenu( 815, meshId, -1 );
3588 createMenu( separator(), meshId, -1 );
3589 createMenu( 810, meshId, -1 );
3590 createMenu( 811, meshId, -1 );
3591 createMenu( 812, meshId, -1 );
3592 createMenu( separator(), meshId, -1 );
3593 createMenu( 814, meshId, -1 );
3594 createMenu( separator(), meshId, -1 );
3595 createMenu( 900, meshId, -1 );
3596 //createMenu( 902, meshId, -1 );
3597 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3598 createMenu( 904, meshId, -1 );
3599 createMenu( separator(), meshId, -1 );
3601 createMenu( 6005, nodeId, -1 );
3602 createMenu( 6002, edgeId, -1 );
3603 createMenu( 6003, edgeId, -1 );
3604 createMenu( 6001, edgeId, -1 );
3605 createMenu( 6004, edgeId, -1 );
3606 createMenu( 6021, faceId, -1 );
3607 createMenu( 6025, faceId, -1 );
3608 createMenu( 6027, faceId, -1 );
3609 createMenu( 6018, faceId, -1 );
3610 createMenu( 6019, faceId, -1 );
3611 createMenu( 6011, faceId, -1 );
3612 createMenu( 6012, faceId, -1 );
3613 createMenu( 6013, faceId, -1 );
3614 createMenu( 6014, faceId, -1 );
3615 createMenu( 6015, faceId, -1 );
3616 createMenu( 6016, faceId, -1 );
3617 createMenu( 6022, faceId, -1 );
3618 createMenu( 6017, volumeId, -1 );
3619 createMenu( 6009, volumeId, -1 );
3620 createMenu( 6023, volumeId, -1 );
3621 createMenu( 6024, volumeId, -1 );
3622 createMenu( 6026, volumeId, -1 );
3624 createMenu( 4000, addId, -1 );
3625 createMenu( 4009, addId, -1 );
3626 createMenu( 4010, addId, -1 );
3627 createMenu( 4021, addId, -1 );
3628 createMenu( 4022, addId, -1 );
3629 createMenu( 4023, addId, -1 );
3630 createMenu( 4031, addId, -1 );
3631 createMenu( 4032, addId, -1 );
3632 createMenu( 4033, addId, -1 );
3633 createMenu( separator(), addId, -1 );
3634 createMenu( 4034, addId, -1 );
3635 createMenu( 4035, addId, -1 );
3636 createMenu( 4036, addId, -1 );
3637 createMenu( 4037, addId, -1 );
3638 createMenu( 4038, addId, -1 );
3639 createMenu( 4039, addId, -1 );
3640 createMenu( 4040, addId, -1 );
3642 createMenu( 4041, removeId, -1 );
3643 createMenu( 4042, removeId, -1 );
3644 createMenu( 4044, removeId, -1 );
3645 createMenu( separator(), removeId, -1 );
3646 createMenu( 813, removeId, -1 );
3647 createMenu( separator(), removeId, -1 );
3648 createMenu( 4043, removeId, -1 );
3650 createMenu( 4051, renumId, -1 );
3651 createMenu( 4052, renumId, -1 );
3653 createMenu( 4061, transfId, -1 );
3654 createMenu( 4062, transfId, -1 );
3655 createMenu( 4063, transfId, -1 );
3656 createMenu( 4068, transfId, -1 );
3657 createMenu( 4064, transfId, -1 );
3658 createMenu( 4065, transfId, -1 );
3659 createMenu( 4066, transfId, -1 );
3660 createMenu( 4069, transfId, -1 );
3662 createMenu( 4067,modifyId, -1 );
3663 createMenu( 407, modifyId, -1 );
3664 createMenu( 408, modifyId, -1 );
3665 createMenu( 409, modifyId, -1 );
3666 createMenu( 410, modifyId, -1 );
3667 createMenu( 411, modifyId, -1 );
3668 createMenu( 419, modifyId, -1 );
3669 createMenu( 412, modifyId, -1 );
3670 createMenu( 413, modifyId, -1 );
3671 createMenu( 416, modifyId, -1 );
3672 createMenu( 414, modifyId, -1 );
3673 createMenu( 415, modifyId, -1 );
3674 createMenu( 417, modifyId, -1 );
3675 createMenu( 418, modifyId, -1 );
3677 createMenu( 501, measureId, -1 );
3678 createMenu( 502, measureId, -1 );
3679 createMenu( 214, viewId, -1 );
3681 // ----- create toolbars --------------
3682 int meshTb = createTool( tr( "TB_MESH" ) ),
3683 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3684 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3685 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3686 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3688 createTool( 702, meshTb );
3689 createTool( 703, meshTb );
3690 createTool( 704, meshTb );
3691 createTool( 710, meshTb );
3692 createTool( 705, meshTb );
3693 createTool( separator(), meshTb );
3694 createTool( 701, meshTb );
3695 createTool( 711, meshTb );
3696 createTool( 712, meshTb );
3697 createTool( 713, meshTb );
3698 createTool( separator(), meshTb );
3699 createTool( 801, meshTb );
3700 createTool( 806, meshTb );
3701 createTool( 802, meshTb );
3702 createTool( 803, meshTb );
3703 //createTool( 815, meshTb );
3704 createTool( separator(), meshTb );
3705 createTool( 900, meshTb );
3706 //createTool( 902, meshTb );
3707 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3708 createTool( 904, meshTb );
3709 createTool( separator(), meshTb );
3711 createTool( 6005, ctrlTb );
3712 createTool( separator(), ctrlTb );
3713 createTool( 6002, ctrlTb );
3714 createTool( 6003, ctrlTb );
3715 createTool( 6001, ctrlTb );
3716 createTool( 6004, ctrlTb );
3717 createTool( separator(), ctrlTb );
3718 createTool( 6021, ctrlTb );
3719 createTool( 6025, ctrlTb );
3720 createTool( 6027, ctrlTb );
3721 createTool( 6018, ctrlTb );
3722 createTool( 6019, ctrlTb );
3723 createTool( 6011, ctrlTb );
3724 createTool( 6012, ctrlTb );
3725 createTool( 6013, ctrlTb );
3726 createTool( 6014, ctrlTb );
3727 createTool( 6015, ctrlTb );
3728 createTool( 6016, ctrlTb );
3729 createTool( 6022, ctrlTb );
3730 createTool( separator(), ctrlTb );
3731 createTool( 6017, ctrlTb );
3732 createTool( 6009, ctrlTb );
3733 createTool( 6023, ctrlTb );
3734 createTool( 6024, ctrlTb );
3735 createTool( 6026, ctrlTb );
3736 createTool( separator(), ctrlTb );
3738 createTool( 4000, addRemTb );
3739 createTool( 4009, addRemTb );
3740 createTool( 4010, addRemTb );
3741 createTool( 4021, addRemTb );
3742 createTool( 4022, addRemTb );
3743 createTool( 4023, addRemTb );
3744 createTool( 4031, addRemTb );
3745 createTool( 4032, addRemTb );
3746 createTool( 4033, addRemTb );
3747 createTool( separator(), addRemTb );
3748 createTool( 4034, addRemTb );
3749 createTool( 4035, addRemTb );
3750 createTool( 4036, addRemTb );
3751 createTool( 4037, addRemTb );
3752 createTool( 4038, addRemTb );
3753 createTool( 4039, addRemTb );
3754 createTool( 4040, addRemTb );
3755 createTool( separator(), addRemTb );
3756 createTool( 4041, addRemTb );
3757 createTool( 4042, addRemTb );
3758 createTool( 4044, addRemTb );
3759 createTool( 4043, addRemTb );
3760 createTool( separator(), addRemTb );
3761 createTool( 4051, addRemTb );
3762 createTool( 4052, addRemTb );
3763 createTool( separator(), addRemTb );
3764 createTool( 4061, addRemTb );
3765 createTool( 4062, addRemTb );
3766 createTool( 4063, addRemTb );
3767 createTool( 4068, addRemTb );
3768 createTool( 4064, addRemTb );
3769 createTool( 4065, addRemTb );
3770 createTool( 4066, addRemTb );
3771 createTool( 4069, addRemTb );
3772 createTool( separator(), addRemTb );
3774 createTool( 4067,modifyTb );
3775 createTool( 407, modifyTb );
3776 createTool( 408, modifyTb );
3777 createTool( 409, modifyTb );
3778 createTool( 410, modifyTb );
3779 createTool( 411, modifyTb );
3780 createTool( 419, modifyTb );
3781 createTool( 412, modifyTb );
3782 createTool( 413, modifyTb );
3783 createTool( 416, modifyTb );
3784 createTool( 414, modifyTb );
3785 createTool( 415, modifyTb );
3786 createTool( 417, modifyTb );
3787 createTool( 418, modifyTb );
3789 createTool( 214, dispModeTb );
3791 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3792 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3795 QString OB = "'ObjectBrowser'",
3796 View = "'" + SVTK_Viewer::Type() + "'",
3798 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3799 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3800 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3801 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3802 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3803 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3804 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3805 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3806 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3807 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3808 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3810 mesh_part = mesh + " " + subMesh + " " + group,
3811 mesh_group = mesh + " " + group,
3812 hyp_alg = hypo + " " + algo;
3814 // popup for object browser
3816 isInvisible("not( isVisible )"),
3817 isEmpty("numberOfNodes = 0"),
3818 isNotEmpty("numberOfNodes <> 0"),
3820 // has nodes, edges, etc in VISIBLE! actor
3821 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3822 hasElems("(count( elemTypes ) > 0)"),
3823 hasDifferentElems("(count( elemTypes ) > 1)"),
3824 hasElems0d("({'Elem0d'} in elemTypes)"),
3825 hasEdges("({'Edge'} in elemTypes)"),
3826 hasFaces("({'Face'} in elemTypes)"),
3827 hasVolumes("({'Volume'} in elemTypes)");
3829 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
3830 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
3831 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
3832 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
3833 createPopupItem( 803, OB, group ); // EDIT_GROUP
3834 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
3836 popupMgr()->insert( separator(), -1, 0 );
3837 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
3838 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
3839 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
3840 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
3841 createPopupItem( 214, OB, mesh_part ); // UPDATE
3842 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
3843 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
3844 popupMgr()->insert( separator(), -1, 0 );
3845 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
3846 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
3847 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
3848 popupMgr()->insert( separator(), -1, 0 );
3849 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
3850 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
3851 popupMgr()->insert( separator(), -1, 0 );
3852 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
3853 popupMgr()->insert( separator(), -1, 0 );
3854 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
3855 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
3857 popupMgr()->insert( separator(), -1, 0 );
3859 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
3860 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
3861 QString only_one_2D = only_one_non_empty + " && dim>1";
3863 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
3864 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
3865 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
3867 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
3869 createPopupItem( 145, OB, mesh_group, multiple_non_empty ); // EXPORT_SAUV
3870 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
3871 popupMgr()->insert( separator(), -1, 0 );
3874 createPopupItem( 803, View, group ); // EDIT_GROUP
3875 createPopupItem( 804, View, elems ); // ADD
3876 createPopupItem( 805, View, elems ); // REMOVE
3878 popupMgr()->insert( separator(), -1, 0 );
3879 createPopupItem( 214, View, mesh_part ); // UPDATE
3880 createPopupItem( 900, View, mesh_part ); // ADV_INFO
3881 createPopupItem( 904, View, mesh ); // FIND_ELEM
3882 popupMgr()->insert( separator(), -1, 0 );
3884 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
3885 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
3886 popupMgr()->insert( separator(), -1, 0 );
3889 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
3890 QString aType = QString( "%1type in {%2}" ).arg( lc );
3891 aType = aType.arg( mesh_part );
3892 QString aMeshInVTK = aClient + "&&" + aType;
3894 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
3895 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
3896 QString aSelCount = QString( "%1 > 0" ).arg( dc );
3898 //-------------------------------------------------
3900 //-------------------------------------------------
3901 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
3903 popupMgr()->insert( action( 9010 ), anId, -1 );
3904 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
3905 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
3907 popupMgr()->insert( action( 9011 ), anId, -1 );
3908 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
3909 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
3911 popupMgr()->insert( separator(), -1, -1 );
3913 //-------------------------------------------------
3915 //-------------------------------------------------
3916 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
3918 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
3919 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
3920 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
3922 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
3923 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
3924 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
3926 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
3927 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
3928 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
3930 popupMgr()->insert( separator(), anId, -1 );
3932 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
3933 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
3934 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
3936 //-------------------------------------------------
3938 //-------------------------------------------------
3939 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
3941 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
3943 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
3944 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
3945 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
3947 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
3948 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
3949 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
3951 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
3952 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
3953 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
3955 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
3956 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
3957 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
3959 popupMgr()->insert( separator(), anId, -1 );
3961 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
3962 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
3965 //-------------------------------------------------
3966 // Representation of the 2D Quadratic elements
3967 //-------------------------------------------------
3968 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
3969 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
3970 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
3971 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
3973 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
3974 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
3975 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
3977 //-------------------------------------------------
3978 // Orientation of faces
3979 //-------------------------------------------------
3980 popupMgr()->insert( action( 221 ), -1, -1 );
3981 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
3982 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
3984 //-------------------------------------------------
3986 //-------------------------------------------------
3987 popupMgr()->insert( action( 1132 ), -1, -1 );
3988 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3990 //-------------------------------------------------
3992 //-------------------------------------------------
3993 popupMgr()->insert( action( 1133 ), -1, -1 );
3994 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
3996 //-------------------------------------------------
3998 //-------------------------------------------------
4000 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4001 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4002 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4003 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4005 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4007 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4008 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4010 popupMgr()->insert( separator(), anId, -1 );
4012 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4014 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4015 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4016 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4018 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4020 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4021 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4022 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4024 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4025 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4026 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4028 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4029 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4030 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4032 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4033 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4034 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4036 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4038 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4039 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4040 QtxPopupMgr::VisibleRule );
4041 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4043 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4044 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4045 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4047 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4048 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4049 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4051 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4052 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4053 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4055 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4056 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4057 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4059 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4060 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4061 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4063 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4064 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4065 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4067 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4068 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4069 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4071 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4072 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4073 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4075 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4076 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4077 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4079 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4080 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4081 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4083 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4084 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4085 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4087 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4089 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4090 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4091 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4093 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4094 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4095 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4097 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4098 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4099 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4101 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4102 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4103 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4105 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4106 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4107 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4109 popupMgr()->insert( separator(), anId, -1 );
4111 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4112 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4114 popupMgr()->insert( separator(), anId, -1 );
4116 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4118 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4119 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4121 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4122 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4123 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4125 #ifndef DISABLE_PLOT2DVIEWER
4126 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4127 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4130 //-------------------------------------------------
4132 //-------------------------------------------------
4133 popupMgr()->insert( separator(), -1, -1 );
4134 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4135 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4136 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4137 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4139 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4140 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4142 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4143 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4145 popupMgr()->insert( separator(), -1, -1 );
4147 //-------------------------------------------------
4149 //-------------------------------------------------
4150 popupMgr()->insert( action( 1134 ), -1, -1 );
4151 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4153 popupMgr()->insert( separator(), -1, -1 );
4155 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4156 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4158 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4159 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4162 //================================================================================
4164 * \brief Return true if SMESH or GEOM objects are selected.
4165 * Is called form LightApp_Module::activateModule() which clear selection if
4166 * not isSelectionCompatible()
4168 //================================================================================
4170 bool SMESHGUI::isSelectionCompatible()
4172 bool isCompatible = true;
4173 SALOME_ListIO selected;
4174 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4175 Sel->selectedObjects( selected );
4177 SALOME_ListIteratorOfListIO It( selected );
4178 for ( ; isCompatible && It.More(); It.Next())
4180 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4181 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4183 return isCompatible;
4187 bool SMESHGUI::reusableOperation( const int id )
4189 // compute, evaluate and precompute are not reusable operations
4190 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4193 bool SMESHGUI::activateModule( SUIT_Study* study )
4195 bool res = SalomeApp_Module::activateModule( study );
4197 setMenuShown( true );
4198 setToolShown( true );
4200 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4201 PyGILState_STATE gstate = PyGILState_Ensure();
4202 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4203 if(pluginsmanager==NULL)
4207 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4212 PyGILState_Release(gstate);
4213 // end of GEOM plugins loading
4215 // Reset actions accelerator keys
4216 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4217 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4218 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4220 action( 33)->setEnabled(true); // Delete: Key_Delete
4222 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4223 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4224 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4225 if ( _PTR(Study) aStudy = s->studyDS()) {
4226 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4227 updateObjBrowser(); // objects can be removed
4230 // get all view currently opened in the study and connect their signals to
4231 // the corresponding slots of the class.
4232 SUIT_Desktop* aDesk = study->application()->desktop();
4234 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4235 SUIT_ViewWindow* wnd;
4236 foreach ( wnd, wndList )
4243 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4245 setMenuShown( false );
4246 setToolShown( false );
4248 EmitSignalCloseAllDialogs();
4250 // Unset actions accelerator keys
4251 action(111)->setShortcut(QKeySequence()); // Import DAT
4252 action(112)->setShortcut(QKeySequence()); // Import UNV
4253 action(113)->setShortcut(QKeySequence()); // Import MED
4255 action( 33)->setEnabled(false); // Delete: Key_Delete
4257 return SalomeApp_Module::deactivateModule( study );
4260 void SMESHGUI::studyClosed( SUIT_Study* s )
4262 SMESH::RemoveVisuData( s->id() );
4263 SalomeApp_Module::studyClosed( s );
4266 void SMESHGUI::OnGUIEvent()
4268 const QObject* obj = sender();
4269 if ( !obj || !obj->inherits( "QAction" ) )
4271 int id = actionId((QAction*)obj);
4276 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4278 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4279 if ( CORBA::is_nil( myComponentSMESH ) )
4281 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4283 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4284 return aGUI.myComponentSMESH;
4287 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4288 return myComponentSMESH;
4291 QString SMESHGUI::engineIOR() const
4293 CORBA::ORB_var anORB = getApp()->orb();
4294 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4295 return QString( anIOR.in() );
4298 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4300 SalomeApp_Module::contextMenuPopup( client, menu, title );
4302 selectionMgr()->selectedObjects( lst );
4303 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4304 Handle(SALOME_InteractiveObject) io = lst.First();
4305 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4306 _PTR(Study) study = appStudy->studyDS();
4307 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4309 QString aName = QString( obj->GetName().c_str() );
4310 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4311 aName.remove( (aName.length() - 1), 1 );
4317 LightApp_Selection* SMESHGUI::createSelection() const
4319 return new SMESHGUI_Selection();
4322 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4324 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4325 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4328 void SMESHGUI::viewManagers( QStringList& list ) const
4330 list.append( SVTK_Viewer::Type() );
4333 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4335 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4336 SMESH::UpdateSelectionProp( this );
4338 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4339 for(int i = 0; i < aViews.count() ; i++){
4340 SUIT_ViewWindow *sf = aViews[i];
4346 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4348 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4349 myClippingPlaneInfoMap.erase( theViewManager );
4352 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4354 theActor->AddObserver( SMESH::DeleteActorEvent,
4355 myEventCallbackCommand.GetPointer(),
4359 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4360 unsigned long theEvent,
4361 void* theClientData,
4364 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4365 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4366 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4367 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4368 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4369 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4370 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4371 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4372 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4373 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4374 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4375 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4376 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4377 if( anActor == *anIter3 ) {
4378 anActorList.erase( anIter3 );
4389 void SMESHGUI::createPreferences()
4391 // General tab ------------------------------------------------------------------------
4392 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4394 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4395 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4396 setPreferenceProperty( lim, "min", 0 );
4397 setPreferenceProperty( lim, "max", 100000000 );
4398 setPreferenceProperty( lim, "step", 1000 );
4399 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4401 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4402 setPreferenceProperty( qaGroup, "columns", 2 );
4403 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4404 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4405 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4406 setPreferenceProperty( prec, "min", 0 );
4407 setPreferenceProperty( prec, "max", 16 );
4409 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4410 setPreferenceProperty( dispgroup, "columns", 2 );
4411 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4413 modes.append( tr("MEN_WIRE") );
4414 modes.append( tr("MEN_SHADE") );
4415 modes.append( tr("MEN_NODES") );
4416 modes.append( tr("MEN_SHRINK") );
4417 QList<QVariant> indices;
4418 indices.append( 0 );
4419 indices.append( 1 );
4420 indices.append( 2 );
4421 indices.append( 3 );
4422 setPreferenceProperty( dispmode, "strings", modes );
4423 setPreferenceProperty( dispmode, "indexes", indices );
4425 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4426 setPreferenceProperty( arcgroup, "columns", 2 );
4427 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4428 QStringList quadraticModes;
4429 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4430 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4432 indices.append( 0 );
4433 indices.append( 1 );
4434 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4435 setPreferenceProperty( quadraticmode, "indexes", indices );
4437 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4438 "SMESH", "max_angle" );
4439 setPreferenceProperty( maxAngle, "min", 1 );
4440 setPreferenceProperty( maxAngle, "max", 90 );
4444 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4445 setPreferenceProperty( exportgroup, "columns", 2 );
4446 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4447 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4449 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4450 setPreferenceProperty( computeGroup, "columns", 2 );
4451 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4453 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4454 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4455 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4457 indices.append( 0 );
4458 indices.append( 1 );
4459 indices.append( 2 );
4460 setPreferenceProperty( notifyMode, "strings", modes );
4461 setPreferenceProperty( notifyMode, "indexes", indices );
4463 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4464 setPreferenceProperty( infoGroup, "columns", 4 );
4465 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4467 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4468 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4470 indices.append( 0 );
4471 indices.append( 1 );
4472 setPreferenceProperty( elemInfo, "strings", modes );
4473 setPreferenceProperty( elemInfo, "indexes", indices );
4474 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4475 setPreferenceProperty( nodesLim, "min", 0 );
4476 setPreferenceProperty( nodesLim, "max", 10000000 );
4477 setPreferenceProperty( nodesLim, "step", 10000 );
4478 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4480 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4481 setPreferenceProperty( segGroup, "columns", 2 );
4482 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4483 "SMESH", "segmentation" );
4484 setPreferenceProperty( segLen, "min", 1 );
4485 setPreferenceProperty( segLen, "max", 10000000 );
4486 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4487 "SMESH", "nb_segments_per_edge" );
4488 setPreferenceProperty( nbSeg, "min", 1 );
4489 setPreferenceProperty( nbSeg, "max", 10000000 );
4491 // Quantities with individual precision settings
4492 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4493 setPreferenceProperty( precGroup, "columns", 2 );
4495 const int nbQuantities = 6;
4496 int precs[nbQuantities], ii = 0;
4497 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4498 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4499 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4500 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4501 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4502 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4503 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4504 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4505 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4506 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4507 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4508 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4510 // Set property for precision value for spinboxes
4511 for ( ii = 0; ii < nbQuantities; ii++ ){
4512 setPreferenceProperty( precs[ii], "min", -14 );
4513 setPreferenceProperty( precs[ii], "max", 14 );
4514 setPreferenceProperty( precs[ii], "precision", 2 );
4517 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4518 setPreferenceProperty( previewGroup, "columns", 2 );
4519 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4520 setPreferenceProperty( chunkSize, "min", 0 );
4521 setPreferenceProperty( chunkSize, "max", 1000 );
4522 setPreferenceProperty( chunkSize, "step", 50 );
4524 // Mesh tab ------------------------------------------------------------------------
4525 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4526 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4527 setPreferenceProperty( nodeGroup, "columns", 3 );
4529 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4531 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4533 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4534 QList<QVariant> aMarkerTypeIndicesList;
4535 QList<QVariant> aMarkerTypeIconsList;
4536 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4537 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4538 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4539 aMarkerTypeIndicesList << i;
4540 aMarkerTypeIconsList << pixmap;
4542 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4543 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4545 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4547 QList<QVariant> aMarkerScaleIndicesList;
4548 QStringList aMarkerScaleValuesList;
4549 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4550 aMarkerScaleIndicesList << i;
4551 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4553 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4554 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4556 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4557 setPreferenceProperty( elemGroup, "columns", 2 );
4559 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4560 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4562 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4563 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4565 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4567 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4568 setPreferenceProperty( grpGroup, "columns", 2 );
4570 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4572 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4573 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4574 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4575 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4576 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4577 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4579 setPreferenceProperty( size0d, "min", 1 );
4580 setPreferenceProperty( size0d, "max", 10 );
4582 setPreferenceProperty( elemW, "min", 1 );
4583 setPreferenceProperty( elemW, "max", 5 );
4585 setPreferenceProperty( shrink, "min", 0 );
4586 setPreferenceProperty( shrink, "max", 100 );
4588 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4589 setPreferenceProperty( orientGroup, "columns", 1 );
4591 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4592 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4594 setPreferenceProperty( orientScale, "min", 0.05 );
4595 setPreferenceProperty( orientScale, "max", 0.5 );
4596 setPreferenceProperty( orientScale, "step", 0.05 );
4598 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4600 // Selection tab ------------------------------------------------------------------------
4601 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4603 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4604 setPreferenceProperty( selGroup, "columns", 2 );
4606 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4607 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4608 int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, LightApp_Preferences::IntSpin, "SMESH", "selection_width" );
4610 setPreferenceProperty( selW, "min", 1 );
4611 setPreferenceProperty( selW, "max", 5 );
4613 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4614 setPreferenceProperty( preGroup, "columns", 2 );
4616 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4617 int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, LightApp_Preferences::IntSpin, "SMESH", "highlight_width" );
4619 setPreferenceProperty( preW, "min", 1 );
4620 setPreferenceProperty( preW, "max", 5 );
4622 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4623 setPreferenceProperty( precSelGroup, "columns", 2 );
4625 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4626 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4627 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4629 // Scalar Bar tab ------------------------------------------------------------------------
4630 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4631 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4632 setPreferenceProperty( fontGr, "columns", 2 );
4634 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4635 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4637 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4638 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4640 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4641 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4643 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4644 setPreferenceProperty( numcol, "min", 2 );
4645 setPreferenceProperty( numcol, "max", 256 );
4647 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4648 setPreferenceProperty( numlab, "min", 2 );
4649 setPreferenceProperty( numlab, "max", 65 );
4651 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4652 setPreferenceProperty( orientGr, "columns", 2 );
4653 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4654 QStringList orients;
4655 orients.append( tr( "SMESH_VERTICAL" ) );
4656 orients.append( tr( "SMESH_HORIZONTAL" ) );
4657 indices.clear(); indices.append( 0 ); indices.append( 1 );
4658 setPreferenceProperty( orient, "strings", orients );
4659 setPreferenceProperty( orient, "indexes", indices );
4661 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4662 setPreferenceProperty( posVSizeGr, "columns", 2 );
4663 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4664 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4665 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4666 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4667 setPreferenceProperty( xv, "step", 0.1 );
4668 setPreferenceProperty( xv, "min", 0.0 );
4669 setPreferenceProperty( xv, "max", 1.0 );
4670 setPreferenceProperty( yv, "step", 0.1 );
4671 setPreferenceProperty( yv, "min", 0.0 );
4672 setPreferenceProperty( yv, "max", 1.0 );
4673 setPreferenceProperty( wv, "step", 0.1 );
4674 setPreferenceProperty( wv, "min", 0.0 );
4675 setPreferenceProperty( wv, "max", 1.0 );
4676 setPreferenceProperty( hv, "min", 0.0 );
4677 setPreferenceProperty( hv, "max", 1.0 );
4678 setPreferenceProperty( hv, "step", 0.1 );
4680 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4681 setPreferenceProperty( posHSizeGr, "columns", 2 );
4682 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4683 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4684 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4685 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4686 setPreferenceProperty( xv, "min", 0.0 );
4687 setPreferenceProperty( xv, "max", 1.0 );
4688 setPreferenceProperty( xv, "step", 0.1 );
4689 setPreferenceProperty( xh, "min", 0.0 );
4690 setPreferenceProperty( xh, "max", 1.0 );
4691 setPreferenceProperty( xh, "step", 0.1 );
4692 setPreferenceProperty( yh, "min", 0.0 );
4693 setPreferenceProperty( yh, "max", 1.0 );
4694 setPreferenceProperty( yh, "step", 0.1 );
4695 setPreferenceProperty( wh, "min", 0.0 );
4696 setPreferenceProperty( wh, "max", 1.0 );
4697 setPreferenceProperty( wh, "step", 0.1 );
4698 setPreferenceProperty( hh, "min", 0.0 );
4699 setPreferenceProperty( hh, "max", 1.0 );
4700 setPreferenceProperty( hh, "step", 0.1 );
4702 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4703 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4704 setPreferenceProperty( distributionGr, "columns", 3 );
4706 types.append( tr( "SMESH_MONOCOLOR" ) );
4707 types.append( tr( "SMESH_MULTICOLOR" ) );
4708 indices.clear(); indices.append( 0 ); indices.append( 1 );
4709 setPreferenceProperty( coloringType, "strings", types );
4710 setPreferenceProperty( coloringType, "indexes", indices );
4711 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4715 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4717 if( sect=="SMESH" ) {
4718 float sbX1,sbY1,sbW,sbH;
4719 float aTol = 1.00000009999999;
4720 std::string aWarning;
4721 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4722 if( name=="selection_object_color" || name=="selection_element_color" ||
4723 name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
4724 name=="selection_precision_node" || name=="selection_precision_element" ||
4725 name=="selection_precision_object")
4726 SMESH::UpdateSelectionProp( this );
4727 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4728 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4729 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4730 if(sbX1+sbW > aTol){
4731 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4734 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4735 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4738 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4739 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4740 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4741 if(sbY1+sbH > aTol){
4742 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4743 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4744 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4747 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4748 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4749 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4750 if(sbX1+sbW > aTol){
4751 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4754 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4755 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4758 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4759 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4760 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4761 if(sbY1+sbH > aTol){
4762 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4765 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4766 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4769 else if ( name == "segmentation" ) {
4770 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4771 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4773 else if ( name == "nb_segments_per_edge" ) {
4774 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4775 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4778 if(aWarning.size() != 0){
4779 aWarning += "The default values are applied instead.";
4780 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4781 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4782 QObject::tr(aWarning.c_str()));
4787 //================================================================================
4789 * \brief Update something in accordance with update flags
4790 * \param theFlags - update flags
4792 * Update viewer or/and object browser etc. in accordance with update flags ( see
4793 * LightApp_UpdateFlags enumeration ).
4795 //================================================================================
4796 void SMESHGUI::update( const int flags )
4798 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
4799 SMESH::UpdateView();
4801 SalomeApp_Module::update( flags );
4804 //================================================================================
4806 * \brief Set default selection mode
4808 * SLOT called when operation commited. Sets default selection mode
4810 //================================================================================
4811 void SMESHGUI::onOperationCommited( SUIT_Operation* )
4813 SVTK_ViewWindow* vtkWnd =
4814 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4816 vtkWnd->SetSelectionMode( ActorSelection );
4819 //================================================================================
4821 * \brief Set default selection mode
4823 * SLOT called when operation aborted. Sets default selection mode
4825 //================================================================================
4826 void SMESHGUI::onOperationAborted( SUIT_Operation* )
4828 SVTK_ViewWindow* vtkWnd =
4829 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
4831 vtkWnd->SetSelectionMode( ActorSelection );
4834 //================================================================================
4836 * \brief Creates operation with given identifier
4837 * \param id - identifier of operation to be started
4838 * \return Pointer on created operation or NULL if operation is not created
4840 * Virtual method redefined from the base class creates operation with given id.
4841 * It is called called automatically from startOperation method of base class.
4843 //================================================================================
4844 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
4846 LightApp_Operation* op = 0;
4847 // to do : create operation here
4850 case 417: //convert to quadratic
4851 op = new SMESHGUI_ConvToQuadOp();
4853 case 418: // create 2D mesh as boundary on 3D
4854 op = new SMESHGUI_Make2DFrom3DOp();
4856 case 701: // Compute mesh
4857 op = new SMESHGUI_ComputeOp();
4859 case 702: // Create mesh
4860 op = new SMESHGUI_MeshOp( true, true );
4862 case 703: // Create sub-mesh
4863 op = new SMESHGUI_MeshOp( true, false );
4865 case 704: // Edit mesh/sub-mesh
4866 op = new SMESHGUI_MeshOp( false );
4868 case 711: // Precompute mesh
4869 op = new SMESHGUI_PrecomputeOp();
4871 case 712: // Evaluate mesh
4872 op = new SMESHGUI_EvaluateOp();
4874 case 713: // Evaluate mesh
4875 op = new SMESHGUI_MeshOrderOp();
4877 case 806: // Create group on geom
4878 op = new SMESHGUI_GroupOnShapeOp();
4880 case 904: // Find element
4881 op = new SMESHGUI_FindElemByPointOp();
4883 case 4067: // make mesh pass through point
4884 op = new SMESHGUI_MakeNodeAtPointOp();
4891 op = SalomeApp_Module::createOperation( id );
4895 //================================================================================
4897 * \brief Stops current operations and starts a given one
4898 * \param id - The id of the operation to start
4900 //================================================================================
4902 void SMESHGUI::switchToOperation(int id)
4904 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
4905 activeStudy()->abortAllOperations();
4906 startOperation( id );
4909 LightApp_Displayer* SMESHGUI::displayer()
4912 myDisplayer = new SMESHGUI_Displayer( getApp() );
4916 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
4919 int aTolerance = 64;
4920 int anIterations = 0;
4926 if( anIterations % aPeriod == 0 )
4929 if( aTolerance < 1 )
4933 aHue = (int)( 360.0 * rand() / RAND_MAX );
4936 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
4937 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
4938 for( ; it != itEnd; ++it )
4940 SALOMEDS::Color anAutoColor = *it;
4941 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
4944 aQColor.getHsv( &h, &s, &v );
4945 if( abs( h - aHue ) < aTolerance )
4957 aColor.setHsv( aHue, 255, 255 );
4959 SALOMEDS::Color aSColor;
4960 aSColor.R = (double)aColor.red() / 255.0;
4961 aSColor.G = (double)aColor.green() / 255.0;
4962 aSColor.B = (double)aColor.blue() / 255.0;
4967 const char gSeparator = '_'; // character used to separate parameter names
4968 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
4969 const char gPathSep = '|'; // character used to separate paths
4972 * \brief Store visual parameters
4974 * This method is called just before the study document is saved.
4975 * Store visual parameters in AttributeParameter attribue(s)
4977 void SMESHGUI::storeVisualParameters (int savePoint)
4979 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
4980 if (!appStudy || !appStudy->studyDS())
4982 _PTR(Study) studyDS = appStudy->studyDS();
4984 // componentName is used for encoding of entries when storing them in IParameters
4985 std::string componentName = myComponentSMESH->ComponentDataType();
4986 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
4987 //if (!aSComponent) return;
4990 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
4991 componentName.c_str(),
4993 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
4995 // store map of custom markers
4996 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
4997 if( !aMarkerMap.empty() )
4999 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5000 for( ; anIter != aMarkerMap.end(); anIter++ )
5002 int anId = anIter->first;
5003 VTK::MarkerData aMarkerData = anIter->second;
5004 std::string aMarkerFileName = aMarkerData.first;
5005 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5006 if( aMarkerTexture.size() < 3 )
5007 continue; // should contain at least width, height and the first value
5009 QString aPropertyName( "texture" );
5010 aPropertyName += gSeparator;
5011 aPropertyName += QString::number( anId );
5013 QString aPropertyValue = aMarkerFileName.c_str();
5014 aPropertyValue += gPathSep;
5016 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5017 ushort aWidth = *aTextureIter++;
5018 ushort aHeight = *aTextureIter++;
5019 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5020 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5021 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5022 aPropertyValue += QString::number( *aTextureIter );
5024 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5028 // viewers counters are used for storing view_numbers in IParameters
5031 // main cycle to store parameters of displayed objects
5032 QList<SUIT_ViewManager*> lst;
5033 QList<SUIT_ViewManager*>::Iterator it;
5034 getApp()->viewManagers(lst);
5035 for (it = lst.begin(); it != lst.end(); it++)
5037 SUIT_ViewManager* vman = *it;
5038 QString vType = vman->getType();
5040 // saving VTK actors properties
5041 if (vType == SVTK_Viewer::Type())
5043 // store the clipping planes attached to the view manager
5044 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5045 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5046 if( anIter != myClippingPlaneInfoMap.end() )
5047 aClippingPlaneInfoList = anIter->second;
5049 if( !aClippingPlaneInfoList.empty() ) {
5050 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5051 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5053 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5054 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5056 QString aPropertyName( "ClippingPlane" );
5057 aPropertyName += gSeparator;
5058 aPropertyName += QString::number( vtkViewers );
5059 aPropertyName += gSeparator;
5060 aPropertyName += QString::number( anId );
5062 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5063 aPropertyValue += gDigitsSep;
5064 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5065 aPropertyValue += gDigitsSep;
5066 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5067 aPropertyValue += gDigitsSep;
5068 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5070 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5074 QVector<SUIT_ViewWindow*> views = vman->getViews();
5075 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5077 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5079 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5080 vtkActorCollection* allActors = aCopy.GetActors();
5081 allActors->InitTraversal();
5082 while (vtkActor* actor = allActors->GetNextActor())
5084 if (actor->GetVisibility()) // store only visible actors
5086 SMESH_Actor* aSmeshActor = 0;
5087 if (actor->IsA("SMESH_Actor"))
5088 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5089 if (aSmeshActor && aSmeshActor->hasIO())
5091 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5094 // entry is "encoded" = it does NOT contain component adress,
5095 // since it is a subject to change on next component loading
5096 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5098 std::string param, vtkParam = vType.toLatin1().data();
5099 vtkParam += gSeparator;
5100 vtkParam += QString::number(vtkViewers).toLatin1().data();
5101 vtkParam += gSeparator;
5104 param = vtkParam + "Visibility";
5105 ip->setParameter(entry, param, "On");
5108 param = vtkParam + "Representation";
5109 ip->setParameter(entry, param, QString::number
5110 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5113 param = vtkParam + "IsShrunk";
5114 ip->setParameter(entry, param, QString::number
5115 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5117 // Displayed entities
5118 unsigned int aMode = aSmeshActor->GetEntityMode();
5119 bool isE = aMode & SMESH_Actor::eEdges;
5120 bool isF = aMode & SMESH_Actor::eFaces;
5121 bool isV = aMode & SMESH_Actor::eVolumes;
5123 QString modeStr ("e");
5124 modeStr += gDigitsSep; modeStr += QString::number(isE);
5125 modeStr += gDigitsSep; modeStr += "f";
5126 modeStr += gDigitsSep; modeStr += QString::number(isF);
5127 modeStr += gDigitsSep; modeStr += "v";
5128 modeStr += gDigitsSep; modeStr += QString::number(isV);
5130 param = vtkParam + "Entities";
5131 ip->setParameter(entry, param, modeStr.toLatin1().data());
5133 // Colors (surface:edge:)
5134 vtkFloatingPointType r, g, b;
5137 aSmeshActor->GetSufaceColor(r, g, b, delta);
5138 QString colorStr ("surface");
5139 colorStr += gDigitsSep; colorStr += QString::number(r);
5140 colorStr += gDigitsSep; colorStr += QString::number(g);
5141 colorStr += gDigitsSep; colorStr += QString::number(b);
5143 colorStr += gDigitsSep; colorStr += "backsurface";
5144 colorStr += gDigitsSep; colorStr += QString::number(delta);
5147 aSmeshActor->GetEdgeColor(r, g, b);
5148 colorStr += gDigitsSep; colorStr += "edge";
5149 colorStr += gDigitsSep; colorStr += QString::number(r);
5150 colorStr += gDigitsSep; colorStr += QString::number(g);
5151 colorStr += gDigitsSep; colorStr += QString::number(b);
5153 aSmeshActor->GetNodeColor(r, g, b);
5154 colorStr += gDigitsSep; colorStr += "node";
5155 colorStr += gDigitsSep; colorStr += QString::number(r);
5156 colorStr += gDigitsSep; colorStr += QString::number(g);
5157 colorStr += gDigitsSep; colorStr += QString::number(b);
5159 aSmeshActor->GetOutlineColor(r, g, b);
5160 colorStr += gDigitsSep; colorStr += "outline";
5161 colorStr += gDigitsSep; colorStr += QString::number(r);
5162 colorStr += gDigitsSep; colorStr += QString::number(g);
5163 colorStr += gDigitsSep; colorStr += QString::number(b);
5165 param = vtkParam + "Colors";
5166 ip->setParameter(entry, param, colorStr.toLatin1().data());
5168 // Sizes of lines and points
5169 QString sizeStr ("line");
5170 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5171 sizeStr += gDigitsSep; sizeStr += "shrink";
5172 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5174 param = vtkParam + "Sizes";
5175 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5180 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5181 if( aMarkerType == VTK::MT_USER ) {
5182 markerStr += "custom";
5183 markerStr += gDigitsSep;
5184 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5188 markerStr += gDigitsSep;
5189 markerStr += QString::number( (int)aMarkerType );
5190 markerStr += gDigitsSep;
5191 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5194 param = vtkParam + "PointMarker";
5195 ip->setParameter(entry, param, markerStr.toLatin1().data());
5198 param = vtkParam + "Opacity";
5199 ip->setParameter(entry, param,
5200 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5203 param = vtkParam + "ClippingPlane";
5205 if( !aClippingPlaneInfoList.empty() ) {
5206 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5207 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5209 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5210 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5211 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5212 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5213 if( aSmeshActor == *anIter2 ) {
5214 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5215 QString::number( anId ).toLatin1().constData() );
5222 ip->setParameter( entry, param, "Off" );
5223 } // if (io->hasEntry())
5224 } // SMESH_Actor && hasIO
5226 } // while.. actors traversal
5230 } // if (SVTK view model)
5231 } // for (viewManagers)
5234 // data structures for clipping planes processing
5237 vtkIdType Orientation;
5238 vtkFloatingPointType Distance;
5239 vtkFloatingPointType Angle[2];
5241 typedef std::list<TPlaneData> TPlaneDataList;
5242 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5244 typedef std::list<vtkActor*> TActorList;
5247 TActorList ActorList;
5248 SUIT_ViewManager* ViewManager;
5250 typedef std::list<TPlaneInfo> TPlaneInfoList;
5251 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5254 * \brief Restore visual parameters
5256 * This method is called after the study document is opened.
5257 * Restore visual parameters from AttributeParameter attribue(s)
5259 void SMESHGUI::restoreVisualParameters (int savePoint)
5261 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5262 if (!appStudy || !appStudy->studyDS())
5264 _PTR(Study) studyDS = appStudy->studyDS();
5266 // componentName is used for encoding of entries when storing them in IParameters
5267 std::string componentName = myComponentSMESH->ComponentDataType();
5268 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5269 //if (!aSComponent) return;
5272 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5273 componentName.c_str(),
5275 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5277 // restore map of custom markers and map of clipping planes
5278 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5279 TPlaneDataMap aPlaneDataMap;
5281 std::vector<std::string> properties = ip->getProperties();
5282 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5284 std::string property = *propIt;
5285 QString aPropertyName( property.c_str() );
5286 QString aPropertyValue( ip->getProperty( property ).c_str() );
5288 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5289 if( aPropertyNameList.isEmpty() )
5292 QString aPropertyType = aPropertyNameList[0];
5293 if( aPropertyType == "texture" )
5295 if( aPropertyNameList.size() != 2 )
5299 int anId = aPropertyNameList[1].toInt( &ok );
5300 if( !ok || anId < 1 )
5303 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5304 if( aPropertyValueList.size() != 2 )
5307 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5308 QString aMarkerTextureString = aPropertyValueList[1];
5309 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5310 if( aMarkerTextureStringList.size() != 3 )
5314 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5319 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5323 VTK::MarkerTexture aMarkerTexture;
5324 aMarkerTexture.push_back( aWidth );
5325 aMarkerTexture.push_back( aHeight );
5327 QString aMarkerTextureData = aMarkerTextureStringList[2];
5328 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5330 QChar aChar = aMarkerTextureData.at( i );
5331 if( aChar.isDigit() )
5332 aMarkerTexture.push_back( aChar.digitValue() );
5335 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5337 else if( aPropertyType == "ClippingPlane" )
5339 if( aPropertyNameList.size() != 3 )
5343 int aViewId = aPropertyNameList[1].toInt( &ok );
5344 if( !ok || aViewId < 0 )
5348 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5349 if( !ok || aClippingPlaneId < 0 )
5352 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5353 if( aPropertyValueList.size() != 4 )
5356 TPlaneData aPlaneData;
5357 aPlaneData.Id = aClippingPlaneId;
5360 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5365 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5370 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5375 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5379 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5380 aPlaneDataList.push_back( aPlaneData );
5384 TPlaneInfoMap aPlaneInfoMap;
5386 std::vector<std::string> entries = ip->getEntries();
5388 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5390 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5391 QString entry (ip->decodeEntry(*entIt).c_str());
5393 // Check that the entry corresponds to a real object in the Study
5394 // as the object may be deleted or modified after the visual state is saved.
5395 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5396 if (!so) continue; //Skip the not existent entry
5398 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5399 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5401 std::vector<std::string>::iterator namesIt = paramNames.begin();
5402 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5404 // actors are stored in a map after displaying of them for
5405 // quicker access in the future: map < viewID to actor >
5406 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5408 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5410 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5411 // '_' is used as separator and should not be used in viewer type or parameter names.
5412 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5413 if (lst.size() != 3)
5416 QString viewerTypStr = lst[0];
5417 QString viewIndexStr = lst[1];
5418 QString paramNameStr = lst[2];
5421 int viewIndex = viewIndexStr.toUInt(&ok);
5422 if (!ok) // bad conversion of view index to integer
5426 if (viewerTypStr == SVTK_Viewer::Type())
5428 SMESH_Actor* aSmeshActor = 0;
5429 if (vtkActors.IsBound(viewIndex))
5430 aSmeshActor = vtkActors.Find(viewIndex);
5432 QList<SUIT_ViewManager*> lst;
5433 getApp()->viewManagers(viewerTypStr, lst);
5435 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5436 SUIT_ViewManager* vman = NULL;
5437 if (viewIndex >= 0 && viewIndex < lst.count())
5438 vman = lst.at(viewIndex);
5440 if (paramNameStr == "Visibility")
5442 if (!aSmeshActor && displayer() && vman)
5444 SUIT_ViewModel* vmodel = vman->getViewModel();
5445 // SVTK view model can be casted to SALOME_View
5446 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5448 // store displayed actor in a temporary map for quicker
5449 // access later when restoring other parameters
5450 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5451 vtkRenderer* Renderer = vtkView->getRenderer();
5452 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5453 vtkActorCollection* theActors = aCopy.GetActors();
5454 theActors->InitTraversal();
5455 bool isFound = false;
5456 vtkActor *ac = theActors->GetNextActor();
5457 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5458 if (ac->IsA("SMESH_Actor")) {
5459 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5460 if (aGeomAc->hasIO()) {
5461 Handle(SALOME_InteractiveObject) io =
5462 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5463 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5465 vtkActors.Bind(viewIndex, aGeomAc);
5471 } // if (paramNameStr == "Visibility")
5474 // the rest properties "work" with SMESH_Actor
5477 QString val ((*valuesIt).c_str());
5480 if (paramNameStr == "Representation") {
5481 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5484 else if (paramNameStr == "IsShrunk") {
5486 if (!aSmeshActor->IsShrunk())
5487 aSmeshActor->SetShrink();
5490 if (aSmeshActor->IsShrunk())
5491 aSmeshActor->UnShrink();
5494 // Displayed entities
5495 else if (paramNameStr == "Entities") {
5496 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5497 if (mode.count() == 6) {
5498 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5499 MESSAGE("Invalid order of data in Entities, must be: "
5500 "e:0/1:f:0/1:v:0/1");
5503 unsigned int aMode = aSmeshActor->GetEntityMode();
5504 unsigned int aNewMode =
5505 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5506 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5507 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5508 if (aNewMode != aMode)
5509 aSmeshActor->SetEntityMode(aNewMode);
5514 else if (paramNameStr == "Colors") {
5515 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5516 if (colors.count() == 16 || colors.count() == 18 ) {
5517 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5518 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
5519 (colors.count() == 18 && colors[14] != "outline")) {
5520 MESSAGE("Invalid order of data in Colors, must be: "
5521 "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");
5527 vtkFloatingPointType otr,otg,otb;
5528 //Old case backsurface color is independent
5529 if( colors.count() == 16 ) {
5531 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5532 er = colors[9].toFloat();
5533 eg = colors[10].toFloat();
5534 eb = colors[11].toFloat();
5536 nr = colors[13].toFloat();
5537 ng = colors[14].toFloat();
5538 nb = colors[15].toFloat();
5539 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5541 //New case backsurface color depends on surface color
5542 delta = colors[5].toInt();
5544 er = colors[7].toFloat();
5545 eg = colors[8].toFloat();
5546 eb = colors[9].toFloat();
5548 nr = colors[11].toFloat();
5549 ng = colors[12].toFloat();
5550 nb = colors[13].toFloat();
5552 otr = colors[15].toFloat();
5553 otg = colors[16].toFloat();
5554 otb = colors[17].toFloat();
5556 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5557 aSmeshActor->SetEdgeColor(er,eg,eb);
5558 aSmeshActor->SetNodeColor(nr,ng,nb);
5559 aSmeshActor->SetOutlineColor(otr,otg,otb);
5563 // Sizes of lines and points
5564 else if (paramNameStr == "Sizes") {
5565 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5566 if (sizes.count() == 4) {
5567 if (sizes[0] != "line" || sizes[2] != "shrink") {
5568 MESSAGE("Invalid order of data in Sizes, must be: "
5569 "line:int:shrink:float");
5572 aSmeshActor->SetLineWidth(sizes[1].toInt());
5573 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5576 else if (sizes.count() == 6) { // just to support old format
5577 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5578 MESSAGE("Invalid order of data in Sizes, must be: "
5579 "line:int:node:int:shrink:float");
5582 aSmeshActor->SetLineWidth(sizes[1].toInt());
5583 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5584 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5589 else if (paramNameStr == "PointMarker") {
5590 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5591 if( data.count() >= 2 ) {
5593 int aParam1 = data[1].toInt( &ok );
5595 if( data[0] == "std" && data.count() == 3 ) {
5596 int aParam2 = data[2].toInt( &ok );
5597 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5599 else if( data[0] == "custom" ) {
5600 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5601 if( markerIt != aMarkerMap.end() ) {
5602 VTK::MarkerData aMarkerData = markerIt->second;
5603 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5610 else if (paramNameStr == "Opacity") {
5611 aSmeshActor->SetOpacity(val.toFloat());
5614 else if (paramNameStr.startsWith("ClippingPlane")) {
5615 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5616 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5617 // new format - val looks like "Off" or "0" (plane id)
5618 // (note: in new format "Off" value is used only for consistency,
5619 // so it is processed together with values in old format)
5620 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5621 if( anIsOldFormat ) {
5622 if (paramNameStr == "ClippingPlane1" || val == "Off")
5623 aSmeshActor->RemoveAllClippingPlanes();
5625 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5626 double aDistance = vals[1].toFloat();
5627 vtkFloatingPointType anAngle[2];
5628 anAngle[0] = vals[2].toFloat();
5629 anAngle[1] = vals[3].toFloat();
5631 QList<SUIT_ViewManager*> lst;
5632 getApp()->viewManagers(viewerTypStr, lst);
5633 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5634 if (viewIndex >= 0 && viewIndex < lst.count()) {
5635 SUIT_ViewManager* vman = lst.at(viewIndex);
5636 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5638 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5640 SMESH::TActorList anActorList;
5641 anActorList.push_back( aSmeshActor );
5642 SMESH::OrientedPlane* aPlane =
5643 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5645 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5646 aClippingPlaneInfo.Plane = aPlane;
5647 aClippingPlaneInfo.ActorList = anActorList;
5648 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5655 int aPlaneId = val.toInt( &ok );
5656 if( ok && aPlaneId >= 0 ) {
5657 bool anIsDefinedPlane = false;
5658 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5659 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5660 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5661 TPlaneInfo& aPlaneInfo = *anIter;
5662 if( aPlaneInfo.PlaneId == aPlaneId ) {
5663 aPlaneInfo.ActorList.push_back( aSmeshActor );
5664 anIsDefinedPlane = true;
5668 if( !anIsDefinedPlane ) {
5669 TPlaneInfo aPlaneInfo;
5670 aPlaneInfo.PlaneId = aPlaneId;
5671 aPlaneInfo.ActorList.push_back( aSmeshActor );
5672 aPlaneInfo.ViewManager = vman;
5674 // to make the list sorted by plane id
5675 anIter = aPlaneInfoList.begin();
5676 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5677 const TPlaneInfo& aPlaneInfoRef = *anIter;
5678 if( aPlaneInfoRef.PlaneId > aPlaneId )
5681 aPlaneInfoList.insert( anIter, aPlaneInfo );
5686 } // if (aSmeshActor)
5687 } // other parameters than Visibility
5689 } // for names/parameters iterator
5690 } // for entries iterator
5692 // take into account planes with empty list of actors referred to them
5693 QList<SUIT_ViewManager*> aVMList;
5694 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5696 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5697 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5698 int aViewId = aPlaneDataIter->first;
5699 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5700 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5702 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5704 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5705 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5706 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5707 const TPlaneData& aPlaneData = *anIter2;
5708 int aPlaneId = aPlaneData.Id;
5710 bool anIsFound = false;
5711 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5712 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5713 const TPlaneInfo& aPlaneInfo = *anIter3;
5714 if( aPlaneInfo.PlaneId == aPlaneId ) {
5721 TPlaneInfo aPlaneInfo; // ActorList field is empty
5722 aPlaneInfo.PlaneId = aPlaneId;
5723 aPlaneInfo.ViewManager = aViewManager;
5725 // to make the list sorted by plane id
5726 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5727 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5728 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5729 if( aPlaneInfoRef.PlaneId > aPlaneId )
5732 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5738 // add clipping planes to actors according to the restored parameters
5739 // and update the clipping plane map
5740 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5741 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5742 int aViewId = anIter1->first;
5743 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5745 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5746 if( anIter2 == aPlaneDataMap.end() )
5748 const TPlaneDataList& aPlaneDataList = anIter2->second;
5750 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5751 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5752 const TPlaneInfo& aPlaneInfo = *anIter3;
5753 int aPlaneId = aPlaneInfo.PlaneId;
5754 const TActorList& anActorList = aPlaneInfo.ActorList;
5755 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5759 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5763 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5765 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5766 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5767 const TPlaneData& aPlaneData = *anIter4;
5768 if( aPlaneData.Id == aPlaneId ) {
5769 SMESH::OrientedPlane* aPlane =
5770 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5772 (SMESH::Orientation)aPlaneData.Orientation,
5773 aPlaneData.Distance,
5776 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5777 aClippingPlaneInfo.Plane = aPlane;
5778 aClippingPlaneInfo.ActorList = anActorList;
5779 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5787 // update all VTK views
5788 QList<SUIT_ViewManager*> lst;
5789 getApp()->viewManagers(lst);
5790 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
5791 SUIT_ViewModel* vmodel = (*it)->getViewModel();
5792 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
5793 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
5794 vtkView->getRenderer()->ResetCameraClippingRange();
5801 \brief Adds preferences for dfont of VTK viewer
5803 \param pIf group identifier
5804 \param param parameter
5805 \return identifier of preferences
5807 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
5809 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
5811 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
5814 fam.append( tr( "SMESH_FONT_ARIAL" ) );
5815 fam.append( tr( "SMESH_FONT_COURIER" ) );
5816 fam.append( tr( "SMESH_FONT_TIMES" ) );
5818 setPreferenceProperty( tfont, "fonts", fam );
5820 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
5821 setPreferenceProperty( tfont, "features", f );
5827 \brief Actions after hypothesis edition
5828 Updates object browser after hypothesis edition
5830 void SMESHGUI::onHypothesisEdit( int result )
5833 SMESHGUI::Modified();
5834 updateObjBrowser( true );
5839 \brief Signal handler closing(SUIT_ViewWindow*) of a view
5840 \param pview view being closed
5842 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
5843 #ifndef DISABLE_PLOT2DVIEWER
5844 //Crear all Plot2d Viewers if need.
5845 SMESH::ClearPlot2Viewers(pview);
5850 \brief Connects or disconnects signals about activating and cloning view on the module slots
5851 \param pview view which is connected/disconnected
5853 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
5857 SUIT_ViewManager* viewMgr = pview->getViewManager();
5859 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5860 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5862 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
5863 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
5868 \brief Return \c true if object can be renamed
5870 bool SMESHGUI::renameAllowed( const QString& entry) const {
5871 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5875 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5879 bool appRes = SalomeApp_Module::renameAllowed(entry);
5883 // check type to prevent renaming of inappropriate objects
5884 int aType = SMESHGUI_Selection::type(qPrintable(entry), aStudy);
5885 if (aType == MESH || aType == GROUP ||
5886 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5887 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5888 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5889 aType == HYPOTHESIS || aType == ALGORITHM)
5896 Rename object by entry.
5897 \param entry entry of the object
5898 \param name new name of the object
5899 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5901 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
5903 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
5907 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
5911 bool appRes = SalomeApp_Module::renameObject(entry,name);
5915 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
5916 _PTR(GenericAttribute) anAttr;
5917 _PTR(AttributeName) aName;
5919 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
5921 // check type to prevent renaming of inappropriate objects
5922 int aType = SMESHGUI_Selection::type( qPrintable(entry), aStudy );
5923 if (aType == MESH || aType == GROUP ||
5924 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
5925 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
5926 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
5927 aType == HYPOTHESIS || aType == ALGORITHM) {
5928 if ( !name.isEmpty() ) {
5929 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
5931 // update name of group object and its actor
5932 Handle(SALOME_InteractiveObject) IObject =
5933 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
5935 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
5936 if( !aGroupObject->_is_nil() ) {
5937 aGroupObject->SetName( qPrintable(name) );
5938 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
5939 anActor->setName( qPrintable(name) );