1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
25 #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
27 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
32 #include "SMESHGUI_AddMeshElementDlg.h"
33 #include "SMESHGUI_AddQuadraticElementDlg.h"
34 #include "SMESHGUI_BuildCompoundDlg.h"
35 #include "SMESHGUI_ClippingDlg.h"
36 #include "SMESHGUI_ComputeDlg.h"
37 #include "SMESHGUI_ConvToQuadOp.h"
38 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
39 #include "SMESHGUI_DeleteGroupDlg.h"
40 #include "SMESHGUI_Displayer.h"
41 #include "SMESHGUI_MergeDlg.h"
42 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
43 #include "SMESHGUI_ExtrusionDlg.h"
44 #include "SMESHGUI_FileInfoDlg.h"
45 #include "SMESHGUI_FileValidator.h"
46 #include "SMESHGUI_FilterDlg.h"
47 #include "SMESHGUI_FilterLibraryDlg.h"
48 #include "SMESHGUI_FindElemByPointDlg.h"
49 #include "SMESHGUI_GroupDlg.h"
50 #include "SMESHGUI_GroupOnShapeDlg.h"
51 #include "SMESHGUI_GroupOpDlg.h"
52 #include "SMESHGUI_Hypotheses.h"
53 #include "SMESHGUI_Make2DFrom3DOp.h"
54 #include "SMESHGUI_MakeNodeAtPointDlg.h"
55 #include "SMESHGUI_Measurements.h"
56 #include "SMESHGUI_MeshInfo.h"
57 #include "SMESHGUI_MeshOp.h"
58 #include "SMESHGUI_MeshOrderOp.h"
59 #include "SMESHGUI_MeshPatternDlg.h"
60 #include "SMESHGUI_MultiEditDlg.h"
61 #include "SMESHGUI_NodesDlg.h"
62 #include "SMESHGUI_Preferences_ColorDlg.h"
63 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
64 #include "SMESHGUI_RemoveElementsDlg.h"
65 #include "SMESHGUI_RemoveNodesDlg.h"
66 #include "SMESHGUI_RenumberingDlg.h"
67 #include "SMESHGUI_RevolutionDlg.h"
68 #include "SMESHGUI_RotationDlg.h"
69 #include "SMESHGUI_Selection.h"
70 #include "SMESHGUI_SewingDlg.h"
71 #include "SMESHGUI_SingleEditDlg.h"
72 #include "SMESHGUI_SmoothingDlg.h"
73 #include "SMESHGUI_SymmetryDlg.h"
74 #include "SMESHGUI_TranslationDlg.h"
75 #include "SMESHGUI_ScaleDlg.h"
76 #include "SMESHGUI_TransparencyDlg.h"
77 #include "SMESHGUI_DuplicateNodesDlg.h"
78 #include "SMESHGUI_CopyMeshDlg.h"
79 #include "SMESHGUI_ReorientFacesDlg.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>
103 #include <SalomeApp_DataObject.h>
105 #include <LightApp_DataOwner.h>
106 #include <LightApp_Preferences.h>
107 #include <LightApp_SelectionMgr.h>
108 #include <LightApp_UpdateFlags.h>
109 #include <LightApp_NameDlg.h>
111 #include <SVTK_ViewWindow.h>
112 #include <SVTK_ViewModel.h>
113 #include <SVTK_ViewManager.h>
115 #include <VTKViewer_Algorithm.h>
117 #include <SUIT_MessageBox.h>
118 #include <SUIT_ResourceMgr.h>
119 #include <SUIT_FileDlg.h>
120 #include <SUIT_Desktop.h>
121 #include <SUIT_OverrideCursor.h>
122 #include <SUIT_Session.h>
124 #include <QtxPopupMgr.h>
125 #include <QtxFontEdit.h>
127 #include <SALOME_ListIO.hxx>
128 #include <SALOME_ListIteratorOfListIO.hxx>
130 #ifndef DISABLE_PLOT2DVIEWER
131 #include <SPlot2d_ViewModel.h>
132 #include <SPlot2d_Histogram.h>
136 #include <SALOMEconfig.h>
137 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
138 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
139 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
142 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
143 #include <QApplication>
145 #include <QTextStream>
148 #include <boost/shared_ptr.hpp>
151 #include <vtkCamera.h>
152 #include <vtkRenderer.h>
153 #include <vtkPlane.h>
154 #include <vtkCallbackCommand.h>
155 #include <vtkLookupTable.h>
157 // SALOME KERNEL includes
158 #include <SALOMEDS_Study.hxx>
159 #include <SALOMEDSClient_StudyBuilder.hxx>
160 #include <SALOMEDSClient_SComponent.hxx>
161 #include <SALOMEDSClient_ClientFactory.hxx>
162 #include <SALOMEDSClient_IParameters.hxx>
165 #include <Standard_ErrorHandler.hxx>
166 #include <NCollection_DataMap.hxx>
168 //To disable automatic genericobj management, the following line should be commented.
169 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
170 #define WITHGENERICOBJ
174 //=============================================================
175 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
178 void ExportMeshToFile(int theCommandID);
180 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
182 void SetDisplayEntity(int theCommandID);
184 void Control( int theCommandID );
188 //=============================================================
189 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
193 std::string myExtension;
195 if ( theCommandID == 113 ) {
196 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
197 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
199 else if ( theCommandID == 112 ) {
200 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
202 else if ( theCommandID == 111 ) {
203 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
205 else if ( theCommandID == 115 ) {
206 filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
208 else if ( theCommandID == 116 ) {
209 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
211 else if ( theCommandID == 117 ) {
212 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
213 filter.append( QObject::tr( "All files (*)" ) );
216 QString anInitialPath = "";
217 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
218 anInitialPath = QDir::currentPath();
220 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
223 QObject::tr( "SMESH_IMPORT_MESH" ) );
224 if ( filenames.count() > 0 ) {
225 SUIT_OverrideCursor wc;
226 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
229 QStringList anEntryList;
230 bool isEmpty = false;
231 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
232 QString filename = *it;
233 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
235 switch ( theCommandID ) {
238 // DAT format (currently unsupported)
239 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
240 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
246 aMeshes->length( 1 );
247 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
248 if ( aMeshes[0]->_is_nil() )
249 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
250 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
256 SMESH::DriverMED_ReadStatus res;
257 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
258 if ( res != SMESH::DRS_OK ) {
259 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
260 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
267 aMeshes->length( 1 );
268 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
269 if ( aMeshes[0]->_is_nil() ) {
270 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
271 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
278 SMESH::DriverMED_ReadStatus res;
279 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
280 if ( res != SMESH::DRS_OK ) {
281 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
282 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
289 SMESH::DriverMED_ReadStatus res;
290 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
291 if ( res != SMESH::DRS_OK ) {
292 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
293 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
299 catch ( const SALOME::SALOME_Exception& S_ex ) {
300 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
301 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
304 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
305 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
307 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
308 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
309 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
310 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
311 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
313 anEntryList.append( aMeshSO->GetID().c_str() );
315 #ifdef WITHGENERICOBJ
316 // obj has been published in study. Its refcount has been incremented.
317 // It is safe to decrement its refcount
318 // so that it will be destroyed when the entry in study will be removed
319 aMeshes[i]->UnRegister();
328 // update Object browser
329 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
331 // browse to the published meshes
332 if( LightApp_Application* anApp =
333 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
334 anApp->browseObjects( anEntryList );
336 // show Error message box if there were errors
337 if ( errors.count() > 0 ) {
338 SUIT_MessageBox::critical( SMESHGUI::desktop(),
339 QObject::tr( "SMESH_ERROR" ),
340 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
343 // show warning message box, if some imported mesh is empty
345 SUIT_MessageBox::warning( SMESHGUI::desktop(),
346 QObject::tr( "SMESH_WRN_WARNING" ),
347 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
352 //================================================================================
354 * \brief Export selected meshes or groups into a file
356 //================================================================================
358 void ExportMeshToFile( int theCommandID )
360 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
361 SALOME_ListIO selected;
363 aSel->selectedObjects( selected );
365 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
366 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
367 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
368 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
369 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
370 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
372 // actually, the following condition can't be met (added for insurance)
373 if( selected.Extent() == 0 ||
374 ( selected.Extent() > 1 && !isMED && !isSTL ))
377 // get mesh object from selection and check duplication of their names
378 bool hasDuplicatedMeshNames = false;
379 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
380 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
381 SALOME_ListIteratorOfListIO It( selected );
382 for( ; It.More(); It.Next() )
384 Handle(SALOME_InteractiveObject) anIObject = It.Value();
385 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
386 if ( aMeshItem->_is_nil() ) {
387 SUIT_MessageBox::warning( SMESHGUI::desktop(),
388 QObject::tr( "SMESH_WRN_WARNING" ),
389 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
393 QString aMeshName = anIObject->getName();
395 // check for name duplications
396 if ( !hasDuplicatedMeshNames )
397 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
398 if( aMeshName == (*aMeshIter).second ) {
399 hasDuplicatedMeshNames = true;
404 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
407 if( hasDuplicatedMeshNames && isMED ) {
408 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
409 QObject::tr("SMESH_WRN_WARNING"),
410 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
411 QObject::tr("SMESH_BUT_YES"),
412 QObject::tr("SMESH_BUT_NO"), 0, 1);
417 aMeshIter = aMeshList.begin();
418 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
419 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
420 QString aMeshName = (*aMeshIter).second;
422 if ( isMED || isCGNS || isSAUV )
424 // check for equal group names within each mesh
425 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
426 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
427 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
428 int aRet = SUIT_MessageBox::warning
429 (SMESHGUI::desktop(),
430 QObject::tr("SMESH_WRN_WARNING"),
431 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
432 QObject::tr("SMESH_BUT_YES"),
433 QObject::tr("SMESH_BUT_NO"), 0, 1);
440 // Warn the user about presence of not supported elements
442 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
446 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Quadrangle );
447 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
448 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
449 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
450 notSupportedElemTypes.push_back( SMESH::Entity_Tetra );
451 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Tetra );
452 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
453 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
454 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Hexa );
455 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
456 notSupportedElemTypes.push_back( SMESH::Entity_Penta );
457 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
458 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
459 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
460 notSupportedElemTypes.push_back( SMESH::Entity_0D );
461 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
466 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
467 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
468 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
469 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
470 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
471 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
472 notSupportedElemTypes.push_back( SMESH::Entity_0D );
473 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
478 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
479 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
480 notSupportedElemTypes.push_back( SMESH::Entity_0D );
481 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
486 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
491 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
492 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
493 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
494 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
495 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
496 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
498 if ( ! notSupportedElemTypes.empty() )
500 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
501 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
502 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
503 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
505 if ( !presentNotSupported.empty() )
508 const char* typeMsg[SMESH::Entity_Last] = { "SMESH_NODES",
509 "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES","SMESH_TRIANGLES",
510 "SMESH_QUADRATIC_TRIANGLES","SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES",
511 "SMESH_BIQUADRATIC_QUADRANGLES","SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
512 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
513 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
514 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
515 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
517 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
518 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
519 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
520 if ( iType != presentNotSupported.size() - 1 )
521 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
523 int aRet = SUIT_MessageBox::warning
524 (SMESHGUI::desktop(),
525 QObject::tr("SMESH_WRN_WARNING"),
526 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
527 QObject::tr("SMESH_BUT_YES"),
528 QObject::tr("SMESH_BUT_NO"), 0, 1);
533 // Get parameters of export operation
536 SMESH::MED_VERSION aFormat;
537 // Init the parameters with the default values
538 bool aIsASCII_STL = true;
539 bool toCreateGroups = false;
540 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
542 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
543 bool toOverwrite = true;
545 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
546 QString anInitialPath = "";
547 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
548 anInitialPath = QDir::currentPath();
550 if ( isUNV || isDAT )
553 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
555 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
556 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
557 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
558 anInitialPath + QString("/") + aMeshName,
559 aFilter, aTitle, false);
561 else if ( isCGNS )// Export to CGNS
563 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
564 fd->setWindowTitle( aTitle );
565 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
566 if ( !anInitialPath.isEmpty() )
567 fd->setDirectory( anInitialPath );
568 fd->selectFile(aMeshName);
569 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
570 fd->setValidator( fv );
573 aFilename = fd->selectedFile();
574 toOverwrite = fv->isOverwrite();
578 else if ( isSTL ) // Export to STL
580 QMap<QString, int> aFilterMap;
581 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
582 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
585 QMap<QString, int>::const_iterator it = aFilterMap.begin();
586 for ( ; it != aFilterMap.end(); ++it )
587 filters.push_back( it.key() );
589 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
590 fd->setWindowTitle( aTitle );
591 fd->setNameFilters( filters );
592 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
593 if ( !anInitialPath.isEmpty() )
594 fd->setDirectory( anInitialPath );
595 fd->selectFile(aMeshName);
599 aFilename = fd->selectedFile();
600 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
605 else if ( isMED || isSAUV ) // Export to MED or SAUV
607 QMap<QString, SMESH::MED_VERSION> aFilterMap;
608 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
610 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
611 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
612 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
615 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
616 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
617 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
621 QString aDefaultFilter;
622 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
623 for ( ; it != aFilterMap.end(); ++it ) {
624 filters.push_back( it.key() );
625 if (it.value() == SMESH::MED_V2_2)
626 aDefaultFilter = it.key();
629 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
630 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
631 fd->setWindowTitle( aTitle );
632 fd->setNameFilters( filters );
633 fd->selectNameFilter(aDefaultFilter);
634 fd->SetChecked(toCreateGroups);
635 if ( !anInitialPath.isEmpty() )
636 fd->setDirectory( anInitialPath );
637 fd->selectFile(aMeshName);
639 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
640 fd->setValidator( fv );
645 aFilename = fd->selectedFile();
647 aFilename = QString::null;
650 aFormat = aFilterMap[fd->selectedNameFilter()];
651 toOverwrite = fv->isOverwrite();
653 if ( !aFilename.isEmpty() ) {
654 // med-2.1 does not support poly elements
655 if ( aFormat==SMESH::MED_V2_1 )
656 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
657 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
658 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
659 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
660 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
662 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
663 QObject::tr("SMESH_WRN_WARNING"),
664 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
665 QObject::tr("SMESH_BUT_YES"),
666 QObject::tr("SMESH_BUT_NO"), 0, 1);
674 // can't append to an existing using other format
675 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
676 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
677 if( !isVersionOk || aVersion != aFormat ) {
678 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
679 QObject::tr("SMESH_WRN_WARNING"),
680 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
681 QObject::tr("SMESH_BUT_YES"),
682 QObject::tr("SMESH_BUT_NO"), 0, 1);
689 QStringList aMeshNamesCollisionList;
690 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
691 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
692 QString anExistingMeshName( aMeshNames[ i ] );
693 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
694 QString anExportMeshName = (*aMeshIter).second;
695 if( anExportMeshName == anExistingMeshName ) {
696 aMeshNamesCollisionList.append( anExportMeshName );
701 if( !aMeshNamesCollisionList.isEmpty() ) {
702 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
703 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
704 QObject::tr("SMESH_WRN_WARNING"),
705 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
706 QObject::tr("SMESH_BUT_YES"),
707 QObject::tr("SMESH_BUT_NO"),
708 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
717 toCreateGroups = fd->IsChecked();
727 if ( !aFilename.isEmpty() ) {
728 // Check whether the file already exists and delete it if yes
729 QFile aFile( aFilename );
730 if ( aFile.exists() && toOverwrite )
732 SUIT_OverrideCursor wc;
735 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
736 // bool Renumber = false;
737 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
739 // Renumber= resMgr->booleanValue("renumbering");
741 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
742 // aMeshEditor->RenumberNodes();
743 // aMeshEditor->RenumberElements();
744 // if ( SMESHGUI::automaticUpdate() )
745 // SMESH::UpdateView();
749 aMeshIter = aMeshList.begin();
750 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
752 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
753 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
754 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
755 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
756 aFormat, toOverwrite && aMeshIndex == 0 );
758 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
759 aFormat, toOverwrite && aMeshIndex == 0 );
764 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
766 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
767 if( !aMeshItem->_is_nil() )
768 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
773 if ( aMeshOrGroup->_is_equivalent( aMesh ))
774 aMesh->ExportDAT( aFilename.toLatin1().data() );
776 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
780 if ( aMeshOrGroup->_is_equivalent( aMesh ))
781 aMesh->ExportUNV( aFilename.toLatin1().data() );
783 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
787 if ( aMeshOrGroup->_is_equivalent( aMesh ))
788 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
790 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
794 aMeshIter = aMeshList.begin();
795 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
797 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
798 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
799 aMeshItem->ExportCGNS( aMeshOrGroup,
800 aFilename.toLatin1().data(),
801 toOverwrite && aMeshIndex == 0 );
805 catch (const SALOME::SALOME_Exception& S_ex){
807 SUIT_MessageBox::warning(SMESHGUI::desktop(),
808 QObject::tr("SMESH_WRN_WARNING"),
809 QObject::tr("SMESH_EXPORT_FAILED"));
815 inline void InverseEntityMode(unsigned int& theOutputMode,
816 unsigned int theMode)
818 bool anIsNotPresent = ~theOutputMode & theMode;
820 theOutputMode |= theMode;
822 theOutputMode &= ~theMode;
825 void SetDisplayEntity(int theCommandID){
826 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
827 SALOME_ListIO selected;
829 aSel->selectedObjects( selected );
831 if(selected.Extent() >= 1){
832 SALOME_ListIteratorOfListIO It( selected );
833 for( ; It.More(); It.Next()){
834 Handle(SALOME_InteractiveObject) IObject = It.Value();
835 if(IObject->hasEntry()){
836 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
837 unsigned int aMode = anActor->GetEntityMode();
838 switch(theCommandID){
840 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
843 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
846 InverseEntityMode(aMode,SMESH_Actor::eEdges);
849 InverseEntityMode(aMode,SMESH_Actor::eFaces);
852 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
855 aMode = SMESH_Actor::eAllEntity;
859 anActor->SetEntityMode(aMode);
867 SALOME_ListIO selected;
868 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
872 LightApp_SelectionMgr* aSel = app->selectionMgr();
873 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
874 if( !aSel || !appStudy )
877 aSel->selectedObjects( selected );
878 if( selected.IsEmpty() )
881 Handle(SALOME_InteractiveObject) anIObject = selected.First();
883 _PTR(Study) aStudy = appStudy->studyDS();
884 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
885 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
886 if( aMainObject->_is_nil() )
889 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
891 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
892 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
894 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
895 SALOMEDS::Color aColor = aGroupObject->GetColor();
896 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
898 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
899 switch ( aGroupObject->GetType ()) {
901 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
903 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
905 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
907 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
911 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
912 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
918 SMESH::RepaintCurrentView();
921 QString functorToString( SMESH::Controls::FunctorPtr f )
923 QString type = QObject::tr( "UNKNOWN_CONTROL" );
924 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
925 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
926 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
927 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
928 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
929 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
930 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
931 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
932 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
933 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
934 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
935 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
936 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
937 type = QObject::tr( "WARP_ELEMENTS" );
938 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
939 type = QObject::tr( "TAPER_ELEMENTS" );
940 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
941 type = QObject::tr( "SKEW_ELEMENTS" );
942 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
943 type = QObject::tr( "AREA_ELEMENTS" );
944 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
945 type = QObject::tr( "LENGTH_EDGES" );
946 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
947 type = QObject::tr( "LENGTH2D_EDGES" );
948 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
949 type = QObject::tr( "MULTI_BORDERS" );
950 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
951 type = QObject::tr( "MULTI2D_BORDERS" );
952 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
953 type = QObject::tr( "FREE_NODES" );
954 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
955 type = QObject::tr( "FREE_EDGES" );
956 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
957 type = QObject::tr( "FREE_BORDERS" );
958 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
959 type = QObject::tr( "FREE_FACES" );
960 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
961 type = QObject::tr( "BARE_BORDER_VOLUME" );
962 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
963 type = QObject::tr( "BARE_BORDER_FACE" );
964 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
965 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
966 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
967 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
968 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
969 type = QObject::tr( "EQUAL_NODE" );
970 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
971 type = QObject::tr( "EQUAL_EDGE" );
972 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
973 type = QObject::tr( "EQUAL_FACE" );
974 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
975 type = QObject::tr( "EQUAL_VOLUME" );
979 void SaveDistribution()
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 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
990 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
991 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
992 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
993 if ( aScalarBarActor && aFunctor ) {
994 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
996 std::vector<int> elements;
997 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
998 if ( mesh->_is_nil() ) {
999 SMESH::SMESH_IDSource_var idSource =
1000 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1001 if ( !idSource->_is_nil() )
1003 SMESH::long_array_var ids = idSource->GetIDs();
1004 elements.resize( ids->length() );
1005 for ( unsigned i = 0; i < elements.size(); ++i )
1006 elements[i] = ids[i];
1009 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1010 vtkLookupTable* lookupTable =
1011 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1012 double * minmax = lookupTable->GetRange();
1013 std::vector<int> nbEvents;
1014 std::vector<double> funValues;
1015 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
1016 QString anInitialPath = "";
1017 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1018 anInitialPath = QDir::currentPath();
1019 QString aMeshName = anIO->getName();
1021 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1022 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1023 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1024 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1025 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1028 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1030 if ( !aFilename.isEmpty() ) {
1031 QFile f( aFilename );
1032 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1033 QTextStream out( &f );
1034 out << "# Mesh: " << aMeshName << endl;
1035 out << "# Control: " << functorToString( aFunctor ) << endl;
1037 out.setFieldWidth( 10 );
1038 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1039 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1050 void ShowDistribution() {
1051 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1052 SALOME_ListIO selected;
1054 aSel->selectedObjects( selected );
1056 if ( selected.Extent() == 1 ) {
1057 Handle(SALOME_InteractiveObject) anIO = selected.First();
1058 if ( anIO->hasEntry() ) {
1059 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1060 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1061 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1062 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1068 #ifndef DISABLE_PLOT2DVIEWER
1069 void PlotDistribution() {
1070 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1074 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1075 SALOME_ListIO selected;
1077 aSel->selectedObjects( selected );
1079 if ( selected.Extent() == 1 ) {
1080 Handle(SALOME_InteractiveObject) anIO = selected.First();
1081 if ( anIO->hasEntry() ) {
1082 //Find Actor by entry before getting Plot2d viewer,
1083 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1084 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1086 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1091 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1095 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1099 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1100 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1101 QString functorName = functorToString( anActor->GetFunctor());
1102 QString aHistogramName("%1 : %2");
1103 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1104 aHistogram->setName(aHistogramName);
1105 aHistogram->setHorTitle(functorName);
1106 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1107 aPlot->displayObject(aHistogram, true);
1112 #endif //DISABLE_PLOT2DVIEWER
1114 void DisableAutoColor(){
1115 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1116 SALOME_ListIO selected;
1118 aSel->selectedObjects( selected );
1120 if(selected.Extent()){
1121 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1122 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1123 if ( !aMesh->_is_nil() ) {
1124 aMesh->SetAutoColor( false );
1129 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1131 SALOME_ListIO selected;
1132 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1136 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1137 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1138 if( !aSel || !appStudy )
1141 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1142 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1143 aModule->EmitSignalDeactivateDialog();
1144 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1145 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1150 _PTR(Study) aStudy = appStudy->studyDS();
1152 aSel->selectedObjects( selected );
1154 if(selected.Extent() >= 1){
1155 switch(theCommandID){
1157 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1158 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1162 QColor c, e, b, n, c0D, cBall, o, outl, selection, preselection;
1164 int size0D = 0, ballSize = 0;
1166 vtkFloatingPointType Shrink = 0.0;
1167 vtkFloatingPointType faces_orientation_scale = 0.0;
1168 bool faces_orientation_3dvectors = false;
1170 VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
1171 VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
1172 int aMarkerTextureCurrent = 0;
1174 SALOME_ListIteratorOfListIO It( selected );
1175 for( ; It.More(); It.Next()){
1176 Handle(SALOME_InteractiveObject) IObject = It.Value();
1177 if(IObject->hasEntry()){
1178 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1179 vtkFloatingPointType color[3];
1180 anActor->GetSufaceColor(color[0], color[1], color[2],delta);
1181 int c0 = int (color[0] * 255);
1182 int c1 = int (color[1] * 255);
1183 int c2 = int (color[2] * 255);
1184 c.setRgb(c0, c1, c2);
1186 vtkFloatingPointType edgecolor[3];
1187 anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
1188 c0 = int (edgecolor[0] * 255);
1189 c1 = int (edgecolor[1] * 255);
1190 c2 = int (edgecolor[2] * 255);
1191 e.setRgb(c0, c1, c2);
1193 vtkFloatingPointType nodecolor[3];
1194 anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
1195 c0 = int (nodecolor[0] * 255);
1196 c1 = int (nodecolor[1] * 255);
1197 c2 = int (nodecolor[2] * 255);
1198 n.setRgb(c0, c1, c2);
1200 vtkFloatingPointType color0D[3];
1201 anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
1202 c0 = int (color0D[0] * 255);
1203 c1 = int (color0D[1] * 255);
1204 c2 = int (color0D[2] * 255);
1205 c0D.setRgb(c0, c1, c2);
1207 vtkFloatingPointType ballcolor[3];
1208 anActor->GetBallColor(ballcolor[0], ballcolor[1], ballcolor[2]);
1209 c0 = int (ballcolor[0] * 255);
1210 c1 = int (ballcolor[1] * 255);
1211 c2 = int (ballcolor[2] * 255);
1212 cBall.setRgb(c0, c1, c2);
1214 vtkFloatingPointType outlineColor[3];
1215 anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
1216 c0 = int (outlineColor[0] * 255);
1217 c1 = int (outlineColor[1] * 255);
1218 c2 = int (outlineColor[2] * 255);
1219 outl.setRgb(c0, c1, c2);
1221 vtkFloatingPointType hColor[3];
1222 anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
1223 c0 = int (hColor[0] * 255);
1224 c1 = int (hColor[1] * 255);
1225 c2 = int (hColor[2] * 255);
1226 selection.setRgb(c0, c1, c2);
1228 vtkFloatingPointType phColor[3];
1229 anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
1230 c0 = int (phColor[0] * 255);
1231 c1 = int (phColor[1] * 255);
1232 c2 = int (phColor[2] * 255);
1233 preselection.setRgb(c0, c1, c2);
1235 size0D = (int)anActor->Get0DSize();
1238 ballSize = (int)anActor->GetBallSize();
1241 Edgewidth = (int)anActor->GetLineWidth();
1244 Shrink = anActor->GetShrinkFactor();
1246 vtkFloatingPointType faces_orientation_color[3];
1247 anActor->GetFacesOrientationColor(faces_orientation_color);
1248 c0 = int (faces_orientation_color[0] * 255);
1249 c1 = int (faces_orientation_color[1] * 255);
1250 c2 = int (faces_orientation_color[2] * 255);
1251 o.setRgb(c0, c1, c2);
1253 faces_orientation_scale = anActor->GetFacesOrientationScale();
1254 faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();
1256 aMarkerTypeCurrent = anActor->GetMarkerType();
1257 aMarkerScaleCurrent = anActor->GetMarkerScale();
1258 aMarkerTextureCurrent = anActor->GetMarkerTexture();
1260 // even if there are multiple objects in the selection,
1261 // we need only the first one to get values for the dialog
1267 SMESHGUI_Preferences_ColorDlg *aDlg =
1268 new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
1269 aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
1270 aDlg->SetColor(1, c);
1271 aDlg->SetColor(2, e);
1272 aDlg->SetColor(3, n);
1273 aDlg->SetColor(4, outl);
1274 aDlg->SetColor(5, c0D);
1275 aDlg->SetColor(6, cBall);
1276 aDlg->SetColor(7, o);
1277 aDlg->SetColor(8, selection);
1278 aDlg->SetColor(9, preselection);
1279 aDlg->SetDeltaBrightness(delta);
1280 aDlg->SetDoubleValue(1, faces_orientation_scale);
1281 aDlg->SetIntValue(1, Edgewidth);
1282 aDlg->SetIntValue(2, int(Shrink*100.));
1283 aDlg->SetIntValue(3, size0D);
1284 aDlg->SetIntValue(4, ballSize);
1286 aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );
1288 if( aMarkerTypeCurrent != VTK::MT_USER )
1289 aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
1291 aDlg->setCustomMarker( aMarkerTextureCurrent );
1294 QColor color = aDlg->GetColor(1);
1295 QColor edgecolor = aDlg->GetColor(2);
1296 QColor nodecolor = aDlg->GetColor(3);
1297 QColor outlinecolor = aDlg->GetColor(4);
1298 QColor color0D = aDlg->GetColor(5);
1299 QColor ballcolor = aDlg->GetColor(6);
1300 QColor faces_orientation_color = aDlg->GetColor(7);
1301 QColor selectioncolor = aDlg->GetColor(8);
1302 QColor preSelectioncolor = aDlg->GetColor(9);
1303 int delta = aDlg->GetDeltaBrightness();
1306 theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();
1308 SALOME_ListIteratorOfListIO It( selected );
1309 for( ; It.More(); It.Next()){
1310 Handle(SALOME_InteractiveObject) IObject = It.Value();
1311 if(IObject->hasEntry()){
1312 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1313 /* actor color and backface color */
1314 anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
1315 vtkFloatingPointType (color.green()) / 255.,
1316 vtkFloatingPointType (color.blue()) / 255.,
1319 anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
1320 vtkFloatingPointType (edgecolor.green()) / 255.,
1321 vtkFloatingPointType (edgecolor.blue()) / 255.);
1323 anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
1324 vtkFloatingPointType (outlinecolor.green()) / 255.,
1325 vtkFloatingPointType (outlinecolor.blue()) / 255.);
1328 anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
1329 vtkFloatingPointType (selectioncolor.green()) / 255.,
1330 vtkFloatingPointType (selectioncolor.blue()) / 255.);
1332 anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
1333 vtkFloatingPointType (preSelectioncolor.green()) / 255.,
1334 vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
1337 /* Shrink factor and size edges */
1338 anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
1339 anActor->SetLineWidth(aDlg->GetIntValue(1));
1341 /* Nodes color and size */
1342 anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
1343 vtkFloatingPointType (nodecolor.green()) / 255.,
1344 vtkFloatingPointType (nodecolor.blue()) / 255.);
1347 anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
1348 vtkFloatingPointType (color0D.green()) / 255.,
1349 vtkFloatingPointType (color0D.blue()) / 255.);
1350 anActor->Set0DSize(aDlg->GetIntValue(3));
1353 anActor->SetBallColor(vtkFloatingPointType (ballcolor.red()) / 255.,
1354 vtkFloatingPointType (ballcolor.green()) / 255.,
1355 vtkFloatingPointType (ballcolor.blue()) / 255.);
1356 anActor->SetBallSize(aDlg->GetIntValue(4));
1358 /* Faces orientation */
1359 vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
1360 vtkFloatingPointType(faces_orientation_color.greenF()),
1361 vtkFloatingPointType(faces_orientation_color.blueF())};
1362 anActor->SetFacesOrientationColor(c);
1363 anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
1364 anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));
1366 VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
1367 VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
1368 int aMarkerTextureNew = aDlg->getCustomMarkerID();
1369 if( aMarkerTypeNew != VTK::MT_USER )
1370 anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
1372 const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
1373 VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
1374 if( anIter != aMarkerMap.end() )
1375 anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
1378 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1379 if( !aGroupObject->_is_nil() )
1381 SMESH::ElementType anElementType = aGroupObject->GetType();
1383 switch( anElementType )
1385 case SMESH::NODE: aColor = nodecolor; break;
1386 case SMESH::EDGE: aColor = edgecolor; break;
1387 default: aColor = color; break;
1390 SALOMEDS::Color aGroupColor;
1391 aGroupColor.R = (float)aColor.red() / 255.0;
1392 aGroupColor.G = (float)aColor.green() / 255.0;
1393 aGroupColor.B = (float)aColor.blue() / 255.0;
1394 aGroupObject->SetColor( aGroupColor );
1399 SMESH::RepaintCurrentView();
1405 SALOME_ListIteratorOfListIO It( selected );
1406 for( ; It.More(); It.Next()){
1407 Handle(SALOME_InteractiveObject) IObject = It.Value();
1408 if(IObject->hasEntry()){
1409 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1410 switch(theCommandID){
1412 anActor->SetRepresentation(SMESH_Actor::eEdge);
1415 anActor->SetRepresentation(SMESH_Actor::eSurface);
1418 if(anActor->IsShrunk())
1419 anActor->UnShrink();
1421 anActor->SetShrink();
1424 anActor->SetRepresentation(SMESH_Actor::ePoint);
1427 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1428 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1431 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1432 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1438 SMESH::RepaintCurrentView();
1442 void Control( int theCommandID )
1444 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1445 SALOME_ListIO selected;
1447 aSel->selectedObjects( selected );
1449 if( !selected.IsEmpty() ){
1450 Handle(SALOME_InteractiveObject) anIO = selected.First();
1452 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1453 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1454 switch ( theCommandID ){
1456 aControl = SMESH_Actor::eLength;
1459 aControl = SMESH_Actor::eLength2D;
1462 aControl = SMESH_Actor::eFreeEdges;
1465 aControl = SMESH_Actor::eFreeBorders;
1468 aControl = SMESH_Actor::eMultiConnection;
1471 aControl = SMESH_Actor::eFreeNodes;
1474 aControl = SMESH_Actor::eMultiConnection2D;
1477 aControl = SMESH_Actor::eArea;
1480 aControl = SMESH_Actor::eTaper;
1483 aControl = SMESH_Actor::eAspectRatio;
1486 aControl = SMESH_Actor::eAspectRatio3D;
1489 aControl = SMESH_Actor::eMinimumAngle;
1492 aControl = SMESH_Actor::eWarping;
1495 aControl = SMESH_Actor::eSkew;
1498 aControl = SMESH_Actor::eVolume3D;
1501 aControl = SMESH_Actor::eFreeFaces;
1504 aControl = SMESH_Actor::eMaxElementLength2D;
1507 aControl = SMESH_Actor::eMaxElementLength3D;
1510 aControl = SMESH_Actor::eBareBorderVolume;
1513 aControl = SMESH_Actor::eBareBorderFace;
1516 aControl = SMESH_Actor::eOverConstrainedVolume;
1519 aControl = SMESH_Actor::eOverConstrainedFace;
1522 aControl = SMESH_Actor::eCoincidentNodes;
1525 aControl = SMESH_Actor::eCoincidentElems1D;
1528 aControl = SMESH_Actor:: eCoincidentElems2D;
1531 aControl = SMESH_Actor::eCoincidentElems3D;
1535 anActor->SetControlMode(aControl);
1536 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1537 SMESH::RepaintCurrentView();
1538 #ifndef DISABLE_PLOT2DVIEWER
1539 if(anActor->GetPlot2Histogram()) {
1540 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1541 QString functorName = functorToString( anActor->GetFunctor());
1542 QString aHistogramName("%1 : %2");
1543 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1544 aHistogram->setName(aHistogramName);
1545 aHistogram->setHorTitle(functorName);
1546 SMESH::ProcessIn2DViewers(anActor);
1555 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1556 MeshObjectType theType,
1557 const QString theInTypeName,
1558 QString & theOutTypeName)
1560 SMESH_TypeFilter aTypeFilter( theType );
1562 if( !theIO.IsNull() )
1564 entry = theIO->getEntry();
1565 LightApp_DataOwner owner( entry );
1566 if ( aTypeFilter.isOk( &owner )) {
1567 theOutTypeName = theInTypeName;
1575 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1577 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1578 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1580 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1581 CORBA::String_var anID = aSComp->GetID().c_str();
1582 if (!strcmp(anID.in(),theIO->getEntry()))
1588 CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
1589 CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
1590 CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
1591 CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
1592 CheckOIType ( theIO, GROUP, "Group", aTypeName )
1600 QString CheckHomogeneousSelection()
1602 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1603 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1604 SALOME_ListIO selected;
1606 aSel->selectedObjects( selected );
1608 QString RefType = CheckTypeObject(selected.First());
1609 SALOME_ListIteratorOfListIO It(selected);
1610 for ( ; It.More(); It.Next())
1612 Handle(SALOME_InteractiveObject) IObject = It.Value();
1613 QString Type = CheckTypeObject(IObject);
1614 if (Type.compare(RefType) != 0)
1615 return "Heterogeneous Selection";
1622 void SMESHGUI::OnEditDelete()
1624 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1625 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1626 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1628 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1629 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1630 _PTR(GenericAttribute) anAttr;
1631 _PTR(AttributeIOR) anIOR;
1633 int objectCount = 0;
1635 QString aParentComponent = QString::null;
1636 Handle(SALOME_InteractiveObject) anIO;
1637 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1639 anIO = anIt.Value();
1640 QString cur = anIO->getComponentDataType();
1641 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1643 // check if object is reference
1644 _PTR(SObject) aRefSObj;
1645 aNameList.append("\n - ");
1646 if ( aSO->ReferencedObject( aRefSObj ) ) {
1647 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1648 aNameList.append( aRefName );
1649 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1652 aNameList.append(anIO->getName());
1656 if( aParentComponent.isNull() )
1657 aParentComponent = cur;
1658 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1659 aParentComponent = "";
1662 if ( objectCount == 0 )
1663 return; // No Valid Objects Selected
1665 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1666 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1667 QObject::tr("ERR_ERROR"),
1668 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1671 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1672 if (SUIT_MessageBox::warning
1673 (SMESHGUI::desktop(),
1674 QObject::tr("SMESH_WRN_WARNING"),
1675 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1676 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1677 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1680 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1682 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1683 // then treat them all starting from the deepest objects (at list back)
1684 std::list< _PTR(SObject) > listSO;
1685 SALOME_ListIteratorOfListIO It(selected);
1686 for( ; It.More(); It.Next()) // loop on selected IO's
1688 Handle(SALOME_InteractiveObject) IObject = It.Value();
1689 if(IObject->hasEntry()) {
1690 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1692 // disable removal of "SMESH" component object
1693 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1695 if ( engineIOR() == anIOR->Value().c_str() )
1698 //Check the referenced object
1699 _PTR(SObject) aRefSObject;
1700 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1701 aSO = aRefSObject; // Delete main Object instead of reference
1703 listSO.push_back( aSO );
1704 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1705 for ( ; itSO != listSO.end(); ++itSO ) {
1706 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1707 for (it->InitEx(false); it->More(); it->Next())
1708 listSO.push_back( it->Value() );
1712 // Check if none of objects to delete is referred from outside
1713 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1714 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1716 _PTR(SObject) SO = *ritSO;
1717 if ( !SO ) continue;
1718 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1719 for (size_t i = 0; i < aReferences.size(); i++) {
1720 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1721 std::string type = aComponent->ComponentDataType();
1722 if ( type != "SMESH" )
1724 SUIT_MessageBox::warning( anApp->desktop(),
1725 QObject::tr("WRN_WARNING"),
1726 QObject::tr("DEP_OBJECT") );
1727 return; // outside SMESH, there is an object depending on a SMESH object
1732 // Treat SO's in the list starting from the back
1733 aStudyBuilder->NewCommand(); // There is a transaction
1734 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1736 _PTR(SObject) SO = *ritSO;
1737 if ( !SO ) continue;
1738 std::string anEntry = SO->GetID();
1740 /** Erase graphical object **/
1741 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1742 ViewManagerList aViewMenegers = anApp->viewManagers();
1743 ViewManagerList::const_iterator it = aViewMenegers.begin();
1744 for( ; it != aViewMenegers.end(); it++) {
1745 SUIT_ViewManager* vm = *it;
1746 int nbSf = vm ? vm->getViewsCount() : 0;
1748 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1749 for(int i = 0; i < nbSf; i++){
1750 SUIT_ViewWindow *sf = aViews[i];
1751 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1752 SMESH::RemoveActor(sf,anActor);
1758 /** Remove an object from data structures **/
1759 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1760 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1761 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1762 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1763 aMesh->RemoveGroup( aGroup );
1765 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1766 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1767 aMesh->RemoveSubMesh( aSubMesh );
1769 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1771 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1774 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1775 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1776 QString objType = CheckTypeObject(IObject);
1777 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1778 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1779 aStudyBuilder->RemoveObjectWithChildren( SO );
1781 else {// default action: remove SObject from the study
1782 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1783 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1785 aStudyBuilder->RemoveObjectWithChildren( SO );
1789 } /* listSO back loop */
1791 aStudyBuilder->CommitCommand();
1793 /* Clear any previous selection */
1795 aSel->setSelectedObjects( l1 );
1797 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1802 SMESHGUI_EXPORT CAM_Module* createModule()
1804 return new SMESHGUI();
1807 SMESHGUI_EXPORT char* getModuleVersion() {
1808 return (char*)SMESH_VERSION_STR;
1812 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1814 //=============================================================================
1818 //=============================================================================
1819 SMESHGUI::SMESHGUI() :
1820 SalomeApp_Module( "SMESH" ),
1821 LightApp_Module( "SMESH" )
1823 if ( CORBA::is_nil( myComponentSMESH ) )
1825 CORBA::Boolean anIsEmbeddedMode;
1826 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1827 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1829 // 0019923: EDF 765 SMESH : default values of hypothesis
1830 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1831 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1832 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1833 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1834 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1836 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1837 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1838 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1840 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1841 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1845 myActiveDialogBox = 0;
1846 myFilterLibraryDlg = 0;
1850 myEventCallbackCommand = vtkCallbackCommand::New();
1851 myEventCallbackCommand->Delete();
1852 myEventCallbackCommand->SetClientData( this );
1853 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1856 SMESH::GetFilterManager();
1857 SMESH::GetPattern();
1858 SMESH::GetMeasurements();
1860 /* load resources for all available meshers */
1861 SMESH::InitAvailableHypotheses();
1864 //=============================================================================
1868 //=============================================================================
1869 SMESHGUI::~SMESHGUI()
1871 #ifdef WITHGENERICOBJ
1872 SMESH::GetFilterManager()->UnRegister();
1873 SMESH::GetMeasurements()->UnRegister();
1875 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1876 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1879 //=============================================================================
1883 //=============================================================================
1884 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1886 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1888 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1893 //=============================================================================
1897 //=============================================================================
1898 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1900 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1904 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1905 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1906 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1907 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1908 return autoUpdate && !exceeded;
1911 //=============================================================================
1915 //=============================================================================
1916 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1918 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1921 //=============================================================================
1925 //=============================================================================
1926 SMESHGUI* SMESHGUI::GetSMESHGUI()
1928 SMESHGUI* smeshMod = 0;
1929 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1932 CAM_Module* module = app->module( "Mesh" );
1933 smeshMod = dynamic_cast<SMESHGUI*>( module );
1936 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1938 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1941 _PTR(Study) aStudy = study->studyDS();
1943 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1952 Standard_EXPORT SMESHGUI* GetComponentGUI()
1954 return SMESHGUI::GetSMESHGUI();
1958 //=============================================================================
1962 //=============================================================================
1963 void SMESHGUI::SetState(int aState)
1968 //=============================================================================
1972 //=============================================================================
1973 void SMESHGUI::ResetState()
1978 //=============================================================================
1982 //=============================================================================
1983 void SMESHGUI::EmitSignalDeactivateDialog()
1985 emit SignalDeactivateActiveDialog();
1988 //=============================================================================
1992 //=============================================================================
1993 void SMESHGUI::EmitSignalStudyFrameChanged()
1995 emit SignalStudyFrameChanged();
1998 //=============================================================================
2002 //=============================================================================
2003 void SMESHGUI::EmitSignalCloseAllDialogs()
2005 emit SignalCloseAllDialogs();
2008 //=============================================================================
2012 //=============================================================================
2013 void SMESHGUI::EmitSignalVisibilityChanged()
2015 emit SignalVisibilityChanged();
2018 //=============================================================================
2022 //=============================================================================
2023 QDialog *SMESHGUI::GetActiveDialogBox()
2025 return myActiveDialogBox;
2028 //=============================================================================
2032 //=============================================================================
2033 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2035 myActiveDialogBox = (QDialog *) aDlg;
2039 //=============================================================================
2043 //=============================================================================
2044 SUIT_Desktop* SMESHGUI::desktop()
2046 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2048 return app->desktop();
2053 //=============================================================================
2057 //=============================================================================
2058 SalomeApp_Study* SMESHGUI::activeStudy()
2060 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2062 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2067 //=============================================================================
2071 //=============================================================================
2072 void SMESHGUI::Modified( bool theIsUpdateActions )
2074 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2075 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2076 appStudy->Modified();
2077 if( theIsUpdateActions )
2078 app->updateActions();
2083 //=============================================================================
2087 //=============================================================================
2088 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2090 /* Here the position is on the bottom right corner - 10 */
2091 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2093 SUIT_Desktop *PP = desktop();
2094 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2095 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2099 //=============================================================================
2103 //=============================================================================
2104 static int isStudyLocked(_PTR(Study) theStudy){
2105 return theStudy->GetProperties()->IsLocked();
2108 static bool checkLock(_PTR(Study) theStudy) {
2109 if (isStudyLocked(theStudy)) {
2110 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2111 QObject::tr("WRN_WARNING"),
2112 QObject::tr("WRN_STUDY_LOCKED") );
2118 //=======================================================================
2119 //function : CheckActiveStudyLocked
2121 //=======================================================================
2123 bool SMESHGUI::isActiveStudyLocked()
2125 _PTR(Study) aStudy = activeStudy()->studyDS();
2126 return checkLock( aStudy );
2129 //=============================================================================
2133 //=============================================================================
2134 bool SMESHGUI::OnGUIEvent( int theCommandID )
2136 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2140 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2141 SUIT_ResourceMgr* mgr = resourceMgr();
2145 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2146 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2149 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2150 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2152 //QAction* act = action( theCommandID );
2154 switch (theCommandID) {
2156 if(checkLock(aStudy)) break;
2167 if(checkLock(aStudy)) break;
2168 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2172 case 150: //MED FILE INFORMATION
2174 SALOME_ListIO selected;
2175 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2177 aSel->selectedObjects( selected );
2178 if( selected.Extent() )
2180 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2181 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2182 if ( !aMesh->_is_nil() )
2184 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2191 case 122: // EXPORT MED
2204 ::ExportMeshToFile(theCommandID);
2208 case 200: // SCALAR BAR
2210 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2211 SALOME_ListIO selected;
2213 aSel->selectedObjects( selected );
2215 if( selected.Extent() ) {
2216 Handle(SALOME_InteractiveObject) anIO = selected.First();
2217 if( anIO->hasEntry() ) {
2218 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2219 anActor->SetControlMode( SMESH_Actor::eNone );
2220 #ifndef DISABLE_PLOT2DVIEWER
2221 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2230 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2235 // dump control distribution data to the text file
2236 ::SaveDistribution();
2242 // show/ distribution
2243 ::ShowDistribution();
2247 #ifndef DISABLE_PLOT2DVIEWER
2250 // plot distribution
2251 ::PlotDistribution();
2262 ::DisableAutoColor();
2265 case 1134: // Clipping
2266 case 1133: // Tranparency
2267 case 1132: // Display preferences (colors, shrink size, line width, ...)
2274 ::SetDisplayMode(theCommandID, myMarkerMap);
2277 //2D quadratic representation
2280 ::SetDisplayMode(theCommandID, myMarkerMap);
2284 case 216: // 0D elements
2287 case 219: // Volumes
2288 case 220: // All Entity
2290 ::SetDisplayEntity(theCommandID);
2293 case 221: // Orientation of faces
2295 LightApp_SelectionMgr* mgr = selectionMgr();
2296 SALOME_ListIO selected; mgr->selectedObjects( selected );
2298 SALOME_ListIteratorOfListIO it(selected);
2299 for( ; it.More(); it.Next()) {
2300 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2301 if(anIObject->hasEntry()) {
2302 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2303 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2312 if(checkLock(aStudy)) break;
2314 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2317 SMESH::UpdateView();
2319 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2320 SMESH::OnVisuException();
2322 catch (...) { // PAL16774 (Crash after display of many groups)
2323 SMESH::OnVisuException();
2327 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2328 aSel->selectedObjects( l );
2329 aSel->setSelectedObjects( l );
2334 case 301: // DISPLAY
2335 case 302: // DISPLAY ONLY
2337 SMESH::EDisplaing anAction;
2338 switch (theCommandID) {
2339 case 300: anAction = SMESH::eErase; break;
2340 case 301: anAction = SMESH::eDisplay; break;
2341 case 302: anAction = SMESH::eDisplayOnly; break;
2344 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2345 SALOME_ListIO sel_objects, to_process;
2347 aSel->selectedObjects( sel_objects );
2349 if( theCommandID==302 )
2351 MESSAGE("anAction = SMESH::eDisplayOnly");
2352 startOperation( myEraseAll );
2355 extractContainers( sel_objects, to_process );
2358 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2362 SALOME_ListIteratorOfListIO It( to_process );
2363 for ( ; It.More(); It.Next()) {
2365 Handle(SALOME_InteractiveObject) IOS = It.Value();
2366 if (IOS->hasEntry()) {
2368 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2369 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2370 break; // PAL16774 (Crash after display of many groups)
2372 if (anAction == SMESH::eDisplayOnly)
2374 MESSAGE("anAction = SMESH::eDisplayOnly");
2375 anAction = SMESH::eDisplay;
2381 // PAL13338 + PAL15161 -->
2382 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2383 MESSAGE("anAction = SMESH::eDisplayOnly");
2384 SMESH::UpdateView();
2385 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2387 // PAL13338 + PAL15161 <--
2389 catch (...) { // PAL16774 (Crash after display of many groups)
2390 SMESH::OnVisuException();
2393 if (anAction == SMESH::eErase) {
2394 MESSAGE("anAction == SMESH::eErase");
2396 aSel->setSelectedObjects( l1 );
2399 aSel->setSelectedObjects( to_process );
2406 if(checkLock(aStudy)) break;
2409 EmitSignalDeactivateDialog();
2411 ( new SMESHGUI_NodesDlg( this ) )->show();
2414 SUIT_MessageBox::warning(desktop(),
2415 tr("SMESH_WRN_WARNING"),
2416 tr("SMESH_WRN_VIEWER_VTK"));
2421 case 2151: // FILTER
2425 EmitSignalDeactivateDialog();
2426 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2431 case 701: // COMPUTE MESH
2432 case 711: // PRECOMPUTE MESH
2433 case 712: // EVALUATE MESH
2434 case 713: // MESH ORDER
2435 case 702: // Create mesh
2436 case 703: // Create sub-mesh
2437 case 704: // Edit mesh/sub-mesh
2438 startOperation( theCommandID );
2440 case 705: // copy mesh
2442 if (checkLock(aStudy)) break;
2443 EmitSignalDeactivateDialog();
2444 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2447 case 710: // Build compound mesh
2449 if (checkLock(aStudy)) break;
2450 EmitSignalDeactivateDialog();
2451 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2455 case 407: // DIAGONAL INVERSION
2456 case 408: // Delete diagonal
2460 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2461 tr( "NOT_A_VTK_VIEWER" ) );
2465 if ( checkLock( aStudy ) )
2468 /*Standard_Boolean aRes;
2469 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2470 if ( aMesh->_is_nil() )
2472 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2473 tr( "SMESH_BAD_SELECTION" ) );
2477 EmitSignalDeactivateDialog();
2478 if ( theCommandID == 407 )
2479 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2481 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2484 case 409: // Change orientation
2485 case 410: // Union of triangles
2486 case 411: // Cutting of quadrangles
2487 case 419: // Splitting volumes into tetrahedra
2491 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2492 tr( "NOT_A_VTK_VIEWER" ) );
2496 if ( checkLock( aStudy ) )
2499 EmitSignalDeactivateDialog();
2500 SMESHGUI_MultiEditDlg* aDlg = NULL;
2501 if ( theCommandID == 409 )
2502 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2503 else if ( theCommandID == 410 )
2504 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2505 else if ( theCommandID == 419 )
2506 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2508 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2513 case 412: // Smoothing
2515 if(checkLock(aStudy)) break;
2517 EmitSignalDeactivateDialog();
2518 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2521 SUIT_MessageBox::warning(desktop(),
2522 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2526 case 413: // Extrusion
2528 if (checkLock(aStudy)) break;
2530 EmitSignalDeactivateDialog();
2531 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2533 SUIT_MessageBox::warning(desktop(),
2534 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2538 case 414: // Revolution
2540 if(checkLock(aStudy)) break;
2542 EmitSignalDeactivateDialog();
2543 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2546 SUIT_MessageBox::warning(desktop(),
2547 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2551 case 415: // Pattern mapping
2553 if ( checkLock( aStudy ) )
2557 EmitSignalDeactivateDialog();
2558 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2561 SUIT_MessageBox::warning(desktop(),
2562 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2566 case 416: // Extrusion along a path
2568 if (checkLock(aStudy)) break;
2570 EmitSignalDeactivateDialog();
2571 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2573 SUIT_MessageBox::warning(desktop(),
2574 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2578 case 417: // Convert mesh to quadratic
2579 case 418: // create 2D mesh from 3D
2580 case 420: // Reorient faces
2581 case 806: // CREATE GEO GROUP
2583 startOperation( theCommandID );
2586 case 801: // CREATE GROUP
2590 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2591 tr( "NOT_A_VTK_VIEWER" ) );
2595 if(checkLock(aStudy)) break;
2596 EmitSignalDeactivateDialog();
2597 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2599 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2600 SALOME_ListIO selected;
2602 aSel->selectedObjects( selected );
2604 int nbSel = selected.Extent();
2606 // check if mesh is selected
2607 aMesh = SMESH::GetMeshByIO( selected.First() );
2609 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2614 case 802: // CONSTRUCT GROUP
2618 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2619 tr( "NOT_A_VTK_VIEWER" ) );
2623 if(checkLock(aStudy)) break;
2624 EmitSignalDeactivateDialog();
2626 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2627 SALOME_ListIO selected;
2629 aSel->selectedObjects( selected );
2631 int nbSel = selected.Extent();
2633 // check if submesh is selected
2634 Handle(SALOME_InteractiveObject) IObject = selected.First();
2635 if (IObject->hasEntry()) {
2636 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2638 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2639 if (!aSubMesh->_is_nil()) {
2641 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2642 // get submesh elements list by types
2643 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2644 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2645 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2646 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2647 // create group for each type o elements
2648 QString aName = IObject->getName();
2649 QStringList anEntryList;
2650 if (aNodes->length() > 0) {
2651 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2652 aGroup->Add(aNodes.inout());
2653 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2654 anEntryList.append( aSObject->GetID().c_str() );
2656 if (aEdges->length() > 0) {
2657 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2658 aGroup->Add(aEdges.inout());
2659 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2660 anEntryList.append( aSObject->GetID().c_str() );
2662 if (aFaces->length() > 0) {
2663 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2664 aGroup->Add(aFaces.inout());
2665 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2666 anEntryList.append( aSObject->GetID().c_str() );
2668 if (aVolumes->length() > 0) {
2669 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2670 aGroup->Add(aVolumes.inout());
2671 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2672 anEntryList.append( aSObject->GetID().c_str() );
2675 anApp->browseObjects( anEntryList );
2677 catch(const SALOME::SALOME_Exception & S_ex){
2678 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2685 SUIT_MessageBox::warning(desktop(),
2686 tr("SMESH_WRN_WARNING"),
2687 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2692 case 803: // EDIT GROUP
2696 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2697 tr( "NOT_A_VTK_VIEWER" ) );
2701 if(checkLock(aStudy)) break;
2702 EmitSignalDeactivateDialog();
2704 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2705 SALOME_ListIO selected;
2707 aSel->selectedObjects( selected );
2709 SALOME_ListIteratorOfListIO It (selected);
2710 int nbSelectedGroups = 0;
2711 for ( ; It.More(); It.Next() )
2713 SMESH::SMESH_GroupBase_var aGroup =
2714 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2715 if (!aGroup->_is_nil()) {
2717 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2721 if (nbSelectedGroups == 0)
2723 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2729 case 804: // Add elements to group
2731 if(checkLock(aStudy)) break;
2732 if (myState == 800) {
2733 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2734 if (aDlg) aDlg->onAdd();
2739 case 805: // Remove elements from group
2741 if(checkLock(aStudy)) break;
2742 if (myState == 800) {
2743 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2744 if (aDlg) aDlg->onRemove();
2749 case 815: // Edit GEOM GROUP as standalone
2753 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2754 tr( "NOT_A_VTK_VIEWER" ) );
2758 if(checkLock(aStudy)) break;
2759 EmitSignalDeactivateDialog();
2761 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2762 SALOME_ListIO selected;
2764 aSel->selectedObjects( selected );
2766 SALOME_ListIteratorOfListIO It (selected);
2767 for ( ; It.More(); It.Next() )
2769 SMESH::SMESH_GroupOnGeom_var aGroup =
2770 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2771 if (!aGroup->_is_nil()) {
2772 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2777 SMESH::SMESH_GroupOnFilter_var aGroup =
2778 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2779 if (!aGroup->_is_nil()) {
2780 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2788 case 810: // Union Groups
2789 case 811: // Intersect groups
2790 case 812: // Cut groups
2794 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2795 tr( "NOT_A_VTK_VIEWER" ) );
2799 if ( checkLock( aStudy ) )
2802 EmitSignalDeactivateDialog();
2804 SMESHGUI_GroupOpDlg* aDlg = 0;
2805 if ( theCommandID == 810 )
2806 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2807 else if ( theCommandID == 811 )
2808 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2810 aDlg = new SMESHGUI_CutGroupsDlg( this );
2817 case 814: // Create groups of entities from existing groups of superior dimensions
2819 if ( checkLock( aStudy ) )
2822 EmitSignalDeactivateDialog();
2823 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2829 case 813: // Delete groups with their contents
2833 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2834 tr( "NOT_A_VTK_VIEWER" ) );
2838 if ( checkLock( aStudy ) )
2841 EmitSignalDeactivateDialog();
2843 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2847 case 900: // MESH INFOS
2848 case 903: // WHAT IS
2850 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2851 EmitSignalDeactivateDialog();
2852 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2853 SALOME_ListIO selected;
2855 aSel->selectedObjects( selected );
2857 if ( selected.Extent() > 1 ) { // a dlg for each IO
2858 SALOME_ListIteratorOfListIO It( selected );
2859 for ( ; It.More(); It.Next() ) {
2860 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2861 dlg->showInfo( It.Value() );
2866 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2872 case 904: // FIND ELEM
2874 startOperation( theCommandID );
2878 case 1100: // EDIT HYPOTHESIS
2880 if(checkLock(aStudy)) break;
2882 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2883 SALOME_ListIO selected;
2885 aSel->selectedObjects( selected );
2887 int nbSel = selected.Extent();
2890 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2891 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2893 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2894 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2895 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2896 if ( !aHypothesis->_is_nil() )
2899 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2900 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2902 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2912 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2914 if(checkLock(aStudy)) break;
2915 SUIT_OverrideCursor wc;
2917 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2918 SALOME_ListIO selected;
2920 aSel->selectedObjects( selected, QString::null, false );
2922 SALOME_ListIteratorOfListIO It(selected);
2923 for (int i = 0; It.More(); It.Next(), i++) {
2924 Handle(SALOME_InteractiveObject) IObject = It.Value();
2925 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2928 aSel->setSelectedObjects( l1 );
2934 case 4009: // ELEM0D
2936 case 4021: // TRIANGLE
2938 case 4023: // POLYGON
2942 case 4134: // PYRAMID
2943 case 4135: // OCTA12
2945 if(checkLock(aStudy)) break;
2947 EmitSignalDeactivateDialog();
2948 SMDSAbs_EntityType type = SMDSEntity_Edge;
2949 switch (theCommandID) {
2950 case 4008: type = SMDSEntity_Ball; break;
2951 case 4009: type = SMDSEntity_0D; break;
2952 case 4021: type = SMDSEntity_Triangle; break;
2953 case 4022: type = SMDSEntity_Quadrangle; break;
2954 case 4031: type = SMDSEntity_Tetra; break;
2955 case 4023: type = SMDSEntity_Polygon; break;
2956 case 4032: type = SMDSEntity_Hexa; break;
2957 case 4133: type = SMDSEntity_Penta; break;
2958 case 4134: type = SMDSEntity_Pyramid; break;
2959 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
2962 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
2965 SUIT_MessageBox::warning(desktop(),
2966 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2970 case 4033: // POLYHEDRON
2972 if(checkLock(aStudy)) break;
2974 EmitSignalDeactivateDialog();
2975 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
2978 SUIT_MessageBox::warning(SMESHGUI::desktop(),
2979 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2983 case 4034: // QUADRATIC EDGE
2984 case 4035: // QUADRATIC TRIANGLE
2985 case 4036: // QUADRATIC QUADRANGLE
2986 case 4136: // BIQUADRATIC QUADRANGLE
2987 case 4037: // QUADRATIC TETRAHEDRON
2988 case 4038: // QUADRATIC PYRAMID
2989 case 4039: // QUADRATIC PENTAHEDRON
2990 case 4040: // QUADRATIC HEXAHEDRON
2991 case 4140: // TRIQUADRATIC HEXAHEDRON
2993 if(checkLock(aStudy)) break;
2995 EmitSignalDeactivateDialog();
2996 SMDSAbs_EntityType type;
2998 switch (theCommandID) {
3000 type = SMDSEntity_Quad_Edge; break;
3002 type = SMDSEntity_Quad_Triangle; break;
3004 type = SMDSEntity_Quad_Quadrangle; break;
3006 type = SMDSEntity_BiQuad_Quadrangle; break;
3008 type = SMDSEntity_Quad_Tetra; break;
3010 type = SMDSEntity_Quad_Pyramid; break;
3012 type = SMDSEntity_Quad_Penta; break;
3014 type = SMDSEntity_Quad_Hexa;
3016 type = SMDSEntity_TriQuad_Hexa;
3020 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3023 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3024 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3028 case 4041: // REMOVES NODES
3030 if(checkLock(aStudy)) break;
3032 EmitSignalDeactivateDialog();
3033 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3036 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3037 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3041 case 4042: // REMOVES ELEMENTS
3043 if(checkLock(aStudy)) break;
3045 EmitSignalDeactivateDialog();
3046 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3050 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3051 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3055 case 4043: { // CLEAR_MESH
3057 if(checkLock(aStudy)) break;
3059 SALOME_ListIO selected;
3060 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3061 aSel->selectedObjects( selected );
3063 SUIT_OverrideCursor wc;
3064 SALOME_ListIteratorOfListIO It (selected);
3065 for ( ; It.More(); It.Next() )
3067 Handle(SALOME_InteractiveObject) IOS = It.Value();
3068 SMESH::SMESH_Mesh_var aMesh =
3069 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3070 if ( aMesh->_is_nil()) continue;
3072 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3074 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3075 SMESH::ModifiedMesh( aMeshSObj, false, true);
3076 // hide groups and submeshes
3077 _PTR(ChildIterator) anIter =
3078 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3079 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3081 _PTR(SObject) so = anIter->Value();
3082 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3085 catch (const SALOME::SALOME_Exception& S_ex){
3087 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3091 SMESH::UpdateView();
3095 case 4044: // REMOVE ORPHAN NODES
3097 if(checkLock(aStudy)) break;
3098 SALOME_ListIO selected;
3099 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3100 aSel->selectedObjects( selected );
3101 if ( selected.Extent() == 1 ) {
3102 Handle(SALOME_InteractiveObject) anIO = selected.First();
3103 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3104 if ( !aMesh->_is_nil() ) {
3105 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3106 tr( "SMESH_WARNING" ),
3107 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3108 SUIT_MessageBox::Yes |
3109 SUIT_MessageBox::No,
3110 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3113 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3114 int removed = aMeshEditor->RemoveOrphanNodes();
3115 SUIT_MessageBox::information(SMESHGUI::desktop(),
3116 tr("SMESH_INFORMATION"),
3117 tr("NB_NODES_REMOVED").arg(removed));
3118 if ( removed > 0 ) {
3119 SMESH::UpdateView();
3120 SMESHGUI::Modified();
3123 catch (const SALOME::SALOME_Exception& S_ex) {
3124 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3133 case 4051: // RENUMBERING NODES
3135 if(checkLock(aStudy)) break;
3137 EmitSignalDeactivateDialog();
3138 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3142 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3143 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3147 case 4052: // RENUMBERING ELEMENTS
3149 if(checkLock(aStudy)) break;
3151 EmitSignalDeactivateDialog();
3152 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3156 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3157 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3161 case 4061: // TRANSLATION
3163 if(checkLock(aStudy)) break;
3165 EmitSignalDeactivateDialog();
3166 ( new SMESHGUI_TranslationDlg( this ) )->show();
3169 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3170 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3174 case 4062: // ROTATION
3176 if(checkLock(aStudy)) break;
3178 EmitSignalDeactivateDialog();
3179 ( new SMESHGUI_RotationDlg( this ) )->show();
3182 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3183 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3187 case 4063: // SYMMETRY
3189 if(checkLock(aStudy)) break;
3191 EmitSignalDeactivateDialog();
3192 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3195 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3196 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3200 case 4064: // SEWING
3202 if(checkLock(aStudy)) break;
3204 EmitSignalDeactivateDialog();
3205 ( new SMESHGUI_SewingDlg( this ) )->show();
3208 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3209 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3213 case 4065: // MERGE NODES
3215 if(checkLock(aStudy)) break;
3217 EmitSignalDeactivateDialog();
3218 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3221 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3222 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3226 case 4066: // MERGE EQUAL ELEMENTS
3228 if (checkLock(aStudy)) break;
3230 EmitSignalDeactivateDialog();
3231 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3233 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3234 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3239 case 4067: // MAKE MESH PASS THROUGH POINT
3240 startOperation( 4067 );
3245 if(checkLock(aStudy)) break;
3247 EmitSignalDeactivateDialog();
3248 ( new SMESHGUI_ScaleDlg( this ) )->show();
3251 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3252 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3257 case 4069: // DUPLICATE NODES
3259 if(checkLock(aStudy)) break;
3261 EmitSignalDeactivateDialog();
3262 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3265 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3266 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3271 case 5105: // Library of selection filters
3273 static QList<int> aTypes;
3274 if ( aTypes.isEmpty() )
3276 aTypes.append( SMESH::NODE );
3277 aTypes.append( SMESH::EDGE );
3278 aTypes.append( SMESH::FACE );
3279 aTypes.append( SMESH::VOLUME );
3281 if (!myFilterLibraryDlg)
3282 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3283 else if (myFilterLibraryDlg->isHidden())
3284 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3285 myFilterLibraryDlg->raise();
3289 case 6017: // CONTROLS
3317 LightApp_SelectionMgr* mgr = selectionMgr();
3318 SALOME_ListIO selected; mgr->selectedObjects( selected );
3320 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3321 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3323 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3324 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3325 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3326 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3327 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3328 ::Control( theCommandID );
3333 SUIT_MessageBox::warning(desktop(),
3334 tr( "SMESH_WRN_WARNING" ),
3335 tr( "SMESH_BAD_SELECTION" ) );
3339 SUIT_MessageBox::warning(desktop(),
3340 tr( "SMESH_WRN_WARNING" ),
3341 tr( "NOT_A_VTK_VIEWER" ) );
3346 LightApp_SelectionMgr* mgr = selectionMgr();
3347 SALOME_ListIO selected; mgr->selectedObjects( selected );
3349 SALOME_ListIteratorOfListIO it(selected);
3350 for( ; it.More(); it.Next()) {
3351 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3352 if(anIObject->hasEntry()) {
3353 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3354 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3362 LightApp_SelectionMgr* mgr = selectionMgr();
3363 SALOME_ListIO selected; mgr->selectedObjects( selected );
3365 SALOME_ListIteratorOfListIO it(selected);
3366 for( ; it.More(); it.Next()) {
3367 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3368 if(anIObject->hasEntry())
3369 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3370 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3378 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3379 EmitSignalDeactivateDialog();
3380 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3386 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3387 //updateObjBrowser();
3391 //=============================================================================
3395 //=============================================================================
3396 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3401 //=============================================================================
3405 //=============================================================================
3406 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3411 //=============================================================================
3415 //=============================================================================
3416 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3421 //=============================================================================
3422 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3423 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3425 //=============================================================================
3426 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3427 SUIT_ViewWindow* wnd )
3429 if(theIO->hasEntry()){
3430 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3431 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3435 //=======================================================================
3436 // function : createSMESHAction
3438 //=======================================================================
3439 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3440 const int key, const bool toggle, const QString& shortcutAction )
3443 QWidget* parent = application()->desktop();
3444 SUIT_ResourceMgr* resMgr = resourceMgr();
3446 if ( !icon_id.isEmpty() )
3447 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3449 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3450 if ( !pix.isNull() )
3451 icon = QIcon( pix );
3453 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3454 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3455 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3457 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3458 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3461 //=======================================================================
3462 // function : createPopupItem
3464 //=======================================================================
3465 void SMESHGUI::createPopupItem( const int id,
3466 const QString& clients,
3467 const QString& types,
3468 const QString& theRule,
3473 parentId = popupMgr()->actionId( action( pId ) );
3475 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3476 popupMgr()->insert( action( id ), parentId, 0 );
3478 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3479 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3480 QString rule = "(%1) and (%2) and (%3)";
3481 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3482 if( clients.isEmpty() )
3483 rule = rule.arg( QString( "true" ) );
3485 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3486 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3489 bool cont = myRules.contains( id );
3491 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3493 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3494 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3497 //=======================================================================
3498 // function : initialize
3500 //=======================================================================
3501 void SMESHGUI::initialize( CAM_Application* app )
3503 SalomeApp_Module::initialize( app );
3505 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3507 /* Automatic Update flag */
3508 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3510 // ----- create actions --------------
3512 createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3513 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3514 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3515 createSMESHAction( 114, "NUM" );
3516 createSMESHAction( 115, "IMPORT_STL" );
3517 createSMESHAction( 116, "IMPORT_CGNS" );
3518 createSMESHAction( 117, "IMPORT_SAUV" );
3519 createSMESHAction( 121, "DAT" );
3520 createSMESHAction( 122, "MED" );
3521 createSMESHAction( 123, "UNV" );
3522 createSMESHAction( 140, "STL" );
3523 createSMESHAction( 142, "CGNS" );
3524 createSMESHAction( 144, "SAUV" );
3525 createSMESHAction( 124, "EXPORT_DAT" );
3526 createSMESHAction( 125, "EXPORT_MED" );
3527 createSMESHAction( 126, "EXPORT_UNV" );
3528 createSMESHAction( 141, "EXPORT_STL" );
3529 createSMESHAction( 143, "EXPORT_CGNS" );
3530 createSMESHAction( 145, "EXPORT_SAUV" );
3531 createSMESHAction( 150, "FILE_INFO" );
3532 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3533 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3534 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3535 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3536 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3537 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3538 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3539 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3540 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3541 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3542 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3543 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3544 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3545 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3546 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3547 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3548 createSMESHAction( 804, "ADD" );
3549 createSMESHAction( 805, "REMOVE" );
3550 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3551 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3552 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3553 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3554 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3555 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3556 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3557 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3558 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3559 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3560 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3561 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3562 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3563 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3564 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3565 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3566 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3567 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3568 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3569 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3570 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3571 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3572 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3573 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3574 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3575 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3576 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3577 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3578 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3579 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3580 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3581 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3582 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3583 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3584 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3585 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3586 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3587 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3588 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3589 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3590 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3591 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3592 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3593 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3594 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3595 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3596 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3597 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3598 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3599 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3600 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3601 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3602 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3603 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3604 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3605 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3606 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3607 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3608 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3609 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3610 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3611 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3612 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3613 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3614 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3615 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3616 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3617 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3618 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3619 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3620 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3621 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3622 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3623 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3624 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3625 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3626 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3627 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3628 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3629 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3630 createSMESHAction( 415, "MAP", "ICON_MAP" );
3631 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3632 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3633 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3634 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3635 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3636 createSMESHAction( 200, "RESET" );
3637 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3638 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3639 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3640 #ifndef DISABLE_PLOT2DVIEWER
3641 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3643 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3644 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3645 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3646 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3647 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3648 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3649 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3650 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3651 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3652 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3653 createSMESHAction( 220, "ALL" );
3654 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3656 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3657 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3659 createSMESHAction( 1100, "EDIT_HYPO" );
3660 createSMESHAction( 1102, "UNASSIGN" );
3661 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3662 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3663 createSMESHAction( 1131, "DISPMODE" );
3664 createSMESHAction( 1132, "COLORS" );
3665 createSMESHAction( 1133, "TRANSP" );
3666 createSMESHAction( 1134, "CLIP" );
3667 createSMESHAction( 1135, "DISP_ENT" );
3668 createSMESHAction( 1136, "AUTO_COLOR" );
3669 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3670 createSMESHAction( 2000, "CTRL" );
3672 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3673 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3675 createSMESHAction( 300, "HIDE" );
3676 createSMESHAction( 301, "SHOW" );
3677 createSMESHAction( 302, "DISPLAY_ONLY" );
3679 // ----- create menu --------------
3680 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3681 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3682 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3683 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3684 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3685 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3686 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3687 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3689 createMenu( separator(), fileId );
3691 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3692 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3693 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3694 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3695 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3696 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3697 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3698 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3699 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3700 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3702 createMenu( 111, importId, -1 );
3703 createMenu( 112, importId, -1 );
3704 createMenu( 113, importId, -1 );
3705 createMenu( 115, importId, -1 );
3707 createMenu( 116, importId, -1 );
3709 createMenu( 117, importId, -1 );
3710 createMenu( 121, exportId, -1 );
3711 createMenu( 122, exportId, -1 );
3712 createMenu( 123, exportId, -1 );
3713 createMenu( 140, exportId, -1 ); // export to STL
3715 createMenu( 142, exportId, -1 ); // export to CGNS
3717 createMenu( 144, exportId, -1 ); // export to SAUV
3718 createMenu( separator(), fileId, 10 );
3720 createMenu( 33, editId, -1 );
3722 createMenu( 5105, toolsId, -1 );
3724 createMenu( 702, meshId, -1 ); // "Mesh" menu
3725 createMenu( 703, meshId, -1 );
3726 createMenu( 704, meshId, -1 );
3727 createMenu( 710, meshId, -1 );
3728 createMenu( 705, meshId, -1 );
3729 createMenu( separator(), meshId, -1 );
3730 createMenu( 701, meshId, -1 );
3731 createMenu( 711, meshId, -1 );
3732 createMenu( 712, meshId, -1 );
3733 createMenu( 713, meshId, -1 );
3734 createMenu( separator(), meshId, -1 );
3735 createMenu( 801, meshId, -1 );
3736 createMenu( 806, meshId, -1 );
3737 createMenu( 802, meshId, -1 );
3738 createMenu( 803, meshId, -1 );
3739 createMenu( 815, meshId, -1 );
3740 createMenu( separator(), meshId, -1 );
3741 createMenu( 810, meshId, -1 );
3742 createMenu( 811, meshId, -1 );
3743 createMenu( 812, meshId, -1 );
3744 createMenu( separator(), meshId, -1 );
3745 createMenu( 814, meshId, -1 );
3746 createMenu( separator(), meshId, -1 );
3747 createMenu( 900, meshId, -1 );
3748 //createMenu( 902, meshId, -1 );
3749 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3750 createMenu( 904, meshId, -1 );
3751 createMenu( separator(), meshId, -1 );
3753 createMenu( 6005, nodeId, -1 );
3754 createMenu( 6028, nodeId, -1 );
3755 createMenu( 6002, edgeId, -1 );
3756 createMenu( 6003, edgeId, -1 );
3757 createMenu( 6001, edgeId, -1 );
3758 createMenu( 6004, edgeId, -1 );
3759 createMenu( 6029, edgeId, -1 );
3760 createMenu( 6021, faceId, -1 );
3761 createMenu( 6025, faceId, -1 );
3762 createMenu( 6027, faceId, -1 );
3763 createMenu( 6018, faceId, -1 );
3764 createMenu( 6019, faceId, -1 );
3765 createMenu( 6011, faceId, -1 );
3766 createMenu( 6012, faceId, -1 );
3767 createMenu( 6013, faceId, -1 );
3768 createMenu( 6014, faceId, -1 );
3769 createMenu( 6015, faceId, -1 );
3770 createMenu( 6016, faceId, -1 );
3771 createMenu( 6022, faceId, -1 );
3772 createMenu( 6030, faceId, -1 );
3773 createMenu( 6017, volumeId, -1 );
3774 createMenu( 6009, volumeId, -1 );
3775 createMenu( 6023, volumeId, -1 );
3776 createMenu( 6024, volumeId, -1 );
3777 createMenu( 6026, volumeId, -1 );
3778 createMenu( 6031, volumeId, -1 );
3780 createMenu( 4000, addId, -1 );
3781 createMenu( 4009, addId, -1 );
3782 createMenu( 4008, addId, -1 );
3783 createMenu( 4010, addId, -1 );
3784 createMenu( 4021, addId, -1 );
3785 createMenu( 4022, addId, -1 );
3786 createMenu( 4023, addId, -1 );
3787 createMenu( 4031, addId, -1 );
3788 createMenu( 4032, addId, -1 );
3789 createMenu( 4133, addId, -1 );
3790 createMenu( 4134, addId, -1 );
3791 createMenu( 4135, addId, -1 );
3792 createMenu( 4033, addId, -1 );
3793 createMenu( separator(), addId, -1 );
3794 createMenu( 4034, addId, -1 );
3795 createMenu( 4035, addId, -1 );
3796 createMenu( 4036, addId, -1 );
3797 createMenu( 4136, addId, -1 );
3798 createMenu( 4037, addId, -1 );
3799 createMenu( 4038, addId, -1 );
3800 createMenu( 4039, addId, -1 );
3801 createMenu( 4040, addId, -1 );
3802 createMenu( 4140, addId, -1 );
3804 createMenu( 4041, removeId, -1 );
3805 createMenu( 4042, removeId, -1 );
3806 createMenu( 4044, removeId, -1 );
3807 createMenu( separator(), removeId, -1 );
3808 createMenu( 813, removeId, -1 );
3809 createMenu( separator(), removeId, -1 );
3810 createMenu( 4043, removeId, -1 );
3812 createMenu( 4051, renumId, -1 );
3813 createMenu( 4052, renumId, -1 );
3815 createMenu( 4061, transfId, -1 );
3816 createMenu( 4062, transfId, -1 );
3817 createMenu( 4063, transfId, -1 );
3818 createMenu( 4068, transfId, -1 );
3819 createMenu( 4064, transfId, -1 );
3820 createMenu( 4065, transfId, -1 );
3821 createMenu( 4066, transfId, -1 );
3822 createMenu( 4069, transfId, -1 );
3824 createMenu( 4067,modifyId, -1 );
3825 createMenu( 407, modifyId, -1 );
3826 createMenu( 408, modifyId, -1 );
3827 createMenu( 409, modifyId, -1 );
3828 createMenu( 420, modifyId, -1 );
3829 createMenu( 410, modifyId, -1 );
3830 createMenu( 411, modifyId, -1 );
3831 createMenu( 419, modifyId, -1 );
3832 createMenu( 412, modifyId, -1 );
3833 createMenu( 413, modifyId, -1 );
3834 createMenu( 416, modifyId, -1 );
3835 createMenu( 414, modifyId, -1 );
3836 createMenu( 415, modifyId, -1 );
3837 createMenu( 417, modifyId, -1 );
3838 createMenu( 418, modifyId, -1 );
3840 createMenu( 501, measureId, -1 );
3841 createMenu( 502, measureId, -1 );
3842 createMenu( 214, viewId, -1 );
3844 // ----- create toolbars --------------
3845 int meshTb = createTool( tr( "TB_MESH" ) ),
3846 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3847 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3848 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3849 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3851 createTool( 702, meshTb );
3852 createTool( 703, meshTb );
3853 createTool( 704, meshTb );
3854 createTool( 710, meshTb );
3855 createTool( 705, meshTb );
3856 createTool( separator(), meshTb );
3857 createTool( 701, meshTb );
3858 createTool( 711, meshTb );
3859 createTool( 712, meshTb );
3860 createTool( 713, meshTb );
3861 createTool( separator(), meshTb );
3862 createTool( 801, meshTb );
3863 createTool( 806, meshTb );
3864 createTool( 802, meshTb );
3865 createTool( 803, meshTb );
3866 //createTool( 815, meshTb );
3867 createTool( separator(), meshTb );
3868 createTool( 900, meshTb );
3869 //createTool( 902, meshTb );
3870 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3871 createTool( 904, meshTb );
3872 createTool( separator(), meshTb );
3874 createTool( 6005, ctrlTb );
3875 createTool( 6028, ctrlTb );
3876 createTool( separator(), ctrlTb );
3877 createTool( 6002, ctrlTb );
3878 createTool( 6003, ctrlTb );
3879 createTool( 6001, ctrlTb );
3880 createTool( 6004, ctrlTb );
3881 createTool( 6029, ctrlTb );
3882 createTool( separator(), ctrlTb );
3883 createTool( 6021, ctrlTb );
3884 createTool( 6025, ctrlTb );
3885 createTool( 6027, ctrlTb );
3886 createTool( 6018, ctrlTb );
3887 createTool( 6019, ctrlTb );
3888 createTool( 6011, ctrlTb );
3889 createTool( 6012, ctrlTb );
3890 createTool( 6013, ctrlTb );
3891 createTool( 6014, ctrlTb );
3892 createTool( 6015, ctrlTb );
3893 createTool( 6016, ctrlTb );
3894 createTool( 6022, ctrlTb );
3895 createTool( 6030, ctrlTb );
3896 createTool( separator(), ctrlTb );
3897 createTool( 6017, ctrlTb );
3898 createTool( 6009, ctrlTb );
3899 createTool( 6023, ctrlTb );
3900 createTool( 6024, ctrlTb );
3901 createTool( 6026, ctrlTb );
3902 createTool( 6031, ctrlTb );
3903 createTool( separator(), ctrlTb );
3905 createTool( 4000, addRemTb );
3906 createTool( 4009, addRemTb );
3907 createTool( 4008, addRemTb );
3908 createTool( 4010, addRemTb );
3909 createTool( 4021, addRemTb );
3910 createTool( 4022, addRemTb );
3911 createTool( 4023, addRemTb );
3912 createTool( 4031, addRemTb );
3913 createTool( 4032, addRemTb );
3914 createTool( 4133, addRemTb );
3915 createTool( 4134, addRemTb );
3916 createTool( 4135, addRemTb );
3917 createTool( 4033, addRemTb );
3918 createTool( separator(), addRemTb );
3919 createTool( 4034, addRemTb );
3920 createTool( 4035, addRemTb );
3921 createTool( 4036, addRemTb );
3922 createTool( 4136, addRemTb );
3923 createTool( 4037, addRemTb );
3924 createTool( 4038, addRemTb );
3925 createTool( 4039, addRemTb );
3926 createTool( 4040, addRemTb );
3927 createTool( 4140, addRemTb );
3928 createTool( separator(), addRemTb );
3929 createTool( 4041, addRemTb );
3930 createTool( 4042, addRemTb );
3931 createTool( 4044, addRemTb );
3932 createTool( 4043, addRemTb );
3933 createTool( separator(), addRemTb );
3934 createTool( 4051, addRemTb );
3935 createTool( 4052, addRemTb );
3936 createTool( separator(), addRemTb );
3937 createTool( 4061, addRemTb );
3938 createTool( 4062, addRemTb );
3939 createTool( 4063, addRemTb );
3940 createTool( 4068, addRemTb );
3941 createTool( 4064, addRemTb );
3942 createTool( 4065, addRemTb );
3943 createTool( 4066, addRemTb );
3944 createTool( 4069, addRemTb );
3945 createTool( separator(), addRemTb );
3947 createTool( 4067,modifyTb );
3948 createTool( 407, modifyTb );
3949 createTool( 408, modifyTb );
3950 createTool( 409, modifyTb );
3951 createTool( 420, modifyTb );
3952 createTool( 410, modifyTb );
3953 createTool( 411, modifyTb );
3954 createTool( 419, modifyTb );
3955 createTool( 412, modifyTb );
3956 createTool( 413, modifyTb );
3957 createTool( 416, modifyTb );
3958 createTool( 414, modifyTb );
3959 createTool( 415, modifyTb );
3960 createTool( 417, modifyTb );
3961 createTool( 418, modifyTb );
3963 createTool( 214, dispModeTb );
3965 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3966 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
3969 QString OB = "'ObjectBrowser'",
3970 View = "'" + SVTK_Viewer::Type() + "'",
3972 mesh = pat.arg( SMESHGUI_Selection::typeName( MESH ) ),
3973 group = pat.arg( SMESHGUI_Selection::typeName( GROUP ) ),
3974 hypo = pat.arg( SMESHGUI_Selection::typeName( HYPOTHESIS ) ),
3975 algo = pat.arg( SMESHGUI_Selection::typeName( ALGORITHM ) ),
3976 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
3977 arg( SMESHGUI_Selection::typeName( SUBMESH_VERTEX ) ).
3978 arg( SMESHGUI_Selection::typeName( SUBMESH_EDGE ) ).
3979 arg( SMESHGUI_Selection::typeName( SUBMESH_FACE ) ).
3980 arg( SMESHGUI_Selection::typeName( SUBMESH_SOLID ) ).
3981 arg( SMESHGUI_Selection::typeName( SUBMESH_COMPOUND ) ).
3982 arg( SMESHGUI_Selection::typeName( SUBMESH ) ),
3984 mesh_part = mesh + " " + subMesh + " " + group,
3985 mesh_group = mesh + " " + group,
3986 hyp_alg = hypo + " " + algo;
3988 // popup for object browser
3990 isInvisible("not( isVisible )"),
3991 isEmpty("numberOfNodes = 0"),
3992 isNotEmpty("numberOfNodes <> 0"),
3994 // has nodes, edges, etc in VISIBLE! actor
3995 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
3996 hasElems("(count( elemTypes ) > 0)"),
3997 hasDifferentElems("(count( elemTypes ) > 1)"),
3998 hasBalls("({'BallElem'} in elemTypes)"),
3999 hasElems0d("({'Elem0d'} in elemTypes)"),
4000 hasEdges("({'Edge'} in elemTypes)"),
4001 hasFaces("({'Face'} in elemTypes)"),
4002 hasVolumes("({'Volume'} in elemTypes)");
4004 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4005 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4006 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4007 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4008 createPopupItem( 803, OB, group ); // EDIT_GROUP
4009 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4011 popupMgr()->insert( separator(), -1, 0 );
4012 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4013 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4014 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4015 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4016 createPopupItem( 214, OB, mesh_part ); // UPDATE
4017 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4018 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4019 popupMgr()->insert( separator(), -1, 0 );
4020 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4021 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4022 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4023 popupMgr()->insert( separator(), -1, 0 );
4024 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4025 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4026 popupMgr()->insert( separator(), -1, 0 );
4027 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4028 popupMgr()->insert( separator(), -1, 0 );
4029 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4030 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4032 popupMgr()->insert( separator(), -1, 0 );
4034 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4035 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4036 QString only_one_2D = only_one_non_empty + " && dim>1";
4038 createPopupItem( 125, OB, mesh_group, multiple_non_empty ); // EXPORT_MED
4039 createPopupItem( 126, OB, mesh_group, only_one_non_empty ); // EXPORT_UNV
4040 createPopupItem( 141, OB, mesh_group, only_one_2D ); // EXPORT_STL
4042 createPopupItem( 143, OB, mesh_group, multiple_non_empty ); // EXPORT_CGNS
4044 createPopupItem( 145, OB, mesh_group, multiple_non_empty ); // EXPORT_SAUV
4045 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4046 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4047 popupMgr()->insert( separator(), -1, 0 );
4050 createPopupItem( 803, View, group ); // EDIT_GROUP
4051 createPopupItem( 804, View, elems ); // ADD
4052 createPopupItem( 805, View, elems ); // REMOVE
4054 popupMgr()->insert( separator(), -1, 0 );
4055 createPopupItem( 214, View, mesh_part ); // UPDATE
4056 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4057 createPopupItem( 904, View, mesh ); // FIND_ELEM
4058 popupMgr()->insert( separator(), -1, 0 );
4060 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4061 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4062 popupMgr()->insert( separator(), -1, 0 );
4065 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4066 QString aType = QString( "%1type in {%2}" ).arg( lc );
4067 aType = aType.arg( mesh_part );
4068 QString aMeshInVTK = aClient + "&&" + aType;
4070 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4071 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4072 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4074 //-------------------------------------------------
4076 //-------------------------------------------------
4077 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4079 popupMgr()->insert( action( 9010 ), anId, -1 );
4080 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4081 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4083 popupMgr()->insert( action( 9011 ), anId, -1 );
4084 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4085 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4087 popupMgr()->insert( separator(), -1, -1 );
4089 //-------------------------------------------------
4091 //-------------------------------------------------
4092 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4094 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4095 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4096 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4098 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4099 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4100 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4102 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4103 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4104 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4106 popupMgr()->insert( separator(), anId, -1 );
4108 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4109 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4110 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4112 //-------------------------------------------------
4114 //-------------------------------------------------
4115 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4117 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4119 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4120 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4121 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4123 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4124 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4125 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4127 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4128 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4129 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4131 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4132 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4133 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4135 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4136 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4137 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4139 popupMgr()->insert( separator(), anId, -1 );
4141 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4142 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4145 //-------------------------------------------------
4146 // Representation of the 2D Quadratic elements
4147 //-------------------------------------------------
4148 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4149 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4150 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4151 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4153 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4154 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4155 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4157 //-------------------------------------------------
4158 // Orientation of faces
4159 //-------------------------------------------------
4160 popupMgr()->insert( action( 221 ), -1, -1 );
4161 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4162 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4164 //-------------------------------------------------
4166 //-------------------------------------------------
4167 popupMgr()->insert( action( 1132 ), -1, -1 );
4168 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4170 //-------------------------------------------------
4172 //-------------------------------------------------
4173 popupMgr()->insert( action( 1133 ), -1, -1 );
4174 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4176 //-------------------------------------------------
4178 //-------------------------------------------------
4180 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4181 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4182 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4183 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4185 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4187 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4188 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4190 popupMgr()->insert( separator(), anId, -1 );
4192 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4194 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4195 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4196 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4198 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4199 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4200 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4202 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4204 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4205 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4206 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4208 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4209 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4210 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4212 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4213 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4214 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4216 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4217 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4218 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4219 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4220 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4221 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4223 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4225 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4226 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4227 QtxPopupMgr::VisibleRule );
4228 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4230 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4231 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4232 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4234 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4235 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4236 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4238 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4239 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4240 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4242 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4243 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4244 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4246 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4247 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4248 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4250 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4251 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4252 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4254 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4255 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4256 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4258 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4259 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4260 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4262 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4263 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4264 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4266 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4267 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4268 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4270 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4271 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4272 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4273 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4274 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4275 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4277 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4279 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4280 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4281 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4283 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4284 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4285 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4287 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4288 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4289 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4291 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4292 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4293 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4295 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4296 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4297 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4299 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4300 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4301 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4303 popupMgr()->insert( separator(), anId, -1 );
4305 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4306 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4308 popupMgr()->insert( separator(), anId, -1 );
4310 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4312 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4313 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4315 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4316 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4317 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4319 #ifndef DISABLE_PLOT2DVIEWER
4320 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4321 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4324 //-------------------------------------------------
4326 //-------------------------------------------------
4327 popupMgr()->insert( separator(), -1, -1 );
4328 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4329 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4330 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4331 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4333 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4334 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4336 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4337 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4339 popupMgr()->insert( separator(), -1, -1 );
4341 //-------------------------------------------------
4343 //-------------------------------------------------
4344 popupMgr()->insert( action( 1134 ), -1, -1 );
4345 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4347 popupMgr()->insert( separator(), -1, -1 );
4349 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4350 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4352 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4353 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4356 //================================================================================
4358 * \brief Return true if SMESH or GEOM objects are selected.
4359 * Is called form LightApp_Module::activateModule() which clear selection if
4360 * not isSelectionCompatible()
4362 //================================================================================
4364 bool SMESHGUI::isSelectionCompatible()
4366 bool isCompatible = true;
4367 SALOME_ListIO selected;
4368 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4369 Sel->selectedObjects( selected );
4371 SALOME_ListIteratorOfListIO It( selected );
4372 for ( ; isCompatible && It.More(); It.Next())
4374 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4375 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4377 return isCompatible;
4381 bool SMESHGUI::reusableOperation( const int id )
4383 // compute, evaluate and precompute are not reusable operations
4384 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4387 bool SMESHGUI::activateModule( SUIT_Study* study )
4389 bool res = SalomeApp_Module::activateModule( study );
4391 setMenuShown( true );
4392 setToolShown( true );
4394 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4395 PyGILState_STATE gstate = PyGILState_Ensure();
4396 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4397 if(pluginsmanager==NULL)
4401 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4406 PyGILState_Release(gstate);
4407 // end of GEOM plugins loading
4409 // Reset actions accelerator keys
4410 action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4411 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4412 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4414 action( 33)->setEnabled(true); // Delete: Key_Delete
4416 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4417 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4418 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4419 if ( _PTR(Study) aStudy = s->studyDS()) {
4420 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4421 updateObjBrowser(); // objects can be removed
4424 // get all view currently opened in the study and connect their signals to
4425 // the corresponding slots of the class.
4426 SUIT_Desktop* aDesk = study->application()->desktop();
4428 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4429 SUIT_ViewWindow* wnd;
4430 foreach ( wnd, wndList )
4437 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4439 setMenuShown( false );
4440 setToolShown( false );
4442 EmitSignalCloseAllDialogs();
4444 // Unset actions accelerator keys
4445 action(111)->setShortcut(QKeySequence()); // Import DAT
4446 action(112)->setShortcut(QKeySequence()); // Import UNV
4447 action(113)->setShortcut(QKeySequence()); // Import MED
4449 action( 33)->setEnabled(false); // Delete: Key_Delete
4451 return SalomeApp_Module::deactivateModule( study );
4454 void SMESHGUI::studyClosed( SUIT_Study* s )
4456 SMESH::RemoveVisuData( s->id() );
4457 SalomeApp_Module::studyClosed( s );
4460 void SMESHGUI::OnGUIEvent()
4462 const QObject* obj = sender();
4463 if ( !obj || !obj->inherits( "QAction" ) )
4465 int id = actionId((QAction*)obj);
4470 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4472 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4473 if ( CORBA::is_nil( myComponentSMESH ) )
4475 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4477 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4478 return aGUI.myComponentSMESH;
4481 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4482 return myComponentSMESH;
4485 QString SMESHGUI::engineIOR() const
4487 CORBA::ORB_var anORB = getApp()->orb();
4488 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4489 return QString( anIOR.in() );
4492 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4494 SalomeApp_Module::contextMenuPopup( client, menu, title );
4496 selectionMgr()->selectedObjects( lst );
4497 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4498 Handle(SALOME_InteractiveObject) io = lst.First();
4499 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4500 _PTR(Study) study = appStudy->studyDS();
4501 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4503 QString aName = QString( obj->GetName().c_str() );
4504 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4505 aName.remove( (aName.length() - 1), 1 );
4511 LightApp_Selection* SMESHGUI::createSelection() const
4513 return new SMESHGUI_Selection();
4516 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4518 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4519 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4522 void SMESHGUI::viewManagers( QStringList& list ) const
4524 list.append( SVTK_Viewer::Type() );
4527 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4529 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4530 SMESH::UpdateSelectionProp( this );
4532 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4533 for(int i = 0; i < aViews.count() ; i++){
4534 SUIT_ViewWindow *sf = aViews[i];
4540 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4542 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4543 myClippingPlaneInfoMap.erase( theViewManager );
4546 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4548 theActor->AddObserver( SMESH::DeleteActorEvent,
4549 myEventCallbackCommand.GetPointer(),
4553 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4554 unsigned long theEvent,
4555 void* theClientData,
4558 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4559 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4560 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4561 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4562 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4563 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4564 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4565 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4566 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4567 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4568 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4569 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4570 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4571 if( anActor == *anIter3 ) {
4572 anActorList.erase( anIter3 );
4583 void SMESHGUI::createPreferences()
4585 // General tab ------------------------------------------------------------------------
4586 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4588 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4589 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4590 setPreferenceProperty( lim, "min", 0 );
4591 setPreferenceProperty( lim, "max", 100000000 );
4592 setPreferenceProperty( lim, "step", 1000 );
4593 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4595 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4596 setPreferenceProperty( qaGroup, "columns", 2 );
4597 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4598 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4599 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4600 setPreferenceProperty( prec, "min", 0 );
4601 setPreferenceProperty( prec, "max", 16 );
4602 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4603 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4604 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4605 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4606 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4608 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4609 setPreferenceProperty( dispgroup, "columns", 2 );
4610 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4612 modes.append( tr("MEN_WIRE") );
4613 modes.append( tr("MEN_SHADE") );
4614 modes.append( tr("MEN_NODES") );
4615 modes.append( tr("MEN_SHRINK") );
4616 QList<QVariant> indices;
4617 indices.append( 0 );
4618 indices.append( 1 );
4619 indices.append( 2 );
4620 indices.append( 3 );
4621 setPreferenceProperty( dispmode, "strings", modes );
4622 setPreferenceProperty( dispmode, "indexes", indices );
4624 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4625 setPreferenceProperty( arcgroup, "columns", 2 );
4626 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4627 QStringList quadraticModes;
4628 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4629 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4631 indices.append( 0 );
4632 indices.append( 1 );
4633 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4634 setPreferenceProperty( quadraticmode, "indexes", indices );
4636 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4637 "SMESH", "max_angle" );
4638 setPreferenceProperty( maxAngle, "min", 1 );
4639 setPreferenceProperty( maxAngle, "max", 90 );
4643 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4644 setPreferenceProperty( exportgroup, "columns", 2 );
4645 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4646 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4648 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4649 setPreferenceProperty( computeGroup, "columns", 2 );
4650 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4652 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4653 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4654 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4656 indices.append( 0 );
4657 indices.append( 1 );
4658 indices.append( 2 );
4659 setPreferenceProperty( notifyMode, "strings", modes );
4660 setPreferenceProperty( notifyMode, "indexes", indices );
4662 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4663 setPreferenceProperty( infoGroup, "columns", 4 );
4664 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4666 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4667 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4669 indices.append( 0 );
4670 indices.append( 1 );
4671 setPreferenceProperty( elemInfo, "strings", modes );
4672 setPreferenceProperty( elemInfo, "indexes", indices );
4673 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4674 setPreferenceProperty( nodesLim, "min", 0 );
4675 setPreferenceProperty( nodesLim, "max", 10000000 );
4676 setPreferenceProperty( nodesLim, "step", 10000 );
4677 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4679 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4680 setPreferenceProperty( segGroup, "columns", 2 );
4681 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4682 "SMESH", "segmentation" );
4683 setPreferenceProperty( segLen, "min", 1 );
4684 setPreferenceProperty( segLen, "max", 10000000 );
4685 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4686 "SMESH", "nb_segments_per_edge" );
4687 setPreferenceProperty( nbSeg, "min", 1 );
4688 setPreferenceProperty( nbSeg, "max", 10000000 );
4690 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4691 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4692 "SMESH", "forget_mesh_on_hyp_modif" );
4695 // Quantities with individual precision settings
4696 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4697 setPreferenceProperty( precGroup, "columns", 2 );
4699 const int nbQuantities = 6;
4700 int precs[nbQuantities], ii = 0;
4701 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4702 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4703 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4704 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4705 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4706 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4707 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4708 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4709 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4710 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4711 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4712 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4714 // Set property for precision value for spinboxes
4715 for ( ii = 0; ii < nbQuantities; ii++ ){
4716 setPreferenceProperty( precs[ii], "min", -14 );
4717 setPreferenceProperty( precs[ii], "max", 14 );
4718 setPreferenceProperty( precs[ii], "precision", 2 );
4721 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4722 setPreferenceProperty( previewGroup, "columns", 2 );
4723 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4724 setPreferenceProperty( chunkSize, "min", 0 );
4725 setPreferenceProperty( chunkSize, "max", 1000 );
4726 setPreferenceProperty( chunkSize, "step", 50 );
4728 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4729 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4731 // Mesh tab ------------------------------------------------------------------------
4732 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4733 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4734 setPreferenceProperty( nodeGroup, "columns", 3 );
4736 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4738 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4740 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4741 QList<QVariant> aMarkerTypeIndicesList;
4742 QList<QVariant> aMarkerTypeIconsList;
4743 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4744 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4745 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4746 aMarkerTypeIndicesList << i;
4747 aMarkerTypeIconsList << pixmap;
4749 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4750 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4752 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4754 QList<QVariant> aMarkerScaleIndicesList;
4755 QStringList aMarkerScaleValuesList;
4756 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4757 aMarkerScaleIndicesList << i;
4758 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4760 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4761 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4763 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4764 setPreferenceProperty( elemGroup, "columns", 2 );
4766 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4767 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4768 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
4769 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4770 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4772 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4774 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4775 setPreferenceProperty( grpGroup, "columns", 2 );
4777 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4779 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4780 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4781 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
4782 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
4783 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4784 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4785 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4786 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4788 setPreferenceProperty( size0d, "min", 1 );
4789 setPreferenceProperty( size0d, "max", 10 );
4791 setPreferenceProperty( ballSize, "min", 1 );
4792 setPreferenceProperty( ballSize, "max", 10 );
4794 setPreferenceProperty( elemW, "min", 1 );
4795 setPreferenceProperty( elemW, "max", 5 );
4797 setPreferenceProperty( shrink, "min", 0 );
4798 setPreferenceProperty( shrink, "max", 100 );
4800 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4801 setPreferenceProperty( orientGroup, "columns", 1 );
4803 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4804 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4806 setPreferenceProperty( orientScale, "min", 0.05 );
4807 setPreferenceProperty( orientScale, "max", 0.5 );
4808 setPreferenceProperty( orientScale, "step", 0.05 );
4810 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4812 // Selection tab ------------------------------------------------------------------------
4813 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4815 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4816 setPreferenceProperty( selGroup, "columns", 2 );
4818 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4819 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4821 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4822 setPreferenceProperty( preGroup, "columns", 2 );
4824 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4826 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4827 setPreferenceProperty( precSelGroup, "columns", 2 );
4829 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4830 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4831 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4833 // Scalar Bar tab ------------------------------------------------------------------------
4834 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4835 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4836 setPreferenceProperty( fontGr, "columns", 2 );
4838 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4839 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4841 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4842 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4844 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4845 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4847 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4848 setPreferenceProperty( numcol, "min", 2 );
4849 setPreferenceProperty( numcol, "max", 256 );
4851 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4852 setPreferenceProperty( numlab, "min", 2 );
4853 setPreferenceProperty( numlab, "max", 65 );
4855 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4856 setPreferenceProperty( orientGr, "columns", 2 );
4857 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4858 QStringList orients;
4859 orients.append( tr( "SMESH_VERTICAL" ) );
4860 orients.append( tr( "SMESH_HORIZONTAL" ) );
4861 indices.clear(); indices.append( 0 ); indices.append( 1 );
4862 setPreferenceProperty( orient, "strings", orients );
4863 setPreferenceProperty( orient, "indexes", indices );
4865 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4866 setPreferenceProperty( posVSizeGr, "columns", 2 );
4867 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4868 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4869 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4870 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4871 setPreferenceProperty( xv, "step", 0.1 );
4872 setPreferenceProperty( xv, "min", 0.0 );
4873 setPreferenceProperty( xv, "max", 1.0 );
4874 setPreferenceProperty( yv, "step", 0.1 );
4875 setPreferenceProperty( yv, "min", 0.0 );
4876 setPreferenceProperty( yv, "max", 1.0 );
4877 setPreferenceProperty( wv, "step", 0.1 );
4878 setPreferenceProperty( wv, "min", 0.0 );
4879 setPreferenceProperty( wv, "max", 1.0 );
4880 setPreferenceProperty( hv, "min", 0.0 );
4881 setPreferenceProperty( hv, "max", 1.0 );
4882 setPreferenceProperty( hv, "step", 0.1 );
4884 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4885 setPreferenceProperty( posHSizeGr, "columns", 2 );
4886 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4887 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4888 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4889 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4890 setPreferenceProperty( xv, "min", 0.0 );
4891 setPreferenceProperty( xv, "max", 1.0 );
4892 setPreferenceProperty( xv, "step", 0.1 );
4893 setPreferenceProperty( xh, "min", 0.0 );
4894 setPreferenceProperty( xh, "max", 1.0 );
4895 setPreferenceProperty( xh, "step", 0.1 );
4896 setPreferenceProperty( yh, "min", 0.0 );
4897 setPreferenceProperty( yh, "max", 1.0 );
4898 setPreferenceProperty( yh, "step", 0.1 );
4899 setPreferenceProperty( wh, "min", 0.0 );
4900 setPreferenceProperty( wh, "max", 1.0 );
4901 setPreferenceProperty( wh, "step", 0.1 );
4902 setPreferenceProperty( hh, "min", 0.0 );
4903 setPreferenceProperty( hh, "max", 1.0 );
4904 setPreferenceProperty( hh, "step", 0.1 );
4906 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4907 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4908 setPreferenceProperty( distributionGr, "columns", 3 );
4910 types.append( tr( "SMESH_MONOCOLOR" ) );
4911 types.append( tr( "SMESH_MULTICOLOR" ) );
4912 indices.clear(); indices.append( 0 ); indices.append( 1 );
4913 setPreferenceProperty( coloringType, "strings", types );
4914 setPreferenceProperty( coloringType, "indexes", indices );
4915 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4919 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4921 if( sect=="SMESH" ) {
4922 float sbX1,sbY1,sbW,sbH;
4923 float aTol = 1.00000009999999;
4924 std::string aWarning;
4925 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4926 if( name=="selection_object_color" || name=="selection_element_color" ||
4927 name=="highlight_color" ||
4928 name=="selection_precision_node" || name=="selection_precision_element" ||
4929 name=="selection_precision_object")
4930 SMESH::UpdateSelectionProp( this );
4931 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4932 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4933 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4934 if(sbX1+sbW > aTol){
4935 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4938 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4939 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4942 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4943 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4944 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4945 if(sbY1+sbH > aTol){
4946 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4947 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4948 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4951 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
4952 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4953 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
4954 if(sbX1+sbW > aTol){
4955 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
4958 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
4959 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
4962 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
4963 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4964 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
4965 if(sbY1+sbH > aTol){
4966 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
4969 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
4970 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
4973 else if ( name == "segmentation" ) {
4974 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
4975 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
4977 else if ( name == "nb_segments_per_edge" ) {
4978 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
4979 myComponentSMESH->SetDefaultNbSegments( nbSeg );
4981 else if ( name == "historical_python_dump" ||
4982 name == "forget_mesh_on_hyp_modif") {
4983 QString val = aResourceMgr->stringValue( "SMESH", name );
4984 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
4987 if(aWarning.size() != 0){
4988 aWarning += "The default values are applied instead.";
4989 SUIT_MessageBox::warning(SMESHGUI::desktop(),
4990 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
4991 QObject::tr(aWarning.c_str()));
4996 //================================================================================
4998 * \brief Update something in accordance with update flags
4999 * \param theFlags - update flags
5001 * Update viewer or/and object browser etc. in accordance with update flags ( see
5002 * LightApp_UpdateFlags enumeration ).
5004 //================================================================================
5005 void SMESHGUI::update( const int flags )
5007 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5008 SMESH::UpdateView();
5010 SalomeApp_Module::update( flags );
5013 //================================================================================
5015 * \brief Set default selection mode
5017 * SLOT called when operation commited. Sets default selection mode
5019 //================================================================================
5020 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5022 SVTK_ViewWindow* vtkWnd =
5023 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5025 vtkWnd->SetSelectionMode( ActorSelection );
5028 //================================================================================
5030 * \brief Set default selection mode
5032 * SLOT called when operation aborted. Sets default selection mode
5034 //================================================================================
5035 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5037 SVTK_ViewWindow* vtkWnd =
5038 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5040 vtkWnd->SetSelectionMode( ActorSelection );
5043 //================================================================================
5045 * \brief Creates operation with given identifier
5046 * \param id - identifier of operation to be started
5047 * \return Pointer on created operation or NULL if operation is not created
5049 * Virtual method redefined from the base class creates operation with given id.
5050 * It is called called automatically from startOperation method of base class.
5052 //================================================================================
5053 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5055 LightApp_Operation* op = 0;
5056 // to do : create operation here
5059 case 417: //convert to quadratic
5060 op = new SMESHGUI_ConvToQuadOp();
5062 case 418: // create 2D mesh as boundary on 3D
5063 op = new SMESHGUI_Make2DFrom3DOp();
5065 case 420: // Reorient faces
5066 op = new SMESHGUI_ReorientFacesOp();
5068 case 701: // Compute mesh
5069 op = new SMESHGUI_ComputeOp();
5071 case 702: // Create mesh
5072 op = new SMESHGUI_MeshOp( true, true );
5074 case 703: // Create sub-mesh
5075 op = new SMESHGUI_MeshOp( true, false );
5077 case 704: // Edit mesh/sub-mesh
5078 op = new SMESHGUI_MeshOp( false );
5080 case 711: // Precompute mesh
5081 op = new SMESHGUI_PrecomputeOp();
5083 case 712: // Evaluate mesh
5084 op = new SMESHGUI_EvaluateOp();
5086 case 713: // Evaluate mesh
5087 op = new SMESHGUI_MeshOrderOp();
5089 case 806: // Create group on geom
5090 op = new SMESHGUI_GroupOnShapeOp();
5092 case 904: // Find element
5093 op = new SMESHGUI_FindElemByPointOp();
5095 case 4067: // make mesh pass through point
5096 op = new SMESHGUI_MakeNodeAtPointOp();
5103 op = SalomeApp_Module::createOperation( id );
5107 //================================================================================
5109 * \brief Stops current operations and starts a given one
5110 * \param id - The id of the operation to start
5112 //================================================================================
5114 void SMESHGUI::switchToOperation(int id)
5116 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5117 activeStudy()->abortAllOperations();
5118 startOperation( id );
5121 LightApp_Displayer* SMESHGUI::displayer()
5124 myDisplayer = new SMESHGUI_Displayer( getApp() );
5128 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5131 int aTolerance = 64;
5132 int anIterations = 0;
5138 if( anIterations % aPeriod == 0 )
5141 if( aTolerance < 1 )
5145 aHue = (int)( 360.0 * rand() / RAND_MAX );
5148 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5149 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5150 for( ; it != itEnd; ++it )
5152 SALOMEDS::Color anAutoColor = *it;
5153 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5156 aQColor.getHsv( &h, &s, &v );
5157 if( abs( h - aHue ) < aTolerance )
5169 aColor.setHsv( aHue, 255, 255 );
5171 SALOMEDS::Color aSColor;
5172 aSColor.R = (double)aColor.red() / 255.0;
5173 aSColor.G = (double)aColor.green() / 255.0;
5174 aSColor.B = (double)aColor.blue() / 255.0;
5179 const char gSeparator = '_'; // character used to separate parameter names
5180 const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
5181 const char gPathSep = '|'; // character used to separate paths
5184 * \brief Store visual parameters
5186 * This method is called just before the study document is saved.
5187 * Store visual parameters in AttributeParameter attribue(s)
5189 void SMESHGUI::storeVisualParameters (int savePoint)
5191 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5192 if (!appStudy || !appStudy->studyDS())
5194 _PTR(Study) studyDS = appStudy->studyDS();
5196 // componentName is used for encoding of entries when storing them in IParameters
5197 std::string componentName = myComponentSMESH->ComponentDataType();
5198 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5199 //if (!aSComponent) return;
5202 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5203 componentName.c_str(),
5205 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5207 // store map of custom markers
5208 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5209 if( !aMarkerMap.empty() )
5211 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5212 for( ; anIter != aMarkerMap.end(); anIter++ )
5214 int anId = anIter->first;
5215 VTK::MarkerData aMarkerData = anIter->second;
5216 std::string aMarkerFileName = aMarkerData.first;
5217 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5218 if( aMarkerTexture.size() < 3 )
5219 continue; // should contain at least width, height and the first value
5221 QString aPropertyName( "texture" );
5222 aPropertyName += gSeparator;
5223 aPropertyName += QString::number( anId );
5225 QString aPropertyValue = aMarkerFileName.c_str();
5226 aPropertyValue += gPathSep;
5228 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5229 ushort aWidth = *aTextureIter++;
5230 ushort aHeight = *aTextureIter++;
5231 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5232 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5233 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5234 aPropertyValue += QString::number( *aTextureIter );
5236 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5240 // viewers counters are used for storing view_numbers in IParameters
5243 // main cycle to store parameters of displayed objects
5244 QList<SUIT_ViewManager*> lst;
5245 QList<SUIT_ViewManager*>::Iterator it;
5246 getApp()->viewManagers(lst);
5247 for (it = lst.begin(); it != lst.end(); it++)
5249 SUIT_ViewManager* vman = *it;
5250 QString vType = vman->getType();
5252 // saving VTK actors properties
5253 if (vType == SVTK_Viewer::Type())
5255 // store the clipping planes attached to the view manager
5256 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5257 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5258 if( anIter != myClippingPlaneInfoMap.end() )
5259 aClippingPlaneInfoList = anIter->second;
5261 if( !aClippingPlaneInfoList.empty() ) {
5262 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5263 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5265 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5266 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5268 QString aPropertyName( "ClippingPlane" );
5269 aPropertyName += gSeparator;
5270 aPropertyName += QString::number( vtkViewers );
5271 aPropertyName += gSeparator;
5272 aPropertyName += QString::number( anId );
5274 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5275 aPropertyValue += gDigitsSep;
5276 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5277 aPropertyValue += gDigitsSep;
5278 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5279 aPropertyValue += gDigitsSep;
5280 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5282 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5286 QVector<SUIT_ViewWindow*> views = vman->getViews();
5287 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5289 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5291 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5292 vtkActorCollection* allActors = aCopy.GetActors();
5293 allActors->InitTraversal();
5294 while (vtkActor* actor = allActors->GetNextActor())
5296 if (actor->GetVisibility()) // store only visible actors
5298 SMESH_Actor* aSmeshActor = 0;
5299 if (actor->IsA("SMESH_Actor"))
5300 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5301 if (aSmeshActor && aSmeshActor->hasIO())
5303 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5306 // entry is "encoded" = it does NOT contain component adress,
5307 // since it is a subject to change on next component loading
5308 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5310 std::string param, vtkParam = vType.toLatin1().data();
5311 vtkParam += gSeparator;
5312 vtkParam += QString::number(vtkViewers).toLatin1().data();
5313 vtkParam += gSeparator;
5316 param = vtkParam + "Visibility";
5317 ip->setParameter(entry, param, "On");
5320 param = vtkParam + "Representation";
5321 ip->setParameter(entry, param, QString::number
5322 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5325 param = vtkParam + "IsShrunk";
5326 ip->setParameter(entry, param, QString::number
5327 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5329 // Displayed entities
5330 unsigned int aMode = aSmeshActor->GetEntityMode();
5331 bool isE = aMode & SMESH_Actor::eEdges;
5332 bool isF = aMode & SMESH_Actor::eFaces;
5333 bool isV = aMode & SMESH_Actor::eVolumes;
5335 QString modeStr ("e");
5336 modeStr += gDigitsSep; modeStr += QString::number(isE);
5337 modeStr += gDigitsSep; modeStr += "f";
5338 modeStr += gDigitsSep; modeStr += QString::number(isF);
5339 modeStr += gDigitsSep; modeStr += "v";
5340 modeStr += gDigitsSep; modeStr += QString::number(isV);
5342 param = vtkParam + "Entities";
5343 ip->setParameter(entry, param, modeStr.toLatin1().data());
5345 // Colors (surface:edge:)
5346 vtkFloatingPointType r, g, b;
5349 aSmeshActor->GetSufaceColor(r, g, b, delta);
5350 QString colorStr ("surface");
5351 colorStr += gDigitsSep; colorStr += QString::number(r);
5352 colorStr += gDigitsSep; colorStr += QString::number(g);
5353 colorStr += gDigitsSep; colorStr += QString::number(b);
5355 colorStr += gDigitsSep; colorStr += "backsurface";
5356 colorStr += gDigitsSep; colorStr += QString::number(delta);
5359 aSmeshActor->GetEdgeColor(r, g, b);
5360 colorStr += gDigitsSep; colorStr += "edge";
5361 colorStr += gDigitsSep; colorStr += QString::number(r);
5362 colorStr += gDigitsSep; colorStr += QString::number(g);
5363 colorStr += gDigitsSep; colorStr += QString::number(b);
5365 aSmeshActor->GetNodeColor(r, g, b);
5366 colorStr += gDigitsSep; colorStr += "node";
5367 colorStr += gDigitsSep; colorStr += QString::number(r);
5368 colorStr += gDigitsSep; colorStr += QString::number(g);
5369 colorStr += gDigitsSep; colorStr += QString::number(b);
5371 aSmeshActor->GetOutlineColor(r, g, b);
5372 colorStr += gDigitsSep; colorStr += "outline";
5373 colorStr += gDigitsSep; colorStr += QString::number(r);
5374 colorStr += gDigitsSep; colorStr += QString::number(g);
5375 colorStr += gDigitsSep; colorStr += QString::number(b);
5377 param = vtkParam + "Colors";
5378 ip->setParameter(entry, param, colorStr.toLatin1().data());
5380 // Sizes of lines and points
5381 QString sizeStr ("line");
5382 sizeStr += gDigitsSep; sizeStr += QString::number((int)aSmeshActor->GetLineWidth());
5383 sizeStr += gDigitsSep; sizeStr += "shrink";
5384 sizeStr += gDigitsSep; sizeStr += QString::number(aSmeshActor->GetShrinkFactor());
5386 param = vtkParam + "Sizes";
5387 ip->setParameter(entry, param, sizeStr.toLatin1().data());
5392 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5393 if( aMarkerType == VTK::MT_USER ) {
5394 markerStr += "custom";
5395 markerStr += gDigitsSep;
5396 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5400 markerStr += gDigitsSep;
5401 markerStr += QString::number( (int)aMarkerType );
5402 markerStr += gDigitsSep;
5403 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5406 param = vtkParam + "PointMarker";
5407 ip->setParameter(entry, param, markerStr.toLatin1().data());
5410 param = vtkParam + "Opacity";
5411 ip->setParameter(entry, param,
5412 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5415 param = vtkParam + "ClippingPlane";
5417 if( !aClippingPlaneInfoList.empty() ) {
5418 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5419 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5421 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5422 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5423 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5424 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5425 if( aSmeshActor == *anIter2 ) {
5426 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5427 QString::number( anId ).toLatin1().constData() );
5434 ip->setParameter( entry, param, "Off" );
5435 } // if (io->hasEntry())
5436 } // SMESH_Actor && hasIO
5438 } // while.. actors traversal
5442 } // if (SVTK view model)
5443 } // for (viewManagers)
5446 // data structures for clipping planes processing
5449 vtkIdType Orientation;
5450 vtkFloatingPointType Distance;
5451 vtkFloatingPointType Angle[2];
5453 typedef std::list<TPlaneData> TPlaneDataList;
5454 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5456 typedef std::list<vtkActor*> TActorList;
5459 TActorList ActorList;
5460 SUIT_ViewManager* ViewManager;
5462 typedef std::list<TPlaneInfo> TPlaneInfoList;
5463 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5466 * \brief Restore visual parameters
5468 * This method is called after the study document is opened.
5469 * Restore visual parameters from AttributeParameter attribue(s)
5471 void SMESHGUI::restoreVisualParameters (int savePoint)
5473 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5474 if (!appStudy || !appStudy->studyDS())
5476 _PTR(Study) studyDS = appStudy->studyDS();
5478 // componentName is used for encoding of entries when storing them in IParameters
5479 std::string componentName = myComponentSMESH->ComponentDataType();
5480 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5481 //if (!aSComponent) return;
5484 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5485 componentName.c_str(),
5487 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5489 // restore map of custom markers and map of clipping planes
5490 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5491 TPlaneDataMap aPlaneDataMap;
5493 std::vector<std::string> properties = ip->getProperties();
5494 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5496 std::string property = *propIt;
5497 QString aPropertyName( property.c_str() );
5498 QString aPropertyValue( ip->getProperty( property ).c_str() );
5500 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5501 if( aPropertyNameList.isEmpty() )
5504 QString aPropertyType = aPropertyNameList[0];
5505 if( aPropertyType == "texture" )
5507 if( aPropertyNameList.size() != 2 )
5511 int anId = aPropertyNameList[1].toInt( &ok );
5512 if( !ok || anId < 1 )
5515 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5516 if( aPropertyValueList.size() != 2 )
5519 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5520 QString aMarkerTextureString = aPropertyValueList[1];
5521 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5522 if( aMarkerTextureStringList.size() != 3 )
5526 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5531 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5535 VTK::MarkerTexture aMarkerTexture;
5536 aMarkerTexture.push_back( aWidth );
5537 aMarkerTexture.push_back( aHeight );
5539 QString aMarkerTextureData = aMarkerTextureStringList[2];
5540 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5542 QChar aChar = aMarkerTextureData.at( i );
5543 if( aChar.isDigit() )
5544 aMarkerTexture.push_back( aChar.digitValue() );
5547 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5549 else if( aPropertyType == "ClippingPlane" )
5551 if( aPropertyNameList.size() != 3 )
5555 int aViewId = aPropertyNameList[1].toInt( &ok );
5556 if( !ok || aViewId < 0 )
5560 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5561 if( !ok || aClippingPlaneId < 0 )
5564 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5565 if( aPropertyValueList.size() != 4 )
5568 TPlaneData aPlaneData;
5569 aPlaneData.Id = aClippingPlaneId;
5572 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5577 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5582 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5587 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5591 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5592 aPlaneDataList.push_back( aPlaneData );
5596 TPlaneInfoMap aPlaneInfoMap;
5598 std::vector<std::string> entries = ip->getEntries();
5600 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5602 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5603 QString entry (ip->decodeEntry(*entIt).c_str());
5605 // Check that the entry corresponds to a real object in the Study
5606 // as the object may be deleted or modified after the visual state is saved.
5607 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5608 if (!so) continue; //Skip the not existent entry
5610 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5611 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5613 std::vector<std::string>::iterator namesIt = paramNames.begin();
5614 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5616 // actors are stored in a map after displaying of them for
5617 // quicker access in the future: map < viewID to actor >
5618 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5620 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5622 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5623 // '_' is used as separator and should not be used in viewer type or parameter names.
5624 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5625 if (lst.size() != 3)
5628 QString viewerTypStr = lst[0];
5629 QString viewIndexStr = lst[1];
5630 QString paramNameStr = lst[2];
5633 int viewIndex = viewIndexStr.toUInt(&ok);
5634 if (!ok) // bad conversion of view index to integer
5638 if (viewerTypStr == SVTK_Viewer::Type())
5640 SMESH_Actor* aSmeshActor = 0;
5641 if (vtkActors.IsBound(viewIndex))
5642 aSmeshActor = vtkActors.Find(viewIndex);
5644 QList<SUIT_ViewManager*> lst;
5645 getApp()->viewManagers(viewerTypStr, lst);
5647 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5648 SUIT_ViewManager* vman = NULL;
5649 if (viewIndex >= 0 && viewIndex < lst.count())
5650 vman = lst.at(viewIndex);
5652 if (paramNameStr == "Visibility")
5654 if (!aSmeshActor && displayer() && vman)
5656 SUIT_ViewModel* vmodel = vman->getViewModel();
5657 // SVTK view model can be casted to SALOME_View
5658 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5660 // store displayed actor in a temporary map for quicker
5661 // access later when restoring other parameters
5662 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5663 vtkRenderer* Renderer = vtkView->getRenderer();
5664 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5665 vtkActorCollection* theActors = aCopy.GetActors();
5666 theActors->InitTraversal();
5667 bool isFound = false;
5668 vtkActor *ac = theActors->GetNextActor();
5669 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5670 if (ac->IsA("SMESH_Actor")) {
5671 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5672 if (aGeomAc->hasIO()) {
5673 Handle(SALOME_InteractiveObject) io =
5674 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5675 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5677 vtkActors.Bind(viewIndex, aGeomAc);
5683 } // if (paramNameStr == "Visibility")
5686 // the rest properties "work" with SMESH_Actor
5689 QString val ((*valuesIt).c_str());
5692 if (paramNameStr == "Representation") {
5693 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5696 else if (paramNameStr == "IsShrunk") {
5698 if (!aSmeshActor->IsShrunk())
5699 aSmeshActor->SetShrink();
5702 if (aSmeshActor->IsShrunk())
5703 aSmeshActor->UnShrink();
5706 // Displayed entities
5707 else if (paramNameStr == "Entities") {
5708 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5709 if (mode.count() == 6) {
5710 if (mode[0] != "e" || mode[2] != "f" || mode[4] != "v") {
5711 MESSAGE("Invalid order of data in Entities, must be: "
5712 "e:0/1:f:0/1:v:0/1");
5715 unsigned int aMode = aSmeshActor->GetEntityMode();
5716 unsigned int aNewMode =
5717 (int(SMESH_Actor::eEdges ) * mode[1].toInt()) |
5718 (int(SMESH_Actor::eFaces ) * mode[3].toInt()) |
5719 (int(SMESH_Actor::eVolumes) * mode[5].toInt());
5720 if (aNewMode != aMode)
5721 aSmeshActor->SetEntityMode(aNewMode);
5726 else if (paramNameStr == "Colors") {
5727 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5728 if (colors.count() == 16 || colors.count() == 18 ) {
5729 if (colors[0] != "surface" || colors[4] != "backsurface" ||
5730 (colors[8] != "edge" && colors[6] != "edge" ) || (colors[12] != "node" && colors[10] != "node") ||
5731 (colors.count() == 18 && colors[14] != "outline")) {
5732 MESSAGE("Invalid order of data in Colors, must be: "
5733 "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");
5739 vtkFloatingPointType otr,otg,otb;
5740 //Old case backsurface color is independent
5741 if( colors.count() == 16 ) {
5743 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
5744 er = colors[9].toFloat();
5745 eg = colors[10].toFloat();
5746 eb = colors[11].toFloat();
5748 nr = colors[13].toFloat();
5749 ng = colors[14].toFloat();
5750 nb = colors[15].toFloat();
5751 SMESH::GetColor("SMESH", "outline_color", otr, otg, otb, QColor( 0, 70, 0 ) );
5753 //New case backsurface color depends on surface color
5754 delta = colors[5].toInt();
5756 er = colors[7].toFloat();
5757 eg = colors[8].toFloat();
5758 eb = colors[9].toFloat();
5760 nr = colors[11].toFloat();
5761 ng = colors[12].toFloat();
5762 nb = colors[13].toFloat();
5764 otr = colors[15].toFloat();
5765 otg = colors[16].toFloat();
5766 otb = colors[17].toFloat();
5768 aSmeshActor->SetSufaceColor(colors[1].toFloat(), colors[2].toFloat(), colors[3].toFloat(), delta);
5769 aSmeshActor->SetEdgeColor(er,eg,eb);
5770 aSmeshActor->SetNodeColor(nr,ng,nb);
5771 aSmeshActor->SetOutlineColor(otr,otg,otb);
5775 // Sizes of lines and points
5776 else if (paramNameStr == "Sizes") {
5777 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
5778 if (sizes.count() == 4) {
5779 if (sizes[0] != "line" || sizes[2] != "shrink") {
5780 MESSAGE("Invalid order of data in Sizes, must be: "
5781 "line:int:shrink:float");
5784 aSmeshActor->SetLineWidth(sizes[1].toInt());
5785 aSmeshActor->SetShrinkFactor(sizes[3].toFloat());
5788 else if (sizes.count() == 6) { // just to support old format
5789 if (sizes[0] != "line" || sizes[2] != "node" || sizes[4] != "shrink") {
5790 MESSAGE("Invalid order of data in Sizes, must be: "
5791 "line:int:node:int:shrink:float");
5794 aSmeshActor->SetLineWidth(sizes[1].toInt());
5795 //aSmeshActor->SetNodeSize(sizes[3].toInt()); // made obsolete
5796 aSmeshActor->SetShrinkFactor(sizes[5].toFloat());
5801 else if (paramNameStr == "PointMarker") {
5802 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
5803 if( data.count() >= 2 ) {
5805 int aParam1 = data[1].toInt( &ok );
5807 if( data[0] == "std" && data.count() == 3 ) {
5808 int aParam2 = data[2].toInt( &ok );
5809 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
5811 else if( data[0] == "custom" ) {
5812 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
5813 if( markerIt != aMarkerMap.end() ) {
5814 VTK::MarkerData aMarkerData = markerIt->second;
5815 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
5822 else if (paramNameStr == "Opacity") {
5823 aSmeshActor->SetOpacity(val.toFloat());
5826 else if (paramNameStr.startsWith("ClippingPlane")) {
5827 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
5828 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
5829 // new format - val looks like "Off" or "0" (plane id)
5830 // (note: in new format "Off" value is used only for consistency,
5831 // so it is processed together with values in old format)
5832 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
5833 if( anIsOldFormat ) {
5834 if (paramNameStr == "ClippingPlane1" || val == "Off")
5835 aSmeshActor->RemoveAllClippingPlanes();
5837 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
5838 double aDistance = vals[1].toFloat();
5839 vtkFloatingPointType anAngle[2];
5840 anAngle[0] = vals[2].toFloat();
5841 anAngle[1] = vals[3].toFloat();
5843 QList<SUIT_ViewManager*> lst;
5844 getApp()->viewManagers(viewerTypStr, lst);
5845 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5846 if (viewIndex >= 0 && viewIndex < lst.count()) {
5847 SUIT_ViewManager* vman = lst.at(viewIndex);
5848 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5850 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
5852 SMESH::TActorList anActorList;
5853 anActorList.push_back( aSmeshActor );
5854 SMESH::OrientedPlane* aPlane =
5855 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
5857 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5858 aClippingPlaneInfo.Plane = aPlane;
5859 aClippingPlaneInfo.ActorList = anActorList;
5860 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5867 int aPlaneId = val.toInt( &ok );
5868 if( ok && aPlaneId >= 0 ) {
5869 bool anIsDefinedPlane = false;
5870 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
5871 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
5872 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5873 TPlaneInfo& aPlaneInfo = *anIter;
5874 if( aPlaneInfo.PlaneId == aPlaneId ) {
5875 aPlaneInfo.ActorList.push_back( aSmeshActor );
5876 anIsDefinedPlane = true;
5880 if( !anIsDefinedPlane ) {
5881 TPlaneInfo aPlaneInfo;
5882 aPlaneInfo.PlaneId = aPlaneId;
5883 aPlaneInfo.ActorList.push_back( aSmeshActor );
5884 aPlaneInfo.ViewManager = vman;
5886 // to make the list sorted by plane id
5887 anIter = aPlaneInfoList.begin();
5888 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
5889 const TPlaneInfo& aPlaneInfoRef = *anIter;
5890 if( aPlaneInfoRef.PlaneId > aPlaneId )
5893 aPlaneInfoList.insert( anIter, aPlaneInfo );
5898 } // if (aSmeshActor)
5899 } // other parameters than Visibility
5901 } // for names/parameters iterator
5902 } // for entries iterator
5904 // take into account planes with empty list of actors referred to them
5905 QList<SUIT_ViewManager*> aVMList;
5906 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
5908 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
5909 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
5910 int aViewId = aPlaneDataIter->first;
5911 if( aViewId >= 0 && aViewId < aVMList.count() ) {
5912 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
5914 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
5916 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
5917 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
5918 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
5919 const TPlaneData& aPlaneData = *anIter2;
5920 int aPlaneId = aPlaneData.Id;
5922 bool anIsFound = false;
5923 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5924 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5925 const TPlaneInfo& aPlaneInfo = *anIter3;
5926 if( aPlaneInfo.PlaneId == aPlaneId ) {
5933 TPlaneInfo aPlaneInfo; // ActorList field is empty
5934 aPlaneInfo.PlaneId = aPlaneId;
5935 aPlaneInfo.ViewManager = aViewManager;
5937 // to make the list sorted by plane id
5938 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
5939 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
5940 const TPlaneInfo& aPlaneInfoRef = *anIter4;
5941 if( aPlaneInfoRef.PlaneId > aPlaneId )
5944 aPlaneInfoList.insert( anIter4, aPlaneInfo );
5950 // add clipping planes to actors according to the restored parameters
5951 // and update the clipping plane map
5952 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
5953 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
5954 int aViewId = anIter1->first;
5955 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
5957 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
5958 if( anIter2 == aPlaneDataMap.end() )
5960 const TPlaneDataList& aPlaneDataList = anIter2->second;
5962 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
5963 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
5964 const TPlaneInfo& aPlaneInfo = *anIter3;
5965 int aPlaneId = aPlaneInfo.PlaneId;
5966 const TActorList& anActorList = aPlaneInfo.ActorList;
5967 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
5971 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
5975 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
5977 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
5978 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
5979 const TPlaneData& aPlaneData = *anIter4;
5980 if( aPlaneData.Id == aPlaneId ) {
5981 SMESH::OrientedPlane* aPlane =
5982 SMESHGUI_ClippingDlg::AddPlane( anActorList,
5984 (SMESH::Orientation)aPlaneData.Orientation,
5985 aPlaneData.Distance,
5988 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
5989 aClippingPlaneInfo.Plane = aPlane;
5990 aClippingPlaneInfo.ActorList = anActorList;
5991 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
5999 // update all VTK views
6000 QList<SUIT_ViewManager*> lst;
6001 getApp()->viewManagers(lst);
6002 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6003 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6004 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6005 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6006 vtkView->getRenderer()->ResetCameraClippingRange();
6013 \brief Adds preferences for dfont of VTK viewer
6015 \param pIf group identifier
6016 \param param parameter
6017 \return identifier of preferences
6019 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
6021 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6023 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6026 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6027 fam.append( tr( "SMESH_FONT_COURIER" ) );
6028 fam.append( tr( "SMESH_FONT_TIMES" ) );
6030 setPreferenceProperty( tfont, "fonts", fam );
6032 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6033 setPreferenceProperty( tfont, "features", f );
6039 \brief Actions after hypothesis edition
6040 Updates object browser after hypothesis edition
6042 void SMESHGUI::onHypothesisEdit( int result )
6045 SMESHGUI::Modified();
6046 updateObjBrowser( true );
6051 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6052 \param pview view being closed
6054 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6055 #ifndef DISABLE_PLOT2DVIEWER
6056 //Crear all Plot2d Viewers if need.
6057 SMESH::ClearPlot2Viewers(pview);
6061 void SMESHGUI::message( const QString& msg )
6064 QStringList data = msg.split("/");
6065 if ( data.count() > 0 ) {
6066 if ( data.first() == "mesh_loading" ) {
6068 QString entry = data.count() > 1 ? data[1] : QString();
6069 if ( entry.isEmpty() )
6072 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6074 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6077 name = obj->GetName().c_str();
6078 if ( name.isEmpty() )
6081 if ( data.last() == "stop" )
6082 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6084 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6085 QApplication::processEvents();
6091 \brief Connects or disconnects signals about activating and cloning view on the module slots
6092 \param pview view which is connected/disconnected
6094 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6098 SUIT_ViewManager* viewMgr = pview->getViewManager();
6100 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6101 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6103 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6104 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6109 \brief Return \c true if object can be renamed
6111 bool SMESHGUI::renameAllowed( const QString& entry) const {
6112 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6116 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6120 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6125 if(appStudy->isComponent(entry) || obj->isReference())
6128 // check type to prevent renaming of inappropriate objects
6129 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6130 if (aType == MESH || aType == GROUP ||
6131 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
6132 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
6133 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
6134 aType == HYPOTHESIS || aType == ALGORITHM)
6141 Rename object by entry.
6142 \param entry entry of the object
6143 \param name new name of the object
6144 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6146 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6148 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6152 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6157 _PTR(Study) aStudy = appStudy->studyDS();
6162 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6164 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6169 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6170 _PTR(GenericAttribute) anAttr;
6171 _PTR(AttributeName) aName;
6173 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6175 // check type to prevent renaming of inappropriate objects
6176 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6177 if (aType == MESH || aType == GROUP ||
6178 aType == SUBMESH || aType == SUBMESH_COMPOUND ||
6179 aType == SUBMESH_SOLID || aType == SUBMESH_FACE ||
6180 aType == SUBMESH_EDGE || aType == SUBMESH_VERTEX ||
6181 aType == HYPOTHESIS || aType == ALGORITHM) {
6182 if ( !name.isEmpty() ) {
6183 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6185 // update name of group object and its actor
6186 Handle(SALOME_InteractiveObject) IObject =
6187 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6189 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6190 if( !aGroupObject->_is_nil() ) {
6191 aGroupObject->SetName( qPrintable(name) );
6192 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6193 anActor->setName( qPrintable(name) );