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
33 #include "SMESHGUI_Add0DElemsOnAllNodesDlg.h"
34 #include "SMESHGUI_AddMeshElementDlg.h"
35 #include "SMESHGUI_AddQuadraticElementDlg.h"
36 #include "SMESHGUI_BuildCompoundDlg.h"
37 #include "SMESHGUI_ClippingDlg.h"
38 #include "SMESHGUI_ComputeDlg.h"
39 #include "SMESHGUI_ConvToQuadOp.h"
40 #include "SMESHGUI_CopyMeshDlg.h"
41 #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
42 #include "SMESHGUI_DeleteGroupDlg.h"
43 #include "SMESHGUI_Displayer.h"
44 #include "SMESHGUI_DuplicateNodesDlg.h"
45 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
46 #include "SMESHGUI_ExtrusionDlg.h"
47 #include "SMESHGUI_FileInfoDlg.h"
48 #include "SMESHGUI_FileValidator.h"
49 #include "SMESHGUI_FilterDlg.h"
50 #include "SMESHGUI_FilterLibraryDlg.h"
51 #include "SMESHGUI_FindElemByPointDlg.h"
52 #include "SMESHGUI_GroupDlg.h"
53 #include "SMESHGUI_GroupOnShapeDlg.h"
54 #include "SMESHGUI_GroupOpDlg.h"
55 #include "SMESHGUI_Hypotheses.h"
56 #include "SMESHGUI_Make2DFrom3DOp.h"
57 #include "SMESHGUI_MakeNodeAtPointDlg.h"
58 #include "SMESHGUI_Measurements.h"
59 #include "SMESHGUI_MergeDlg.h"
60 #include "SMESHGUI_MeshInfo.h"
61 #include "SMESHGUI_MeshOp.h"
62 #include "SMESHGUI_MeshOrderOp.h"
63 #include "SMESHGUI_MeshPatternDlg.h"
64 #include "SMESHGUI_MultiEditDlg.h"
65 #include "SMESHGUI_NodesDlg.h"
66 #include "SMESHGUI_Preferences_ScalarBarDlg.h"
67 #include "SMESHGUI_PropertiesDlg.h"
68 #include "SMESHGUI_RemoveElementsDlg.h"
69 #include "SMESHGUI_RemoveNodesDlg.h"
70 #include "SMESHGUI_RenumberingDlg.h"
71 #include "SMESHGUI_ReorientFacesDlg.h"
72 #include "SMESHGUI_RevolutionDlg.h"
73 #include "SMESHGUI_RotationDlg.h"
74 #include "SMESHGUI_ScaleDlg.h"
75 #include "SMESHGUI_Selection.h"
76 #include "SMESHGUI_SewingDlg.h"
77 #include "SMESHGUI_SingleEditDlg.h"
78 #include "SMESHGUI_SmoothingDlg.h"
79 #include "SMESHGUI_SymmetryDlg.h"
80 #include "SMESHGUI_TranslationDlg.h"
81 #include "SMESHGUI_TransparencyDlg.h"
83 #include "SMESHGUI_FilterUtils.h"
84 #include "SMESHGUI_GroupUtils.h"
85 #include "SMESHGUI_HypothesesUtils.h"
86 #include "SMESHGUI_MeshUtils.h"
87 #include "SMESHGUI_PatternUtils.h"
88 #include "SMESHGUI_Utils.h"
89 #include "SMESHGUI_VTKUtils.h"
91 #include <SMESH_version.h>
93 #include "SMESH_ControlsDef.hxx"
94 #include <SMESH_Actor.h>
95 #include <SMESH_ActorUtils.h>
96 #include <SMESH_Client.hxx>
97 #include <SMESH_ScalarBarActor.h>
98 #include <SMESH_TypeFilter.hxx>
100 // SALOME GUI includes
101 #include <SalomeApp_Application.h>
102 #include <SalomeApp_CheckFileDlg.h>
103 #include <SalomeApp_DataObject.h>
104 #include <SalomeApp_Study.h>
105 #include <SalomeApp_Tools.h>
107 #include <LightApp_DataOwner.h>
108 #include <LightApp_NameDlg.h>
109 #include <LightApp_Preferences.h>
110 #include <LightApp_SelectionMgr.h>
111 #include <LightApp_UpdateFlags.h>
113 #include <SVTK_ViewManager.h>
114 #include <SVTK_ViewModel.h>
115 #include <SVTK_ViewWindow.h>
117 #include <VTKViewer_Algorithm.h>
119 #include <SUIT_Desktop.h>
120 #include <SUIT_FileDlg.h>
121 #include <SUIT_MessageBox.h>
122 #include <SUIT_OverrideCursor.h>
123 #include <SUIT_ResourceMgr.h>
124 #include <SUIT_Session.h>
126 #include <QtxPopupMgr.h>
127 #include <QtxFontEdit.h>
129 #include <SALOME_ListIO.hxx>
130 #include <SALOME_ListIteratorOfListIO.hxx>
132 #ifndef DISABLE_PLOT2DVIEWER
133 #include <SPlot2d_ViewModel.h>
134 #include <SPlot2d_Histogram.h>
138 #include <SALOMEconfig.h>
139 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
140 #include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
141 #include CORBA_CLIENT_HEADER(SMESH_Measurements)
144 // #define INCLUDE_MENUITEM_DEF // VSR commented ????????
145 #include <QApplication>
147 #include <QTextStream>
150 #include <boost/shared_ptr.hpp>
153 #include <vtkCallbackCommand.h>
154 #include <vtkCamera.h>
155 #include <vtkLookupTable.h>
156 #include <vtkPlane.h>
157 #include <vtkRenderer.h>
159 // SALOME KERNEL includes
160 #include <SALOMEDSClient_ClientFactory.hxx>
161 #include <SALOMEDSClient_IParameters.hxx>
162 #include <SALOMEDSClient_SComponent.hxx>
163 #include <SALOMEDSClient_StudyBuilder.hxx>
164 #include <SALOMEDS_Study.hxx>
167 #include <Standard_ErrorHandler.hxx>
168 #include <NCollection_DataMap.hxx>
170 #include <Basics_Utils.hxx>
172 //To disable automatic genericobj management, the following line should be commented.
173 //Otherwise, it should be uncommented.
174 //Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
175 #define WITHGENERICOBJ
179 //=============================================================
180 void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
183 void ExportMeshToFile(int theCommandID);
185 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap);
187 void SetDisplayEntity(int theCommandID);
189 void Control( int theCommandID );
193 //=============================================================
194 void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh,
198 std::string myExtension;
200 if ( theCommandID == 113 ) {
201 filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.*med)" );
202 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
204 else if ( theCommandID == 112 ) {
205 filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
207 else if ( theCommandID == 111 ) {
208 filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
210 else if ( theCommandID == 115 ) {
211 filter.append( QObject::tr( "STL_FILES_FILTER" ) + " (*.stl)" );
213 else if ( theCommandID == 116 ) {
214 filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
216 else if ( theCommandID == 117 ) {
217 filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
218 filter.append( QObject::tr( "All files (*)" ) );
220 else if ( theCommandID == 118 ) {
221 filter.append( QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" );
222 filter.append( QObject::tr( "GMF_BINARY_FILES_FILTER") + " (*.meshb)" );
225 QString anInitialPath = "";
226 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
227 anInitialPath = QDir::currentPath();
229 QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
232 QObject::tr( "SMESH_IMPORT_MESH" ) );
233 if ( filenames.count() > 0 ) {
234 SUIT_OverrideCursor wc;
235 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
238 QStringList anEntryList;
239 bool isEmpty = false;
240 for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
241 QString filename = *it;
242 SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
244 switch ( theCommandID ) {
247 // DAT format (currently unsupported)
248 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
249 arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
255 aMeshes->length( 1 );
256 aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
257 if ( aMeshes[0]->_is_nil() )
258 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
259 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
265 SMESH::DriverMED_ReadStatus res;
266 aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
267 if ( res != SMESH::DRS_OK ) {
268 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
269 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
276 aMeshes->length( 1 );
277 aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
278 if ( aMeshes[0]->_is_nil() ) {
279 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
280 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
287 SMESH::DriverMED_ReadStatus res;
288 aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
289 if ( res != SMESH::DRS_OK ) {
290 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
291 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
298 SMESH::DriverMED_ReadStatus res;
299 aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
300 if ( res != SMESH::DRS_OK ) {
301 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
302 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
309 SMESH::ComputeError_var res;
310 aMeshes->length( 1 );
311 aMeshes[0] = theComponentMesh->CreateMeshesFromGMF( filename.toLatin1().constData(), res.out() );
312 if ( res->code != SMESH::DRS_OK ) {
313 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
314 arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res->code ).toLatin1().data() ) ) );
315 if ( strlen( res->comment.in() ) > 0 ) {
316 errors.back() += ": ";
317 errors.back() += res->comment.in();
324 catch ( const SALOME::SALOME_Exception& S_ex ) {
325 errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
326 arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
329 for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
330 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
332 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
333 _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
334 aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
335 if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
336 SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
338 anEntryList.append( aMeshSO->GetID().c_str() );
340 #ifdef WITHGENERICOBJ
341 // obj has been published in study. Its refcount has been incremented.
342 // It is safe to decrement its refcount
343 // so that it will be destroyed when the entry in study will be removed
344 aMeshes[i]->UnRegister();
353 // update Object browser
354 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
356 // browse to the published meshes
357 if( LightApp_Application* anApp =
358 dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
359 anApp->browseObjects( anEntryList );
361 // show Error message box if there were errors
362 if ( errors.count() > 0 ) {
363 SUIT_MessageBox::critical( SMESHGUI::desktop(),
364 QObject::tr( "SMESH_ERROR" ),
365 QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
368 // show warning message box, if some imported mesh is empty
370 SUIT_MessageBox::warning( SMESHGUI::desktop(),
371 QObject::tr( "SMESH_WRN_WARNING" ),
372 QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
377 //================================================================================
379 * \brief Export selected meshes or groups into a file
381 //================================================================================
383 void ExportMeshToFile( int theCommandID )
385 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
386 SALOME_ListIO selected;
388 aSel->selectedObjects( selected );
390 const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
391 const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
392 const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
393 const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
394 const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
395 const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );
396 const bool isGMF = ( theCommandID == 146 || theCommandID == 147 );
398 // actually, the following condition can't be met (added for insurance)
399 if( selected.Extent() == 0 ||
400 ( selected.Extent() > 1 && !isMED && !isSTL ))
403 // get mesh object from selection and check duplication of their names
404 bool hasDuplicatedMeshNames = false;
405 QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
406 QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
407 SALOME_ListIteratorOfListIO It( selected );
408 for( ; It.More(); It.Next() )
410 Handle(SALOME_InteractiveObject) anIObject = It.Value();
411 SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
412 if ( aMeshItem->_is_nil() ) {
413 SUIT_MessageBox::warning( SMESHGUI::desktop(),
414 QObject::tr( "SMESH_WRN_WARNING" ),
415 QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
419 QString aMeshName = anIObject->getName();
421 // check for name duplications
422 if ( !hasDuplicatedMeshNames )
423 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
424 if( aMeshName == (*aMeshIter).second ) {
425 hasDuplicatedMeshNames = true;
430 aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
433 if( hasDuplicatedMeshNames && isMED ) {
434 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
435 QObject::tr("SMESH_WRN_WARNING"),
436 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
437 QObject::tr("SMESH_BUT_YES"),
438 QObject::tr("SMESH_BUT_NO"), 0, 1);
443 aMeshIter = aMeshList.begin();
444 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
445 SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
446 QString aMeshName = (*aMeshIter).second;
448 if ( isMED || isCGNS || isSAUV ) // formats where group names must be unique
450 // check for equal group names within each mesh
451 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
452 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
453 if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
454 int aRet = SUIT_MessageBox::warning
455 (SMESHGUI::desktop(),
456 QObject::tr("SMESH_WRN_WARNING"),
457 QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
458 QObject::tr("SMESH_BUT_YES"),
459 QObject::tr("SMESH_BUT_NO"), 0, 1);
466 // Warn the user about presence of not supported elements
468 std::vector< SMESH::EntityType > notSupportedElemTypes, presentNotSupported;
472 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Quadrangle );
473 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
474 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
475 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
476 notSupportedElemTypes.push_back( SMESH::Entity_Tetra );
477 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Tetra );
478 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
479 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
480 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Hexa );
481 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
482 notSupportedElemTypes.push_back( SMESH::Entity_Penta );
483 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
484 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
485 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
486 notSupportedElemTypes.push_back( SMESH::Entity_0D );
487 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
492 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
493 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
494 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
495 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
496 notSupportedElemTypes.push_back( SMESH::Entity_Pyramid );
497 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
498 notSupportedElemTypes.push_back( SMESH::Entity_0D );
499 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
504 notSupportedElemTypes.push_back( SMESH::Entity_Edge );
505 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Edge );
506 notSupportedElemTypes.push_back( SMESH::Entity_0D );
507 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
512 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
517 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
518 notSupportedElemTypes.push_back( SMESH::Entity_BiQuad_Quadrangle );
519 notSupportedElemTypes.push_back( SMESH::Entity_TriQuad_Hexa );
520 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
521 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
522 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
527 notSupportedElemTypes.push_back( SMESH::Entity_0D );
528 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Quadrangle );
529 notSupportedElemTypes.push_back( SMESH::Entity_Polygon );
530 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polygon );
531 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Pyramid );
532 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Hexa );
533 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Penta );
534 notSupportedElemTypes.push_back( SMESH::Entity_Hexagonal_Prism );
535 notSupportedElemTypes.push_back( SMESH::Entity_Polyhedra );
536 notSupportedElemTypes.push_back( SMESH::Entity_Quad_Polyhedra );
537 notSupportedElemTypes.push_back( SMESH::Entity_Ball );
539 if ( ! notSupportedElemTypes.empty() )
541 SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
542 for ( size_t iType = 0; iType < notSupportedElemTypes.size(); ++iType )
543 if ( nbElems[ notSupportedElemTypes[ iType ]] > 0 )
544 presentNotSupported.push_back( notSupportedElemTypes[ iType ]);
546 if ( !presentNotSupported.empty() )
549 const char* typeMsg[SMESH::Entity_Last] = { "SMESH_NODES",
550 "SMESH_ELEMS0D","SMESH_EDGES","SMESH_QUADRATIC_EDGES","SMESH_TRIANGLES",
551 "SMESH_QUADRATIC_TRIANGLES","SMESH_QUADRANGLES","SMESH_QUADRATIC_QUADRANGLES",
552 "SMESH_BIQUADRATIC_QUADRANGLES","SMESH_POLYGONS","SMESH_QUADRATIC_POLYGONS",
553 "SMESH_TETRAHEDRA","SMESH_QUADRATIC_TETRAHEDRONS","SMESH_PYRAMIDS",
554 "SMESH_QUADRATIC_PYRAMIDS","SMESH_HEXAHEDRA","SMESH_QUADRATIC_HEXAHEDRONS",
555 "SMESH_TRIQUADRATIC_HEXAHEDRONS","SMESH_PENTAHEDRA","SMESH_QUADRATIC_PENTAHEDRONS",
556 "SMESH_OCTAHEDRA","SMESH_POLYEDRONS","SMESH_QUADRATIC_POLYEDRONS","SMESH_BALLS"
558 QString andStr = " " + QObject::tr("SMESH_AND") + " ", comma(", ");
559 for ( size_t iType = 0; iType < presentNotSupported.size(); ++iType ) {
560 typeNames += QObject::tr( typeMsg[ presentNotSupported[ iType ]]);
561 if ( iType != presentNotSupported.size() - 1 )
562 typeNames += ( iType == presentNotSupported.size() - 2 ) ? andStr : comma;
564 int aRet = SUIT_MessageBox::warning
565 (SMESHGUI::desktop(),
566 QObject::tr("SMESH_WRN_WARNING"),
567 QObject::tr("EXPORT_NOT_SUPPORTED").arg(aMeshName).arg(format).arg(typeNames),
568 QObject::tr("SMESH_BUT_YES"),
569 QObject::tr("SMESH_BUT_NO"), 0, 1);
574 // Get parameters of export operation
577 SMESH::MED_VERSION aFormat;
578 // Init the parameters with the default values
579 bool aIsASCII_STL = true;
580 bool toCreateGroups = false;
581 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
583 toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
584 bool toOverwrite = true;
586 QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
587 QString anInitialPath = "";
588 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
589 anInitialPath = QDir::currentPath();
591 // Get a file name to write in and additional otions
592 if ( isUNV || isDAT || isGMF ) // Export w/o options
595 aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
597 aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
599 aFilter = QObject::tr( "GMF_ASCII_FILES_FILTER" ) + " (*.mesh)" +
600 ";;" + QObject::tr( "GMF_BINARY_FILES_FILTER" ) + " (*.meshb)";
601 if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
602 aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
603 anInitialPath + QString("/") + aMeshName,
604 aFilter, aTitle, false);
606 else if ( isCGNS )// Export to CGNS
608 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
609 fd->setWindowTitle( aTitle );
610 fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
611 if ( !anInitialPath.isEmpty() )
612 fd->setDirectory( anInitialPath );
613 fd->selectFile(aMeshName);
614 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
615 fd->setValidator( fv );
618 aFilename = fd->selectedFile();
619 toOverwrite = fv->isOverwrite();
623 else if ( isSTL ) // Export to STL
625 QMap<QString, int> aFilterMap;
626 aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
627 aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
630 QMap<QString, int>::const_iterator it = aFilterMap.begin();
631 for ( ; it != aFilterMap.end(); ++it )
632 filters.push_back( it.key() );
634 SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
635 fd->setWindowTitle( aTitle );
636 fd->setNameFilters( filters );
637 fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
638 if ( !anInitialPath.isEmpty() )
639 fd->setDirectory( anInitialPath );
640 fd->selectFile(aMeshName);
644 aFilename = fd->selectedFile();
645 aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
650 else if ( isMED || isSAUV ) // Export to MED or SAUV
652 QMap<QString, SMESH::MED_VERSION> aFilterMap;
653 //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
655 QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
656 //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
657 aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
660 aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
661 aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
662 aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
666 QString aDefaultFilter;
667 QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
668 for ( ; it != aFilterMap.end(); ++it ) {
669 filters.push_back( it.key() );
670 if (it.value() == SMESH::MED_V2_2)
671 aDefaultFilter = it.key();
674 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
675 ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
676 fd->setWindowTitle( aTitle );
677 fd->setNameFilters( filters );
678 fd->selectNameFilter(aDefaultFilter);
679 fd->SetChecked(toCreateGroups);
680 if ( !anInitialPath.isEmpty() )
681 fd->setDirectory( anInitialPath );
682 fd->selectFile(aMeshName);
684 SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
685 fd->setValidator( fv );
690 aFilename = fd->selectedFile();
692 aFilename = QString::null;
695 aFormat = aFilterMap[fd->selectedNameFilter()];
696 toOverwrite = fv->isOverwrite();
698 if ( !aFilename.isEmpty() ) {
699 // med-2.1 does not support poly elements
700 if ( aFormat==SMESH::MED_V2_1 )
701 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
702 SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
703 SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
704 if ( nbElems[ SMESH::Entity_Polygon ] + nbElems[ SMESH::Entity_Quad_Polygon ] +
705 nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
707 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
708 QObject::tr("SMESH_WRN_WARNING"),
709 QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
710 QObject::tr("SMESH_BUT_YES"),
711 QObject::tr("SMESH_BUT_NO"), 0, 1);
719 // can't append to an existing using other format
720 SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
721 bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
722 if( !isVersionOk || aVersion != aFormat ) {
723 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
724 QObject::tr("SMESH_WRN_WARNING"),
725 QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
726 QObject::tr("SMESH_BUT_YES"),
727 QObject::tr("SMESH_BUT_NO"), 0, 1);
734 QStringList aMeshNamesCollisionList;
735 SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
736 for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
737 QString anExistingMeshName( aMeshNames[ i ] );
738 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
739 QString anExportMeshName = (*aMeshIter).second;
740 if( anExportMeshName == anExistingMeshName ) {
741 aMeshNamesCollisionList.append( anExportMeshName );
746 if( !aMeshNamesCollisionList.isEmpty() ) {
747 QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
748 int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
749 QObject::tr("SMESH_WRN_WARNING"),
750 QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
751 QObject::tr("SMESH_BUT_YES"),
752 QObject::tr("SMESH_BUT_NO"),
753 QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
762 toCreateGroups = fd->IsChecked();
772 if ( !aFilename.isEmpty() ) {
773 // Check whether the file already exists and delete it if yes
774 QFile aFile( aFilename );
775 if ( aFile.exists() && toOverwrite )
777 SUIT_OverrideCursor wc;
780 // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
781 // bool Renumber = false;
782 // // PAL 14172 : Check of we have to renumber or not from the preferences before export
784 // Renumber= resMgr->booleanValue("renumbering");
786 // SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
787 // aMeshEditor->RenumberNodes();
788 // aMeshEditor->RenumberElements();
789 // if ( SMESHGUI::automaticUpdate() )
790 // SMESH::UpdateView();
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 if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
800 aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
801 aFormat, toOverwrite && aMeshIndex == 0 );
803 aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
804 aFormat, toOverwrite && aMeshIndex == 0 );
809 for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
811 SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
812 if( !aMeshItem->_is_nil() )
813 aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
818 if ( aMeshOrGroup->_is_equivalent( aMesh ))
819 aMesh->ExportDAT( aFilename.toLatin1().data() );
821 aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
825 if ( aMeshOrGroup->_is_equivalent( aMesh ))
826 aMesh->ExportUNV( aFilename.toLatin1().data() );
828 aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
832 if ( aMeshOrGroup->_is_equivalent( aMesh ))
833 aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
835 aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
839 aMeshIter = aMeshList.begin();
840 for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
842 SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
843 SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh();
844 aMeshItem->ExportCGNS( aMeshOrGroup,
845 aFilename.toLatin1().data(),
846 toOverwrite && aMeshIndex == 0 );
851 aMesh->ExportGMF( aMeshOrGroup, aFilename.toLatin1().data() );
854 catch (const SALOME::SALOME_Exception& S_ex){
856 SUIT_MessageBox::warning(SMESHGUI::desktop(),
857 QObject::tr("SMESH_WRN_WARNING"),
858 QObject::tr("SMESH_EXPORT_FAILED"));
864 inline void InverseEntityMode(unsigned int& theOutputMode,
865 unsigned int theMode)
867 bool anIsNotPresent = ~theOutputMode & theMode;
869 theOutputMode |= theMode;
871 theOutputMode &= ~theMode;
874 void SetDisplayEntity(int theCommandID){
875 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
876 SALOME_ListIO selected;
878 aSel->selectedObjects( selected );
880 if(selected.Extent() >= 1){
881 SALOME_ListIteratorOfListIO It( selected );
882 for( ; It.More(); It.Next()){
883 Handle(SALOME_InteractiveObject) IObject = It.Value();
884 if(IObject->hasEntry()){
885 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
886 unsigned int aMode = anActor->GetEntityMode();
887 switch(theCommandID){
889 InverseEntityMode(aMode,SMESH_Actor::eBallElem);
892 InverseEntityMode(aMode,SMESH_Actor::e0DElements);
895 InverseEntityMode(aMode,SMESH_Actor::eEdges);
898 InverseEntityMode(aMode,SMESH_Actor::eFaces);
901 InverseEntityMode(aMode,SMESH_Actor::eVolumes);
904 aMode = SMESH_Actor::eAllEntity;
908 anActor->SetEntityMode(aMode);
916 SALOME_ListIO selected;
917 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
921 LightApp_SelectionMgr* aSel = app->selectionMgr();
922 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
923 if( !aSel || !appStudy )
926 aSel->selectedObjects( selected );
927 if( selected.IsEmpty() )
930 Handle(SALOME_InteractiveObject) anIObject = selected.First();
932 _PTR(Study) aStudy = appStudy->studyDS();
933 _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
934 SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
935 if( aMainObject->_is_nil() )
938 aMainObject->SetAutoColor( true ); // mesh groups are re-colored here
940 SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
941 for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
943 SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
944 SALOMEDS::Color aColor = aGroupObject->GetColor();
945 _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
949 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
950 switch ( aGroupObject->GetType ()) {
952 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break;
954 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break;
956 anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break;
958 anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break;
960 SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100");
961 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break;
964 SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
965 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
971 SMESH::RepaintCurrentView();
974 QString functorToString( SMESH::Controls::FunctorPtr f )
976 QString type = QObject::tr( "UNKNOWN_CONTROL" );
977 if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
978 type = QObject::tr( "VOLUME_3D_ELEMENTS" );
979 else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
980 type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
981 else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
982 type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
983 else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
984 type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
985 else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
986 type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
987 else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
988 type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
989 else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
990 type = QObject::tr( "WARP_ELEMENTS" );
991 else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
992 type = QObject::tr( "TAPER_ELEMENTS" );
993 else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
994 type = QObject::tr( "SKEW_ELEMENTS" );
995 else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
996 type = QObject::tr( "AREA_ELEMENTS" );
997 else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
998 type = QObject::tr( "LENGTH_EDGES" );
999 else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
1000 type = QObject::tr( "LENGTH2D_EDGES" );
1001 else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
1002 type = QObject::tr( "MULTI_BORDERS" );
1003 else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
1004 type = QObject::tr( "MULTI2D_BORDERS" );
1005 else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
1006 type = QObject::tr( "FREE_NODES" );
1007 else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
1008 type = QObject::tr( "FREE_EDGES" );
1009 else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
1010 type = QObject::tr( "FREE_BORDERS" );
1011 else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
1012 type = QObject::tr( "FREE_FACES" );
1013 else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
1014 type = QObject::tr( "BARE_BORDER_VOLUME" );
1015 else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
1016 type = QObject::tr( "BARE_BORDER_FACE" );
1017 else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
1018 type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
1019 else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
1020 type = QObject::tr( "OVER_CONSTRAINED_FACE" );
1021 else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
1022 type = QObject::tr( "EQUAL_NODE" );
1023 else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
1024 type = QObject::tr( "EQUAL_EDGE" );
1025 else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
1026 type = QObject::tr( "EQUAL_FACE" );
1027 else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
1028 type = QObject::tr( "EQUAL_VOLUME" );
1032 void SaveDistribution()
1034 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1035 SALOME_ListIO selected;
1037 aSel->selectedObjects( selected );
1039 if ( selected.Extent() == 1 ) {
1040 Handle(SALOME_InteractiveObject) anIO = selected.First();
1041 if ( anIO->hasEntry() ) {
1042 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1043 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1044 SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
1045 SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
1046 if ( aScalarBarActor && aFunctor ) {
1047 SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
1049 std::vector<int> elements;
1050 SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
1051 if ( mesh->_is_nil() ) {
1052 SMESH::SMESH_IDSource_var idSource =
1053 SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
1054 if ( !idSource->_is_nil() )
1056 SMESH::long_array_var ids = idSource->GetIDs();
1057 elements.resize( ids->length() );
1058 for ( unsigned i = 0; i < elements.size(); ++i )
1059 elements[i] = ids[i];
1062 int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
1063 vtkLookupTable* lookupTable =
1064 static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
1065 double * minmax = lookupTable->GetRange();
1066 std::vector<int> nbEvents;
1067 std::vector<double> funValues;
1068 aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
1069 QString anInitialPath = "";
1070 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
1071 anInitialPath = QDir::currentPath();
1072 QString aMeshName = anIO->getName();
1074 filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
1075 filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
1076 QString aFilename = anInitialPath + "/" + aMeshName + "_" +
1077 functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
1078 aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
1081 QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
1083 if ( !aFilename.isEmpty() ) {
1084 QFile f( aFilename );
1085 if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
1086 QTextStream out( &f );
1087 out << "# Mesh: " << aMeshName << endl;
1088 out << "# Control: " << functorToString( aFunctor ) << endl;
1090 out.setFieldWidth( 10 );
1091 for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
1092 out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
1103 void ShowDistribution() {
1104 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1105 SALOME_ListIO selected;
1107 aSel->selectedObjects( selected );
1109 if ( selected.Extent() == 1 ) {
1110 Handle(SALOME_InteractiveObject) anIO = selected.First();
1111 if ( anIO->hasEntry() ) {
1112 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1113 if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1114 SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
1115 aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
1121 #ifndef DISABLE_PLOT2DVIEWER
1122 void PlotDistribution() {
1123 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1127 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1128 SALOME_ListIO selected;
1130 aSel->selectedObjects( selected );
1132 if ( selected.Extent() == 1 ) {
1133 Handle(SALOME_InteractiveObject) anIO = selected.First();
1134 if ( anIO->hasEntry() ) {
1135 //Find Actor by entry before getting Plot2d viewer,
1136 //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
1137 SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1139 SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary
1144 SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
1148 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1152 if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
1153 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1154 QString functorName = functorToString( anActor->GetFunctor());
1155 QString aHistogramName("%1 : %2");
1156 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1157 aHistogram->setName(aHistogramName);
1158 aHistogram->setHorTitle(functorName);
1159 aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
1160 aPlot->displayObject(aHistogram, true);
1165 #endif //DISABLE_PLOT2DVIEWER
1167 void DisableAutoColor(){
1168 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1169 SALOME_ListIO selected;
1171 aSel->selectedObjects( selected );
1173 if(selected.Extent()){
1174 Handle(SALOME_InteractiveObject) anIObject = selected.First();
1175 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
1176 if ( !aMesh->_is_nil() ) {
1177 aMesh->SetAutoColor( false );
1182 void SetDisplayMode(int theCommandID, SMESHGUI_StudyId2MarkerMap& theMarkerMap)
1184 SALOME_ListIO selected;
1185 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
1189 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1190 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
1191 if( !aSel || !appStudy )
1194 if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
1195 if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
1196 aModule->EmitSignalDeactivateDialog();
1197 if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
1198 (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
1203 _PTR(Study) aStudy = appStudy->studyDS();
1205 aSel->selectedObjects( selected );
1207 if(selected.Extent() >= 1){
1208 switch(theCommandID){
1210 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1211 (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
1215 vtkFloatingPointType color[3];
1216 QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor;
1217 QColor orientationColor, outlineColor, volumeColor;
1218 int deltaF = 0, deltaV = 0;
1222 int outlineWidth = 1;
1223 vtkFloatingPointType shrinkCoef = 0.0;
1224 vtkFloatingPointType orientationScale = 0.0;
1225 bool orientation3d = false;
1226 VTK::MarkerType markerType = VTK::MT_NONE;
1227 VTK::MarkerScale markerScale = VTK::MS_NONE;
1229 bool hasNodes = false;
1230 int presentEntities = 0;
1231 bool firstTime = true;
1233 SALOME_ListIteratorOfListIO It( selected );
1234 for ( ; It.More(); It.Next() ) {
1235 Handle(SALOME_InteractiveObject) IObject = It.Value();
1236 if ( !IObject->hasEntry() ) continue;
1237 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1238 if ( !anActor || !anActor->GetObject() ) continue;
1241 // nodes: color, marker
1242 anActor->GetNodeColor( color[0], color[1], color[2] );
1243 nodeColor.setRgbF( color[0], color[1], color[2] );
1244 markerType = anActor->GetMarkerType();
1245 markerScale = anActor->GetMarkerScale();
1246 markerId = anActor->GetMarkerTexture();
1247 // edges: color, width
1248 anActor->GetEdgeColor( color[0], color[1], color[2] );
1249 edgeColor.setRgbF( color[0], color[1], color[2] );
1250 edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1
1251 // faces: front color, back color (delta)
1252 anActor->GetSufaceColor( color[0], color[1], color[2], deltaF );
1253 faceColor.setRgbF( color[0], color[1], color[2] );
1254 // faces: front color, back color (delta)
1255 anActor->GetVolumeColor( color[0], color[1], color[2], deltaV );
1256 volumeColor.setRgbF( color[0], color[1], color[2] );
1257 // 0d elements: color, size
1258 anActor->Get0DColor( color[0], color[1], color[2] );
1259 elem0dColor.setRgbF( color[0], color[1], color[2] );
1260 elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1
1261 // balls: color, size
1262 anActor->GetBallColor( color[0], color[1], color[2] );
1263 ballColor.setRgbF( color[0], color[1], color[2] );
1264 ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
1266 anActor->GetOutlineColor( color[0], color[1], color[2] );
1267 outlineColor.setRgbF( color[0], color[1], color[2] );
1268 outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1
1269 // orientation vectors: color, scale, 3d flag
1270 anActor->GetFacesOrientationColor( color[0], color[1], color[2] );
1271 orientationColor.setRgbF( color[0], color[1], color[2] );
1272 orientationScale = anActor->GetFacesOrientationScale();
1273 orientation3d = anActor->GetFacesOrientation3DVectors();
1275 shrinkCoef = anActor->GetShrinkFactor();
1278 firstTime = false; // we only take properties from first object (for performance reasons)
1281 hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node );
1282 if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) )
1283 presentEntities = presentEntities | SMESH_Actor::eEdges;
1284 if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) )
1285 presentEntities = presentEntities | SMESH_Actor::eFaces;
1286 if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) )
1287 presentEntities = presentEntities | SMESH_Actor::eVolumes;
1288 if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) )
1289 presentEntities = presentEntities | SMESH_Actor::e0DElements;
1290 if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) )
1291 presentEntities = presentEntities | SMESH_Actor::eBallElem;
1293 // as we know that all types of elements are present, we can exit the loop
1294 if ( presentEntities == SMESH_Actor::eAllEntity )
1298 SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() );
1299 // nodes: color, marker
1300 dlg.setNodeColor( nodeColor );
1301 if( markerType != VTK::MT_USER )
1302 dlg.setNodeMarker( markerType, markerScale );
1304 dlg.setNodeCustomMarker( markerId );
1305 // edges: color, line width
1306 dlg.setEdgeColor( edgeColor );
1307 dlg.setEdgeWidth( edgeWidth );
1308 // faces: front color, back color
1309 dlg.setFaceColor( faceColor, deltaF );
1310 // volumes: normal color, reversed color
1311 dlg.setVolumeColor( volumeColor, deltaV );
1312 // outlines: color, line width
1313 dlg.setOutlineColor( outlineColor );
1314 dlg.setOutlineWidth( outlineWidth );
1315 // 0d elements: color, size
1316 dlg.setElem0dColor( elem0dColor );
1317 dlg.setElem0dSize( elem0dSize );
1318 // balls: color, size
1319 dlg.setBallColor( ballColor );
1320 dlg.setBallSize( ballSize );
1321 // orientation: color, scale, 3d flag
1322 dlg.setOrientationColor( orientationColor );
1323 dlg.setOrientationSize( int( orientationScale * 100. ) );
1324 dlg.setOrientation3d( orientation3d );
1325 // shrink: scale factor
1326 dlg.setShrinkCoef( int( shrinkCoef * 100. ) );
1327 // hide unused controls
1328 dlg.showControls( presentEntities, hasNodes );
1331 nodeColor = dlg.nodeColor();
1332 markerType = dlg.nodeMarkerType();
1333 markerScale = dlg.nodeMarkerScale();
1334 markerId = dlg.nodeMarkerId();
1335 edgeColor = dlg.edgeColor();
1336 edgeWidth = dlg.edgeWidth();
1337 faceColor = dlg.faceColor();
1338 deltaF = dlg.faceColorDelta();
1339 volumeColor = dlg.volumeColor();
1340 deltaV = dlg.volumeColorDelta();
1341 outlineColor = dlg.outlineColor();
1342 outlineWidth = dlg.outlineWidth();
1343 elem0dColor = dlg.elem0dColor();
1344 elem0dSize = dlg.elem0dSize();
1345 ballColor = dlg.ballColor();
1346 ballSize = dlg.ballSize();
1347 orientationColor = dlg.orientationColor();
1348 orientationScale = dlg.orientationSize() / 100.;
1349 orientation3d = dlg.orientation3d();
1350 shrinkCoef = dlg.shrinkCoef() / 100.;
1352 // store point markers map that might be changed by the user
1353 theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers();
1355 // set properties from dialog box to the presentations
1356 SALOME_ListIteratorOfListIO It( selected );
1357 for ( ; It.More(); It.Next() ) {
1358 Handle(SALOME_InteractiveObject) IObject = It.Value();
1359 if ( !IObject->hasEntry() ) continue;
1360 SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() );
1361 if ( !anActor ) continue;
1363 // nodes: color, marker
1364 anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
1365 if ( markerType != VTK::MT_USER ) {
1366 anActor->SetMarkerStd( markerType, markerScale );
1369 const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ];
1370 VTK::MarkerMap::const_iterator iter = markerMap.find( markerId );
1371 if ( iter != markerMap.end() )
1372 anActor->SetMarkerTexture( markerId, iter->second.second );
1374 // volumes: normal color, reversed color (delta)
1375 anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
1376 // faces: front color, back color (delta)
1377 anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
1378 // edges: color, width
1379 anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
1380 anActor->SetLineWidth( edgeWidth );
1382 anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
1383 anActor->SetOutlineWidth( outlineWidth );
1384 // 0D elements: color, size
1385 anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
1386 anActor->Set0DSize( elem0dSize );
1387 // balls: color, size
1388 anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
1389 anActor->SetBallSize( ballSize );
1390 // orientation: color, scale, 3d flag
1391 anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
1392 anActor->SetFacesOrientationScale( orientationScale );
1393 anActor->SetFacesOrientation3DVectors( orientation3d );
1395 anActor->SetShrinkFactor( shrinkCoef );
1397 // for groups, set also proper color
1398 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
1399 if ( !aGroupObject->_is_nil() ) {
1400 SMESH::ElementType anElementType = aGroupObject->GetType();
1402 switch( anElementType ) {
1404 aColor = nodeColor; break;
1406 aColor = edgeColor; break;
1408 aColor = faceColor; break;
1410 aColor = volumeColor; break;
1412 aColor = elem0dColor; break;
1414 aColor = ballColor; break;
1418 if ( aColor.isValid() ) {
1419 SALOMEDS::Color aGroupColor;
1420 aGroupColor.R = aColor.redF();
1421 aGroupColor.G = aColor.greenF();
1422 aGroupColor.B = aColor.blueF();
1423 aGroupObject->SetColor( aGroupColor );
1425 } // if ( !aGroupObject->_is_nil() )
1426 } // for ( ; It.More(); It.Next() )
1427 SMESH::RepaintCurrentView();
1428 } // if ( dlg.exec() )
1431 } // switch(theCommandID)
1432 SALOME_ListIteratorOfListIO It( selected );
1433 for( ; It.More(); It.Next()){
1434 Handle(SALOME_InteractiveObject) IObject = It.Value();
1435 if(IObject->hasEntry()){
1436 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
1437 switch(theCommandID){
1439 anActor->SetRepresentation(SMESH_Actor::eEdge);
1442 anActor->SetRepresentation(SMESH_Actor::eSurface);
1445 if(anActor->IsShrunk())
1446 anActor->UnShrink();
1448 anActor->SetShrink();
1451 anActor->SetRepresentation(SMESH_Actor::ePoint);
1454 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
1455 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
1458 if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
1459 anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
1465 SMESH::RepaintCurrentView();
1469 void Control( int theCommandID )
1471 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1472 SALOME_ListIO selected;
1474 aSel->selectedObjects( selected );
1476 if( !selected.IsEmpty() ){
1477 Handle(SALOME_InteractiveObject) anIO = selected.First();
1479 SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
1480 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
1481 switch ( theCommandID ){
1483 aControl = SMESH_Actor::eLength;
1486 aControl = SMESH_Actor::eLength2D;
1489 aControl = SMESH_Actor::eFreeEdges;
1492 aControl = SMESH_Actor::eFreeBorders;
1495 aControl = SMESH_Actor::eMultiConnection;
1498 aControl = SMESH_Actor::eFreeNodes;
1501 aControl = SMESH_Actor::eMultiConnection2D;
1504 aControl = SMESH_Actor::eArea;
1507 aControl = SMESH_Actor::eTaper;
1510 aControl = SMESH_Actor::eAspectRatio;
1513 aControl = SMESH_Actor::eAspectRatio3D;
1516 aControl = SMESH_Actor::eMinimumAngle;
1519 aControl = SMESH_Actor::eWarping;
1522 aControl = SMESH_Actor::eSkew;
1525 aControl = SMESH_Actor::eVolume3D;
1528 aControl = SMESH_Actor::eFreeFaces;
1531 aControl = SMESH_Actor::eMaxElementLength2D;
1534 aControl = SMESH_Actor::eMaxElementLength3D;
1537 aControl = SMESH_Actor::eBareBorderVolume;
1540 aControl = SMESH_Actor::eBareBorderFace;
1543 aControl = SMESH_Actor::eOverConstrainedVolume;
1546 aControl = SMESH_Actor::eOverConstrainedFace;
1549 aControl = SMESH_Actor::eCoincidentNodes;
1552 aControl = SMESH_Actor::eCoincidentElems1D;
1555 aControl = SMESH_Actor:: eCoincidentElems2D;
1558 aControl = SMESH_Actor::eCoincidentElems3D;
1562 anActor->SetControlMode(aControl);
1563 anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
1564 SMESH::RepaintCurrentView();
1565 #ifndef DISABLE_PLOT2DVIEWER
1566 if(anActor->GetPlot2Histogram()) {
1567 SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
1568 QString functorName = functorToString( anActor->GetFunctor());
1569 QString aHistogramName("%1 : %2");
1570 aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
1571 aHistogram->setName(aHistogramName);
1572 aHistogram->setHorTitle(functorName);
1573 SMESH::ProcessIn2DViewers(anActor);
1582 bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
1583 SMESH::MeshObjectType theType,
1584 const QString theInTypeName,
1585 QString & theOutTypeName)
1587 SMESH_TypeFilter aTypeFilter( theType );
1589 if( !theIO.IsNull() )
1591 entry = theIO->getEntry();
1592 LightApp_DataOwner owner( entry );
1593 if ( aTypeFilter.isOk( &owner )) {
1594 theOutTypeName = theInTypeName;
1602 QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
1604 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1605 _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
1607 _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
1608 CORBA::String_var anID = aSComp->GetID().c_str();
1609 if (!strcmp(anID.in(),theIO->getEntry()))
1615 CheckOIType ( theIO, SMESH::HYPOTHESIS, "Hypothesis", aTypeName ) ||
1616 CheckOIType ( theIO, SMESH::ALGORITHM, "Algorithm", aTypeName ) ||
1617 CheckOIType ( theIO, SMESH::MESH, "Mesh", aTypeName ) ||
1618 CheckOIType ( theIO, SMESH::SUBMESH, "SubMesh", aTypeName ) ||
1619 CheckOIType ( theIO, SMESH::GROUP, "Group", aTypeName )
1627 QString CheckHomogeneousSelection()
1629 //SUIT_Study* aStudy = SMESH::GetActiveStudy();
1630 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
1631 SALOME_ListIO selected;
1633 aSel->selectedObjects( selected );
1635 QString RefType = CheckTypeObject(selected.First());
1636 SALOME_ListIteratorOfListIO It(selected);
1637 for ( ; It.More(); It.Next())
1639 Handle(SALOME_InteractiveObject) IObject = It.Value();
1640 QString Type = CheckTypeObject(IObject);
1641 if (Type.compare(RefType) != 0)
1642 return "Heterogeneous Selection";
1649 void SMESHGUI::OnEditDelete()
1651 // VSR 17/11/04: check if all objects selected belong to SMESH component --> start
1652 LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
1653 SALOME_ListIO selected; aSel->selectedObjects( selected, QString::null, false );
1655 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1656 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
1657 _PTR(GenericAttribute) anAttr;
1658 _PTR(AttributeIOR) anIOR;
1660 int objectCount = 0;
1662 QString aParentComponent = QString::null;
1663 Handle(SALOME_InteractiveObject) anIO;
1664 for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
1666 anIO = anIt.Value();
1667 QString cur = anIO->getComponentDataType();
1668 _PTR(SObject) aSO = aStudy->FindObjectID(anIO->getEntry());
1670 // check if object is reference
1671 _PTR(SObject) aRefSObj;
1672 aNameList.append("\n - ");
1673 if ( aSO->ReferencedObject( aRefSObj ) ) {
1674 QString aRefName = QString::fromStdString ( aRefSObj->GetName() );
1675 aNameList.append( aRefName );
1676 cur = QString::fromStdString ( aRefSObj->GetFatherComponent()->ComponentDataType() );
1679 aNameList.append(anIO->getName());
1683 if( aParentComponent.isNull() )
1684 aParentComponent = cur;
1685 else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
1686 aParentComponent = "";
1689 if ( objectCount == 0 )
1690 return; // No Valid Objects Selected
1692 if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
1693 SUIT_MessageBox::warning( SMESHGUI::desktop(),
1694 QObject::tr("ERR_ERROR"),
1695 QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ) );
1698 // VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
1699 if (SUIT_MessageBox::warning
1700 (SMESHGUI::desktop(),
1701 QObject::tr("SMESH_WRN_WARNING"),
1702 QObject::tr("SMESH_REALLY_DELETE").arg( objectCount ).arg( aNameList ),
1703 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1704 SUIT_MessageBox::Yes) != SUIT_MessageBox::Yes)
1707 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1709 // Put the whole hierarchy of sub-objects of the selected SO's into a list and
1710 // then treat them all starting from the deepest objects (at list back)
1711 std::list< _PTR(SObject) > listSO;
1712 SALOME_ListIteratorOfListIO It(selected);
1713 for( ; It.More(); It.Next()) // loop on selected IO's
1715 Handle(SALOME_InteractiveObject) IObject = It.Value();
1716 if(IObject->hasEntry()) {
1717 _PTR(SObject) aSO = aStudy->FindObjectID(IObject->getEntry());
1719 // disable removal of "SMESH" component object
1720 if(aSO->FindAttribute(anAttr, "AttributeIOR")){
1722 if ( engineIOR() == anIOR->Value().c_str() )
1725 //Check the referenced object
1726 _PTR(SObject) aRefSObject;
1727 if ( aSO && aSO->ReferencedObject( aRefSObject ) )
1728 aSO = aRefSObject; // Delete main Object instead of reference
1730 listSO.push_back( aSO );
1731 std::list< _PTR(SObject) >::iterator itSO = listSO.begin();
1732 for ( ; itSO != listSO.end(); ++itSO ) {
1733 _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
1734 for (it->InitEx(false); it->More(); it->Next())
1735 listSO.push_back( it->Value() );
1739 // Check if none of objects to delete is referred from outside
1740 std::list< _PTR(SObject) >::reverse_iterator ritSO;
1741 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1743 _PTR(SObject) SO = *ritSO;
1744 if ( !SO ) continue;
1745 std::vector<_PTR(SObject)> aReferences = aStudy->FindDependances( *ritSO );
1746 for (size_t i = 0; i < aReferences.size(); i++) {
1747 _PTR(SComponent) aComponent = aReferences[i]->GetFatherComponent();
1748 std::string type = aComponent->ComponentDataType();
1749 if ( type != "SMESH" )
1751 SUIT_MessageBox::warning( anApp->desktop(),
1752 QObject::tr("WRN_WARNING"),
1753 QObject::tr("DEP_OBJECT") );
1754 return; // outside SMESH, there is an object depending on a SMESH object
1759 // Treat SO's in the list starting from the back
1760 aStudyBuilder->NewCommand(); // There is a transaction
1761 for ( ritSO = listSO.rbegin(); ritSO != listSO.rend(); ++ritSO )
1763 _PTR(SObject) SO = *ritSO;
1764 if ( !SO ) continue;
1765 std::string anEntry = SO->GetID();
1767 /** Erase graphical object **/
1768 if(SO->FindAttribute(anAttr, "AttributeIOR")){
1769 ViewManagerList aViewMenegers = anApp->viewManagers();
1770 ViewManagerList::const_iterator it = aViewMenegers.begin();
1771 for( ; it != aViewMenegers.end(); it++) {
1772 SUIT_ViewManager* vm = *it;
1773 int nbSf = vm ? vm->getViewsCount() : 0;
1775 QVector<SUIT_ViewWindow*> aViews = vm->getViews();
1776 for(int i = 0; i < nbSf; i++){
1777 SUIT_ViewWindow *sf = aViews[i];
1778 if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
1779 SMESH::RemoveActor(sf,anActor);
1785 /** Remove an object from data structures **/
1786 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
1787 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( SO ));
1788 if ( !aGroup->_is_nil() ) { // DELETE GROUP
1789 SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
1790 aMesh->RemoveGroup( aGroup );
1792 else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
1793 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
1794 aMesh->RemoveSubMesh( aSubMesh );
1796 _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
1798 SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
1801 Handle(SALOME_InteractiveObject) IObject = new SALOME_InteractiveObject
1802 ( anEntry.c_str(), engineIOR().toLatin1().data(), SO->GetName().c_str() );
1803 QString objType = CheckTypeObject(IObject);
1804 if ( objType == "Hypothesis" || objType == "Algorithm" ) {// DELETE HYPOTHESIS
1805 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
1806 aStudyBuilder->RemoveObjectWithChildren( SO );
1808 else {// default action: remove SObject from the study
1809 // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
1810 //SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
1812 aStudyBuilder->RemoveObjectWithChildren( SO );
1816 } /* listSO back loop */
1818 aStudyBuilder->CommitCommand();
1820 /* Clear any previous selection */
1822 aSel->setSelectedObjects( l1 );
1824 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
1829 SMESHGUI_EXPORT CAM_Module* createModule()
1831 return new SMESHGUI();
1834 SMESHGUI_EXPORT char* getModuleVersion() {
1835 return (char*)SMESH_VERSION_STR;
1839 SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil();
1841 //=============================================================================
1845 //=============================================================================
1846 SMESHGUI::SMESHGUI() :
1847 SalomeApp_Module( "SMESH" ),
1848 LightApp_Module( "SMESH" )
1850 if ( CORBA::is_nil( myComponentSMESH ) )
1852 CORBA::Boolean anIsEmbeddedMode;
1853 myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
1854 MESSAGE("-------------------------------> anIsEmbeddedMode=" << anIsEmbeddedMode);
1856 // 0019923: EDF 765 SMESH : default values of hypothesis
1857 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
1858 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
1859 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
1860 nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
1861 myComponentSMESH->SetDefaultNbSegments( nbSeg );
1863 const char* options[] = { "historical_python_dump", "forget_mesh_on_hyp_modif" };
1864 for ( size_t i = 0; i < sizeof(options)/sizeof(char*); ++i )
1865 if ( aResourceMgr->hasValue( "SMESH", options[i] ))
1867 QString val = aResourceMgr->stringValue( "SMESH", options[i] );
1868 myComponentSMESH->SetOption( options[i], val.toLatin1().constData() );
1872 myActiveDialogBox = 0;
1873 myFilterLibraryDlg = 0;
1877 myEventCallbackCommand = vtkCallbackCommand::New();
1878 myEventCallbackCommand->Delete();
1879 myEventCallbackCommand->SetClientData( this );
1880 myEventCallbackCommand->SetCallback( SMESHGUI::ProcessEvents );
1883 SMESH::GetFilterManager();
1884 SMESH::GetPattern();
1885 SMESH::GetMeasurements();
1887 /* load resources for all available meshers */
1888 SMESH::InitAvailableHypotheses();
1891 //=============================================================================
1895 //=============================================================================
1896 SMESHGUI::~SMESHGUI()
1898 #ifdef WITHGENERICOBJ
1899 SMESH::GetFilterManager()->UnRegister();
1900 SMESH::GetMeasurements()->UnRegister();
1902 SMESH::GetFilterManager() = SMESH::FilterManager::_nil();
1903 SMESH::GetMeasurements() = SMESH::Measurements::_nil();
1906 //=============================================================================
1910 //=============================================================================
1911 LightApp_SelectionMgr* SMESHGUI::selectionMgr()
1913 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1915 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1920 //=============================================================================
1924 //=============================================================================
1925 bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded)
1927 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
1931 bool autoUpdate = resMgr->booleanValue( "SMESH", "auto_update", false );
1932 long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 );
1933 bool exceeded = updateLimit > 0 && requestedSize > updateLimit;
1934 if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded;
1935 return autoUpdate && !exceeded;
1938 //=============================================================================
1942 //=============================================================================
1943 SUIT_ResourceMgr* SMESHGUI::resourceMgr()
1945 return dynamic_cast<SUIT_ResourceMgr*>( SUIT_Session::session()->resourceMgr() );
1948 //=============================================================================
1952 //=============================================================================
1953 SMESHGUI* SMESHGUI::GetSMESHGUI()
1955 SMESHGUI* smeshMod = 0;
1956 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
1959 CAM_Module* module = app->module( "Mesh" );
1960 smeshMod = dynamic_cast<SMESHGUI*>( module );
1963 if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() )
1965 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( smeshMod->application()->activeStudy() );
1968 _PTR(Study) aStudy = study->studyDS();
1970 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
1979 Standard_EXPORT SMESHGUI* GetComponentGUI()
1981 return SMESHGUI::GetSMESHGUI();
1985 //=============================================================================
1989 //=============================================================================
1990 void SMESHGUI::SetState(int aState)
1995 //=============================================================================
1999 //=============================================================================
2000 void SMESHGUI::ResetState()
2005 //=============================================================================
2009 //=============================================================================
2010 void SMESHGUI::EmitSignalDeactivateDialog()
2012 emit SignalDeactivateActiveDialog();
2015 //=============================================================================
2019 //=============================================================================
2020 void SMESHGUI::EmitSignalStudyFrameChanged()
2022 emit SignalStudyFrameChanged();
2025 //=============================================================================
2029 //=============================================================================
2030 void SMESHGUI::EmitSignalCloseAllDialogs()
2032 emit SignalCloseAllDialogs();
2035 //=============================================================================
2039 //=============================================================================
2040 void SMESHGUI::EmitSignalVisibilityChanged()
2042 emit SignalVisibilityChanged();
2045 //=============================================================================
2049 //=============================================================================
2050 QDialog *SMESHGUI::GetActiveDialogBox()
2052 return myActiveDialogBox;
2055 //=============================================================================
2059 //=============================================================================
2060 void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2062 myActiveDialogBox = (QDialog *) aDlg;
2066 //=============================================================================
2070 //=============================================================================
2071 SUIT_Desktop* SMESHGUI::desktop()
2073 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2075 return app->desktop();
2080 //=============================================================================
2084 //=============================================================================
2085 SalomeApp_Study* SMESHGUI::activeStudy()
2087 SUIT_Application* app = SUIT_Session::session()->activeApplication();
2089 return dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
2094 //=============================================================================
2098 //=============================================================================
2099 void SMESHGUI::Modified( bool theIsUpdateActions )
2101 if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) ) {
2102 if( SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) ) {
2103 appStudy->Modified();
2104 if( theIsUpdateActions )
2105 app->updateActions();
2110 //=============================================================================
2114 //=============================================================================
2115 bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2117 /* Here the position is on the bottom right corner - 10 */
2118 // aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
2120 SUIT_Desktop *PP = desktop();
2121 x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
2122 y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
2126 //=============================================================================
2130 //=============================================================================
2131 static int isStudyLocked(_PTR(Study) theStudy){
2132 return theStudy->GetProperties()->IsLocked();
2135 static bool checkLock(_PTR(Study) theStudy) {
2136 if (isStudyLocked(theStudy)) {
2137 SUIT_MessageBox::warning( SMESHGUI::desktop(),
2138 QObject::tr("WRN_WARNING"),
2139 QObject::tr("WRN_STUDY_LOCKED") );
2145 //=======================================================================
2146 //function : CheckActiveStudyLocked
2148 //=======================================================================
2150 bool SMESHGUI::isActiveStudyLocked()
2152 _PTR(Study) aStudy = activeStudy()->studyDS();
2153 return checkLock( aStudy );
2156 //=============================================================================
2160 //=============================================================================
2161 bool SMESHGUI::OnGUIEvent( int theCommandID )
2163 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
2167 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2168 SUIT_ResourceMgr* mgr = resourceMgr();
2172 if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
2173 GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
2176 SUIT_ViewWindow* view = application()->desktop()->activeWindow();
2177 SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
2179 //QAction* act = action( theCommandID );
2181 switch (theCommandID) {
2183 if(checkLock(aStudy)) break;
2195 if(checkLock(aStudy)) break;
2196 ::ImportMeshesFromFile(GetSMESHGen(),theCommandID);
2200 case 150: //MED FILE INFORMATION
2202 SALOME_ListIO selected;
2203 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2205 aSel->selectedObjects( selected );
2206 if( selected.Extent() )
2208 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2209 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
2210 if ( !aMesh->_is_nil() )
2212 SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
2219 case 122: // EXPORT MED
2234 ::ExportMeshToFile(theCommandID);
2238 case 200: // SCALAR BAR
2240 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2241 SALOME_ListIO selected;
2243 aSel->selectedObjects( selected );
2245 if( selected.Extent() ) {
2246 Handle(SALOME_InteractiveObject) anIO = selected.First();
2247 if( anIO->hasEntry() ) {
2248 if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
2249 anActor->SetControlMode( SMESH_Actor::eNone );
2250 #ifndef DISABLE_PLOT2DVIEWER
2251 SMESH::ProcessIn2DViewers(anActor,SMESH::RemoveFrom2dViewer);
2260 SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
2265 // dump control distribution data to the text file
2266 ::SaveDistribution();
2272 // show/ distribution
2273 ::ShowDistribution();
2277 #ifndef DISABLE_PLOT2DVIEWER
2280 // plot distribution
2281 ::PlotDistribution();
2292 ::DisableAutoColor();
2295 case 1134: // Clipping
2296 case 1133: // Tranparency
2297 case 1132: // Display preferences (colors, shrink size, line width, ...)
2304 ::SetDisplayMode(theCommandID, myMarkerMap);
2307 //2D quadratic representation
2310 ::SetDisplayMode(theCommandID, myMarkerMap);
2314 case 216: // 0D elements
2317 case 219: // Volumes
2318 case 220: // All Entity
2320 ::SetDisplayEntity(theCommandID);
2323 case 221: // Orientation of faces
2325 LightApp_SelectionMgr* mgr = selectionMgr();
2326 SALOME_ListIO selected; mgr->selectedObjects( selected );
2328 SALOME_ListIteratorOfListIO it(selected);
2329 for( ; it.More(); it.Next()) {
2330 Handle(SALOME_InteractiveObject) anIObject = it.Value();
2331 if(anIObject->hasEntry()) {
2332 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2333 anActor->SetFacesOriented( !anActor->GetFacesOriented() );
2342 if(checkLock(aStudy)) break;
2344 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2347 SMESH::UpdateView();
2349 catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
2350 SMESH::OnVisuException();
2352 catch (...) { // PAL16774 (Crash after display of many groups)
2353 SMESH::OnVisuException();
2357 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2358 aSel->selectedObjects( l );
2359 aSel->setSelectedObjects( l );
2364 case 301: // DISPLAY
2365 case 302: // DISPLAY ONLY
2367 SMESH::EDisplaing anAction;
2368 switch (theCommandID) {
2369 case 300: anAction = SMESH::eErase; break;
2370 case 301: anAction = SMESH::eDisplay; break;
2371 case 302: anAction = SMESH::eDisplayOnly; break;
2374 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2375 SALOME_ListIO sel_objects, to_process;
2377 aSel->selectedObjects( sel_objects );
2379 if( theCommandID==302 )
2381 MESSAGE("anAction = SMESH::eDisplayOnly");
2382 startOperation( myEraseAll );
2385 extractContainers( sel_objects, to_process );
2388 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2392 SALOME_ListIteratorOfListIO It( to_process );
2393 for ( ; It.More(); It.Next()) {
2395 Handle(SALOME_InteractiveObject) IOS = It.Value();
2396 if (IOS->hasEntry()) {
2398 if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
2399 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2400 break; // PAL16774 (Crash after display of many groups)
2402 if (anAction == SMESH::eDisplayOnly)
2404 MESSAGE("anAction = SMESH::eDisplayOnly");
2405 anAction = SMESH::eDisplay;
2411 // PAL13338 + PAL15161 -->
2412 if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
2413 MESSAGE("anAction = SMESH::eDisplayOnly");
2414 SMESH::UpdateView();
2415 SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
2417 // PAL13338 + PAL15161 <--
2419 catch (...) { // PAL16774 (Crash after display of many groups)
2420 SMESH::OnVisuException();
2423 if (anAction == SMESH::eErase) {
2424 MESSAGE("anAction == SMESH::eErase");
2426 aSel->setSelectedObjects( l1 );
2429 aSel->setSelectedObjects( to_process );
2436 if(checkLock(aStudy)) break;
2439 EmitSignalDeactivateDialog();
2441 ( new SMESHGUI_NodesDlg( this ) )->show();
2444 SUIT_MessageBox::warning(desktop(),
2445 tr("SMESH_WRN_WARNING"),
2446 tr("SMESH_WRN_VIEWER_VTK"));
2451 case 2151: // FILTER
2455 EmitSignalDeactivateDialog();
2456 ( new SMESHGUI_FilterDlg( this, SMESH::EDGE ) )->show();
2461 case 701: // COMPUTE MESH
2462 case 711: // PRECOMPUTE MESH
2463 case 712: // EVALUATE MESH
2464 case 713: // MESH ORDER
2465 case 702: // Create mesh
2466 case 703: // Create sub-mesh
2467 case 704: // Edit mesh/sub-mesh
2468 startOperation( theCommandID );
2470 case 705: // copy mesh
2472 if (checkLock(aStudy)) break;
2473 EmitSignalDeactivateDialog();
2474 ( new SMESHGUI_CopyMeshDlg( this ) )->show();
2477 case 710: // Build compound mesh
2479 if (checkLock(aStudy)) break;
2480 EmitSignalDeactivateDialog();
2481 ( new SMESHGUI_BuildCompoundDlg( this ) )->show();
2485 case 407: // DIAGONAL INVERSION
2486 case 408: // Delete diagonal
2490 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2491 tr( "NOT_A_VTK_VIEWER" ) );
2495 if ( checkLock( aStudy ) )
2498 /*Standard_Boolean aRes;
2499 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
2500 if ( aMesh->_is_nil() )
2502 SUIT_MessageBox::warning(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
2503 tr( "SMESH_BAD_SELECTION" ) );
2507 EmitSignalDeactivateDialog();
2508 if ( theCommandID == 407 )
2509 ( new SMESHGUI_TrianglesInversionDlg( this ) )->show();
2511 ( new SMESHGUI_UnionOfTwoTrianglesDlg( this ) )->show();
2514 case 409: // Change orientation
2515 case 410: // Union of triangles
2516 case 411: // Cutting of quadrangles
2517 case 419: // Splitting volumes into tetrahedra
2521 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2522 tr( "NOT_A_VTK_VIEWER" ) );
2526 if ( checkLock( aStudy ) )
2529 EmitSignalDeactivateDialog();
2530 SMESHGUI_MultiEditDlg* aDlg = NULL;
2531 if ( theCommandID == 409 )
2532 aDlg = new SMESHGUI_ChangeOrientationDlg(this);
2533 else if ( theCommandID == 410 )
2534 aDlg = new SMESHGUI_UnionOfTrianglesDlg(this);
2535 else if ( theCommandID == 419 )
2536 aDlg = new SMESHGUI_CuttingIntoTetraDlg(this);
2538 aDlg = new SMESHGUI_CuttingOfQuadsDlg(this);
2543 case 412: // Smoothing
2545 if(checkLock(aStudy)) break;
2547 EmitSignalDeactivateDialog();
2548 ( new SMESHGUI_SmoothingDlg( this ) )->show();
2551 SUIT_MessageBox::warning(desktop(),
2552 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2556 case 413: // Extrusion
2558 if (checkLock(aStudy)) break;
2560 EmitSignalDeactivateDialog();
2561 ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
2563 SUIT_MessageBox::warning(desktop(),
2564 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2568 case 414: // Revolution
2570 if(checkLock(aStudy)) break;
2572 EmitSignalDeactivateDialog();
2573 ( new SMESHGUI_RevolutionDlg( this ) )->show();
2576 SUIT_MessageBox::warning(desktop(),
2577 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2581 case 415: // Pattern mapping
2583 if ( checkLock( aStudy ) )
2587 EmitSignalDeactivateDialog();
2588 ( new SMESHGUI_MeshPatternDlg( this ) )->show();
2591 SUIT_MessageBox::warning(desktop(),
2592 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2596 case 416: // Extrusion along a path
2598 if (checkLock(aStudy)) break;
2600 EmitSignalDeactivateDialog();
2601 ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
2603 SUIT_MessageBox::warning(desktop(),
2604 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
2608 case 417: // Convert mesh to quadratic
2609 case 418: // create 2D mesh from 3D
2610 case 420: // Reorient faces
2611 case 806: // CREATE GEO GROUP
2613 startOperation( theCommandID );
2616 case 801: // CREATE GROUP
2620 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2621 tr( "NOT_A_VTK_VIEWER" ) );
2625 if(checkLock(aStudy)) break;
2626 EmitSignalDeactivateDialog();
2627 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
2629 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2630 SALOME_ListIO selected;
2632 aSel->selectedObjects( selected );
2634 int nbSel = selected.Extent();
2636 // check if mesh is selected
2637 aMesh = SMESH::GetMeshByIO( selected.First() );
2639 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aMesh);
2644 case 802: // CONSTRUCT GROUP
2648 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2649 tr( "NOT_A_VTK_VIEWER" ) );
2653 if(checkLock(aStudy)) break;
2654 EmitSignalDeactivateDialog();
2656 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2657 SALOME_ListIO selected;
2659 aSel->selectedObjects( selected );
2661 int nbSel = selected.Extent();
2663 // check if submesh is selected
2664 Handle(SALOME_InteractiveObject) IObject = selected.First();
2665 if (IObject->hasEntry()) {
2666 _PTR(SObject) aSObj = aStudy->FindObjectID(IObject->getEntry());
2668 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( aSObj ) );
2669 if (!aSubMesh->_is_nil()) {
2671 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
2672 // get submesh elements list by types
2673 SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
2674 SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
2675 SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
2676 SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
2677 // create group for each type o elements
2678 QString aName = IObject->getName();
2679 QStringList anEntryList;
2680 if (aNodes->length() > 0) {
2681 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
2682 aGroup->Add(aNodes.inout());
2683 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2684 anEntryList.append( aSObject->GetID().c_str() );
2686 if (aEdges->length() > 0) {
2687 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
2688 aGroup->Add(aEdges.inout());
2689 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2690 anEntryList.append( aSObject->GetID().c_str() );
2692 if (aFaces->length() > 0) {
2693 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
2694 aGroup->Add(aFaces.inout());
2695 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2696 anEntryList.append( aSObject->GetID().c_str() );
2698 if (aVolumes->length() > 0) {
2699 SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
2700 aGroup->Add(aVolumes.inout());
2701 if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
2702 anEntryList.append( aSObject->GetID().c_str() );
2705 anApp->browseObjects( anEntryList );
2707 catch(const SALOME::SALOME_Exception & S_ex){
2708 SalomeApp_Tools::QtCatchCorbaException(S_ex);
2715 SUIT_MessageBox::warning(desktop(),
2716 tr("SMESH_WRN_WARNING"),
2717 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
2722 case 803: // EDIT GROUP
2726 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2727 tr( "NOT_A_VTK_VIEWER" ) );
2731 if(checkLock(aStudy)) break;
2732 EmitSignalDeactivateDialog();
2734 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2735 SALOME_ListIO selected;
2737 aSel->selectedObjects( selected );
2739 SALOME_ListIteratorOfListIO It (selected);
2740 int nbSelectedGroups = 0;
2741 for ( ; It.More(); It.Next() )
2743 SMESH::SMESH_GroupBase_var aGroup =
2744 SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(It.Value());
2745 if (!aGroup->_is_nil()) {
2747 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup);
2751 if (nbSelectedGroups == 0)
2753 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, SMESH::SMESH_GroupBase::_nil());
2759 case 804: // Add elements to group
2761 if(checkLock(aStudy)) break;
2762 if (myState == 800) {
2763 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2764 if (aDlg) aDlg->onAdd();
2769 case 805: // Remove elements from group
2771 if(checkLock(aStudy)) break;
2772 if (myState == 800) {
2773 SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
2774 if (aDlg) aDlg->onRemove();
2779 case 815: // Edit GEOM GROUP as standalone
2783 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2784 tr( "NOT_A_VTK_VIEWER" ) );
2788 if(checkLock(aStudy)) break;
2789 EmitSignalDeactivateDialog();
2791 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2792 SALOME_ListIO selected;
2794 aSel->selectedObjects( selected );
2796 SALOME_ListIteratorOfListIO It (selected);
2797 for ( ; It.More(); It.Next() )
2799 SMESH::SMESH_GroupOnGeom_var aGroup =
2800 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
2801 if (!aGroup->_is_nil()) {
2802 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2807 SMESH::SMESH_GroupOnFilter_var aGroup =
2808 SMESH::IObjectToInterface<SMESH::SMESH_GroupOnFilter>(It.Value());
2809 if (!aGroup->_is_nil()) {
2810 SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
2818 case 810: // Union Groups
2819 case 811: // Intersect groups
2820 case 812: // Cut groups
2824 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2825 tr( "NOT_A_VTK_VIEWER" ) );
2829 if ( checkLock( aStudy ) )
2832 EmitSignalDeactivateDialog();
2834 SMESHGUI_GroupOpDlg* aDlg = 0;
2835 if ( theCommandID == 810 )
2836 aDlg = new SMESHGUI_UnionGroupsDlg( this );
2837 else if ( theCommandID == 811 )
2838 aDlg = new SMESHGUI_IntersectGroupsDlg( this );
2840 aDlg = new SMESHGUI_CutGroupsDlg( this );
2847 case 814: // Create groups of entities from existing groups of superior dimensions
2849 if ( checkLock( aStudy ) )
2852 EmitSignalDeactivateDialog();
2853 SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
2859 case 813: // Delete groups with their contents
2863 SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
2864 tr( "NOT_A_VTK_VIEWER" ) );
2868 if ( checkLock( aStudy ) )
2871 EmitSignalDeactivateDialog();
2873 ( new SMESHGUI_DeleteGroupDlg( this ) )->show();
2877 case 900: // MESH INFOS
2878 case 903: // WHAT IS
2880 int page = theCommandID == 900 ? SMESHGUI_MeshInfoDlg::BaseInfo : SMESHGUI_MeshInfoDlg::ElemInfo;
2881 EmitSignalDeactivateDialog();
2882 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2883 SALOME_ListIO selected;
2885 aSel->selectedObjects( selected );
2887 if ( selected.Extent() > 1 ) { // a dlg for each IO
2888 SALOME_ListIteratorOfListIO It( selected );
2889 for ( ; It.More(); It.Next() ) {
2890 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2891 dlg->showInfo( It.Value() );
2896 SMESHGUI_MeshInfoDlg* dlg = new SMESHGUI_MeshInfoDlg( SMESHGUI::desktop(), page );
2902 case 904: // FIND ELEM
2904 startOperation( theCommandID );
2908 case 1100: // EDIT HYPOTHESIS
2910 if(checkLock(aStudy)) break;
2912 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2913 SALOME_ListIO selected;
2915 aSel->selectedObjects( selected );
2917 int nbSel = selected.Extent();
2920 Handle(SALOME_InteractiveObject) anIObject = selected.First();
2921 SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
2923 /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
2924 /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
2925 /* Warning : however by internal mechanism all subMeshes icons are changed ! */
2926 if ( !aHypothesis->_is_nil() )
2929 //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2930 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
2932 aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
2942 case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2944 if(checkLock(aStudy)) break;
2945 SUIT_OverrideCursor wc;
2947 LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
2948 SALOME_ListIO selected;
2950 aSel->selectedObjects( selected, QString::null, false );
2952 SALOME_ListIteratorOfListIO It(selected);
2953 for (int i = 0; It.More(); It.Next(), i++) {
2954 Handle(SALOME_InteractiveObject) IObject = It.Value();
2955 SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
2958 aSel->setSelectedObjects( l1 );
2964 case 4009: // ELEM0D
2966 case 4021: // TRIANGLE
2968 case 4023: // POLYGON
2972 case 4134: // PYRAMID
2973 case 4135: // OCTA12
2975 if(checkLock(aStudy)) break;
2977 EmitSignalDeactivateDialog();
2978 SMDSAbs_EntityType type = SMDSEntity_Edge;
2979 switch (theCommandID) {
2980 case 4008: type = SMDSEntity_Ball; break;
2981 case 4009: type = SMDSEntity_0D; break;
2982 case 4021: type = SMDSEntity_Triangle; break;
2983 case 4022: type = SMDSEntity_Quadrangle; break;
2984 case 4031: type = SMDSEntity_Tetra; break;
2985 case 4023: type = SMDSEntity_Polygon; break;
2986 case 4032: type = SMDSEntity_Hexa; break;
2987 case 4133: type = SMDSEntity_Penta; break;
2988 case 4134: type = SMDSEntity_Pyramid; break;
2989 case 4135: type = SMDSEntity_Hexagonal_Prism; break;
2992 ( new SMESHGUI_AddMeshElementDlg( this, type ) )->show();
2995 SUIT_MessageBox::warning(desktop(),
2996 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3000 case 4033: // POLYHEDRON
3002 if(checkLock(aStudy)) break;
3004 EmitSignalDeactivateDialog();
3005 ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
3008 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3009 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3013 case 4034: // QUADRATIC EDGE
3014 case 4035: // QUADRATIC TRIANGLE
3015 case 4036: // QUADRATIC QUADRANGLE
3016 case 4136: // BIQUADRATIC QUADRANGLE
3017 case 4037: // QUADRATIC TETRAHEDRON
3018 case 4038: // QUADRATIC PYRAMID
3019 case 4039: // QUADRATIC PENTAHEDRON
3020 case 4040: // QUADRATIC HEXAHEDRON
3021 case 4140: // TRIQUADRATIC HEXAHEDRON
3023 if(checkLock(aStudy)) break;
3025 EmitSignalDeactivateDialog();
3026 SMDSAbs_EntityType type;
3028 switch (theCommandID) {
3030 type = SMDSEntity_Quad_Edge; break;
3032 type = SMDSEntity_Quad_Triangle; break;
3034 type = SMDSEntity_Quad_Quadrangle; break;
3036 type = SMDSEntity_BiQuad_Quadrangle; break;
3038 type = SMDSEntity_Quad_Tetra; break;
3040 type = SMDSEntity_Quad_Pyramid; break;
3042 type = SMDSEntity_Quad_Penta; break;
3044 type = SMDSEntity_Quad_Hexa;
3046 type = SMDSEntity_TriQuad_Hexa;
3050 ( new SMESHGUI_AddQuadraticElementDlg( this, type ) )->show();
3053 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3054 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3058 case 4041: // REMOVES NODES
3060 if(checkLock(aStudy)) break;
3062 EmitSignalDeactivateDialog();
3063 ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
3066 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3067 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3071 case 4042: // REMOVES ELEMENTS
3073 if(checkLock(aStudy)) break;
3075 EmitSignalDeactivateDialog();
3076 ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
3080 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3081 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3085 case 4043: { // CLEAR_MESH
3087 if(checkLock(aStudy)) break;
3089 SALOME_ListIO selected;
3090 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3091 aSel->selectedObjects( selected );
3093 SUIT_OverrideCursor wc;
3094 SALOME_ListIteratorOfListIO It (selected);
3095 for ( ; It.More(); It.Next() )
3097 Handle(SALOME_InteractiveObject) IOS = It.Value();
3098 SMESH::SMESH_Mesh_var aMesh =
3099 SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IOS);
3100 if ( aMesh->_is_nil()) continue;
3102 SMESH::RemoveVisualObjectWithActors(IOS->getEntry(), true);
3104 _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
3105 SMESH::ModifiedMesh( aMeshSObj, false, true);
3106 // hide groups and submeshes
3107 _PTR(ChildIterator) anIter =
3108 SMESH::GetActiveStudyDocument()->NewChildIterator( aMeshSObj );
3109 for ( anIter->InitEx(true); anIter->More(); anIter->Next() )
3111 _PTR(SObject) so = anIter->Value();
3112 SMESH::RemoveVisualObjectWithActors(so->GetID().c_str(), true);
3115 catch (const SALOME::SALOME_Exception& S_ex){
3117 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3121 SMESH::UpdateView();
3125 case 4044: // REMOVE ORPHAN NODES
3127 if(checkLock(aStudy)) break;
3128 SALOME_ListIO selected;
3129 if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
3130 aSel->selectedObjects( selected );
3131 if ( selected.Extent() == 1 ) {
3132 Handle(SALOME_InteractiveObject) anIO = selected.First();
3133 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
3134 if ( !aMesh->_is_nil() ) {
3135 bool confirm = SUIT_MessageBox::question( SMESHGUI::desktop(),
3136 tr( "SMESH_WARNING" ),
3137 tr( "REMOVE_ORPHAN_NODES_QUESTION"),
3138 SUIT_MessageBox::Yes |
3139 SUIT_MessageBox::No,
3140 SUIT_MessageBox::No ) == SUIT_MessageBox::Yes;
3143 SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
3144 int removed = aMeshEditor->RemoveOrphanNodes();
3145 SUIT_MessageBox::information(SMESHGUI::desktop(),
3146 tr("SMESH_INFORMATION"),
3147 tr("NB_NODES_REMOVED").arg(removed));
3148 if ( removed > 0 ) {
3149 SMESH::UpdateView();
3150 SMESHGUI::Modified();
3153 catch (const SALOME::SALOME_Exception& S_ex) {
3154 SalomeApp_Tools::QtCatchCorbaException(S_ex);
3163 case 4051: // RENUMBERING NODES
3165 if(checkLock(aStudy)) break;
3167 EmitSignalDeactivateDialog();
3168 ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
3172 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3173 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3177 case 4052: // RENUMBERING ELEMENTS
3179 if(checkLock(aStudy)) break;
3181 EmitSignalDeactivateDialog();
3182 ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
3186 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3187 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3191 case 4061: // TRANSLATION
3193 if(checkLock(aStudy)) break;
3195 EmitSignalDeactivateDialog();
3196 ( new SMESHGUI_TranslationDlg( this ) )->show();
3199 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3200 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3204 case 4062: // ROTATION
3206 if(checkLock(aStudy)) break;
3208 EmitSignalDeactivateDialog();
3209 ( new SMESHGUI_RotationDlg( this ) )->show();
3212 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3213 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3217 case 4063: // SYMMETRY
3219 if(checkLock(aStudy)) break;
3221 EmitSignalDeactivateDialog();
3222 ( new SMESHGUI_SymmetryDlg( this ) )->show();
3225 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3226 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3230 case 4064: // SEWING
3232 if(checkLock(aStudy)) break;
3234 EmitSignalDeactivateDialog();
3235 ( new SMESHGUI_SewingDlg( this ) )->show();
3238 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3239 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3243 case 4065: // MERGE NODES
3245 if(checkLock(aStudy)) break;
3247 EmitSignalDeactivateDialog();
3248 ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
3251 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3252 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3256 case 4066: // MERGE EQUAL ELEMENTS
3258 if (checkLock(aStudy)) break;
3260 EmitSignalDeactivateDialog();
3261 ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
3263 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3264 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3269 case 4067: // MAKE MESH PASS THROUGH POINT
3270 startOperation( 4067 );
3275 if(checkLock(aStudy)) break;
3277 EmitSignalDeactivateDialog();
3278 ( new SMESHGUI_ScaleDlg( this ) )->show();
3281 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3282 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3287 case 4069: // DUPLICATE NODES
3289 if(checkLock(aStudy)) break;
3291 EmitSignalDeactivateDialog();
3292 ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
3295 SUIT_MessageBox::warning(SMESHGUI::desktop(),
3296 tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"));
3301 case 4070: // 0D_ON_ALL_NODES
3302 startOperation( 4070 );
3305 case 5105: // Library of selection filters
3307 static QList<int> aTypes;
3308 if ( aTypes.isEmpty() )
3310 aTypes.append( SMESH::NODE );
3311 aTypes.append( SMESH::EDGE );
3312 aTypes.append( SMESH::FACE );
3313 aTypes.append( SMESH::VOLUME );
3315 if (!myFilterLibraryDlg)
3316 myFilterLibraryDlg = new SMESHGUI_FilterLibraryDlg( this, SMESH::GetDesktop( this ), aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3317 else if (myFilterLibraryDlg->isHidden())
3318 myFilterLibraryDlg->Init( aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
3319 myFilterLibraryDlg->raise();
3323 case 6017: // CONTROLS
3351 LightApp_SelectionMgr* mgr = selectionMgr();
3352 SALOME_ListIO selected; mgr->selectedObjects( selected );
3354 if ( selected.Extent() == 1 && selected.First()->hasEntry() ) {
3355 _PTR(SObject) SO = aStudy->FindObjectID( selected.First()->getEntry() );
3357 CORBA::Object_var aObject = SMESH::SObjectToObject( SO );
3358 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
3359 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
3360 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
3361 if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
3362 ::Control( theCommandID );
3367 SUIT_MessageBox::warning(desktop(),
3368 tr( "SMESH_WRN_WARNING" ),
3369 tr( "SMESH_BAD_SELECTION" ) );
3373 SUIT_MessageBox::warning(desktop(),
3374 tr( "SMESH_WRN_WARNING" ),
3375 tr( "NOT_A_VTK_VIEWER" ) );
3380 LightApp_SelectionMgr* mgr = selectionMgr();
3381 SALOME_ListIO selected; mgr->selectedObjects( selected );
3383 SALOME_ListIteratorOfListIO it(selected);
3384 for( ; it.More(); it.Next()) {
3385 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3386 if(anIObject->hasEntry()) {
3387 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3388 anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
3396 LightApp_SelectionMgr* mgr = selectionMgr();
3397 SALOME_ListIO selected; mgr->selectedObjects( selected );
3399 SALOME_ListIteratorOfListIO it(selected);
3400 for( ; it.More(); it.Next()) {
3401 Handle(SALOME_InteractiveObject) anIObject = it.Value();
3402 if(anIObject->hasEntry())
3403 if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
3404 anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
3412 int page = theCommandID == 501 ? SMESHGUI_MeasureDlg::MinDistance : SMESHGUI_MeasureDlg::BoundingBox;
3413 EmitSignalDeactivateDialog();
3414 SMESHGUI_MeasureDlg* dlg = new SMESHGUI_MeasureDlg( SMESHGUI::desktop(), page );
3420 anApp->updateActions(); //SRN: To update a Save button in the toolbar
3421 //updateObjBrowser();
3425 //=============================================================================
3429 //=============================================================================
3430 bool SMESHGUI::OnMousePress( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3435 //=============================================================================
3439 //=============================================================================
3440 bool SMESHGUI::OnMouseMove( QMouseEvent * pe, SUIT_ViewWindow * wnd )
3445 //=============================================================================
3449 //=============================================================================
3450 bool SMESHGUI::OnKeyPress( QKeyEvent * pe, SUIT_ViewWindow * wnd )
3455 //=============================================================================
3456 /*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3457 * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
3459 //=============================================================================
3460 void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
3461 SUIT_ViewWindow* wnd )
3463 if(theIO->hasEntry()){
3464 //SUIT_ViewWindow* wnd = SMESH::GetActiveWindow();
3465 SMESH::UpdateView(wnd,SMESH::eDisplay,theIO->getEntry());
3469 //=======================================================================
3470 // function : createSMESHAction
3472 //=======================================================================
3473 void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QString& icon_id,
3474 const int key, const bool toggle, const QString& shortcutAction )
3477 QWidget* parent = application()->desktop();
3478 SUIT_ResourceMgr* resMgr = resourceMgr();
3480 if ( !icon_id.isEmpty() )
3481 pix = resMgr->loadPixmap( "SMESH", tr( icon_id.toLatin1().data() ) );
3483 pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data() ), false );
3484 if ( !pix.isNull() )
3485 icon = QIcon( pix );
3487 QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
3488 menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
3489 status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );
3491 createAction( id, tooltip, icon, menu, status_bar, key, parent,
3492 toggle, this, SLOT( OnGUIEvent() ), shortcutAction );
3495 //=======================================================================
3496 // function : createPopupItem
3498 //=======================================================================
3499 void SMESHGUI::createPopupItem( const int id,
3500 const QString& clients,
3501 const QString& types,
3502 const QString& theRule,
3505 if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) )
3506 popupMgr()->insert( action( id ), pId, 0 );
3508 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
3509 QString dc = "selcount"; // VSR : insetad of QtxPopupSelection::defSelCountParam()
3510 QString rule = "(%1) and (%2) and (%3)";
3511 rule = rule.arg( QString( "%1>0" ).arg( dc ) );
3512 if( clients.isEmpty() )
3513 rule = rule.arg( QString( "true" ) );
3515 rule = rule.arg( QString( "%1client in {%2}" ).arg( lc ).arg( clients ) );
3516 rule = rule.arg( QString( "%1type in {%2}" ).arg( lc ).arg( types ) );
3519 bool cont = myRules.contains( id );
3521 rule = QString( "%1 or (%2)" ).arg( myRules[ id ] ).arg( rule );
3523 popupMgr()->setRule( action( id ), rule, QtxPopupMgr::VisibleRule );
3524 myRules[ id ] = QString( cont ? "%1" : "(%1)" ).arg( rule );
3527 //=======================================================================
3528 // function : initialize
3530 //=======================================================================
3531 void SMESHGUI::initialize( CAM_Application* app )
3533 SalomeApp_Module::initialize( app );
3535 // SUIT_ResourceMgr* mgr = app->resourceMgr();
3537 /* Automatic Update flag */
3538 // myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate );
3540 // ----- create actions --------------
3542 //createSMESHAction( 111, "IMPORT_DAT", "", (Qt::CTRL+Qt::Key_B) );
3543 createSMESHAction( 112, "IMPORT_UNV", "", (Qt::CTRL+Qt::Key_U) );
3544 createSMESHAction( 113, "IMPORT_MED", "", (Qt::CTRL+Qt::Key_M) );
3545 createSMESHAction( 114, "NUM" );
3546 createSMESHAction( 115, "IMPORT_STL" );
3547 createSMESHAction( 116, "IMPORT_CGNS" );
3548 createSMESHAction( 117, "IMPORT_SAUV" );
3549 createSMESHAction( 118, "IMPORT_GMF" );
3550 createSMESHAction( 121, "DAT" );
3551 createSMESHAction( 122, "MED" );
3552 createSMESHAction( 123, "UNV" );
3553 createSMESHAction( 140, "STL" );
3554 createSMESHAction( 142, "CGNS");
3555 createSMESHAction( 144, "SAUV");
3556 createSMESHAction( 146, "GMF" );
3557 createSMESHAction( 124, "DAT" );
3558 createSMESHAction( 125, "MED" );
3559 createSMESHAction( 126, "UNV" );
3560 createSMESHAction( 141, "STL" );
3561 createSMESHAction( 143, "CGNS");
3562 createSMESHAction( 145, "SAUV");
3563 createSMESHAction( 147, "GMF" );
3564 createSMESHAction( 150, "FILE_INFO" );
3565 createSMESHAction( 33, "DELETE", "ICON_DELETE", Qt::Key_Delete );
3566 createSMESHAction( 5105, "SEL_FILTER_LIB" );
3567 createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
3568 createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
3569 createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
3570 createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
3571 createSMESHAction( 705, "COPY_MESH", "ICON_COPY_MESH" );
3572 createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
3573 createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
3574 createSMESHAction( 712, "EVALUATE", "ICON_COMPUTE" );
3575 createSMESHAction( 713, "MESH_ORDER", "ICON_COMPUTE" );
3576 createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
3577 createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
3578 createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
3579 createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
3580 createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
3581 createSMESHAction( 804, "ADD" );
3582 createSMESHAction( 805, "REMOVE" );
3583 createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
3584 createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
3585 createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
3586 createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
3587 createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
3588 createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
3589 //createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
3590 //createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3591 createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
3592 createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
3593 createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
3594 createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
3595 createSMESHAction( 6022, "MAX_ELEMENT_LENGTH_2D", "ICON_MAX_ELEMENT_LENGTH_2D", 0, true );
3596 createSMESHAction( 6023, "MAX_ELEMENT_LENGTH_3D", "ICON_MAX_ELEMENT_LENGTH_3D", 0, true );
3597 createSMESHAction( 6024, "BARE_BORDER_VOLUME", "ICON_BARE_BORDER_VOLUME", 0, true );
3598 createSMESHAction( 6025, "BARE_BORDER_FACE", "ICON_BARE_BORDER_FACE", 0, true );
3599 createSMESHAction( 6026, "OVER_CONSTRAINED_VOLUME","ICON_OVER_CONSTRAINED_VOLUME", 0, true );
3600 createSMESHAction( 6027, "OVER_CONSTRAINED_FACE", "ICON_OVER_CONSTRAINED_FACE", 0, true );
3601 createSMESHAction( 6028, "EQUAL_NODE", "ICON_EQUAL_NODE", 0, true );
3602 createSMESHAction( 6029, "EQUAL_EDGE", "ICON_EQUAL_EDGE", 0, true );
3603 createSMESHAction( 6030, "EQUAL_FACE", "ICON_EQUAL_FACE", 0, true );
3604 createSMESHAction( 6031, "EQUAL_VOLUME", "ICON_EQUAL_VOLUME", 0, true );
3605 createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
3606 createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
3607 createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
3608 createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
3609 createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
3610 createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
3611 createSMESHAction( 6014, "MIN_ANG", "ICON_ANGLE", 0, true );
3612 createSMESHAction( 6015, "WARP", "ICON_WARP", 0, true );
3613 createSMESHAction( 6016, "SKEW", "ICON_SKEW", 0, true );
3614 createSMESHAction( 6017, "ASPECT_3D", "ICON_ASPECT_3D", 0, true );
3615 createSMESHAction( 6018, "LENGTH_2D", "ICON_LENGTH_2D", 0, true );
3616 createSMESHAction( 6019, "CONNECTION_2D", "ICON_CONNECTION_2D", 0, true );
3617 createSMESHAction( 6009, "VOLUME_3D", "ICON_VOLUME_3D", 0, true );
3618 createSMESHAction( 4000, "NODE", "ICON_DLG_NODE" );
3619 createSMESHAction( 4009, "ELEM0D", "ICON_DLG_ELEM0D" );
3620 createSMESHAction( 4008, "BALL", "ICON_DLG_BALL" );
3621 createSMESHAction( 4010, "EDGE", "ICON_DLG_EDGE" );
3622 createSMESHAction( 4021, "TRIANGLE", "ICON_DLG_TRIANGLE" );
3623 createSMESHAction( 4022, "QUAD", "ICON_DLG_QUADRANGLE" );
3624 createSMESHAction( 4023, "POLYGON", "ICON_DLG_POLYGON" );
3625 createSMESHAction( 4031, "TETRA", "ICON_DLG_TETRAS" );
3626 createSMESHAction( 4032, "HEXA", "ICON_DLG_HEXAS" );
3627 createSMESHAction( 4133, "PENTA", "ICON_DLG_PENTA" );
3628 createSMESHAction( 4134, "PYRAMID", "ICON_DLG_PYRAMID" );
3629 createSMESHAction( 4135, "OCTA", "ICON_DLG_OCTA" );
3630 createSMESHAction( 4033, "POLYHEDRON", "ICON_DLG_POLYHEDRON" );
3631 createSMESHAction( 4034, "QUADRATIC_EDGE", "ICON_DLG_QUADRATIC_EDGE" );
3632 createSMESHAction( 4035, "QUADRATIC_TRIANGLE", "ICON_DLG_QUADRATIC_TRIANGLE" );
3633 createSMESHAction( 4036, "QUADRATIC_QUADRANGLE", "ICON_DLG_QUADRATIC_QUADRANGLE" );
3634 createSMESHAction( 4136, "BIQUADRATIC_QUADRANGLE", "ICON_DLG_BIQUADRATIC_QUADRANGLE" );
3635 createSMESHAction( 4037, "QUADRATIC_TETRAHEDRON", "ICON_DLG_QUADRATIC_TETRAHEDRON" );
3636 createSMESHAction( 4038, "QUADRATIC_PYRAMID", "ICON_DLG_QUADRATIC_PYRAMID" );
3637 createSMESHAction( 4039, "QUADRATIC_PENTAHEDRON", "ICON_DLG_QUADRATIC_PENTAHEDRON" );
3638 createSMESHAction( 4040, "QUADRATIC_HEXAHEDRON", "ICON_DLG_QUADRATIC_HEXAHEDRON" );
3639 createSMESHAction( 4140, "TRIQUADRATIC_HEXAHEDRON", "ICON_DLG_TRIQUADRATIC_HEXAHEDRON" );
3640 createSMESHAction( 4041, "REMOVE_NODES", "ICON_DLG_REM_NODE" );
3641 createSMESHAction( 4042, "REMOVE_ELEMENTS", "ICON_DLG_REM_ELEMENT" );
3642 createSMESHAction( 4044, "REMOVE_ORPHAN_NODES", "ICON_DLG_REM_ORPHAN_NODES" );
3643 createSMESHAction( 4043, "CLEAR_MESH" , "ICON_CLEAR_MESH" );
3644 createSMESHAction( 4051, "RENUM_NODES", "ICON_DLG_RENUMBERING_NODES" );
3645 createSMESHAction( 4052, "RENUM_ELEMENTS", "ICON_DLG_RENUMBERING_ELEMENTS" );
3646 createSMESHAction( 4061, "TRANS", "ICON_SMESH_TRANSLATION_VECTOR" );
3647 createSMESHAction( 4062, "ROT", "ICON_DLG_MESH_ROTATION" );
3648 createSMESHAction( 4063, "SYM", "ICON_SMESH_SYMMETRY_PLANE" );
3649 createSMESHAction( 4064, "SEW", "ICON_SMESH_SEWING_FREEBORDERS" );
3650 createSMESHAction( 4065, "MERGE", "ICON_SMESH_MERGE_NODES" );
3651 createSMESHAction( 4066, "MERGE_ELEMENTS", "ICON_DLG_MERGE_ELEMENTS" );
3652 createSMESHAction( 4067, "MESH_THROU_POINT","ICON_DLG_MOVE_NODE" );
3653 createSMESHAction( 4068, "SCALE", "ICON_DLG_MESH_SCALE" );
3654 createSMESHAction( 4069, "DUPLICATE_NODES", "ICON_SMESH_DUPLICATE_NODES" );
3655 createSMESHAction( 4070, "0D_ON_ALL_NODES", "ICON_0D_ON_ALL_NODES" );
3656 createSMESHAction( 407, "INV", "ICON_DLG_MESH_DIAGONAL" );
3657 createSMESHAction( 408, "UNION2", "ICON_UNION2TRI" );
3658 createSMESHAction( 409, "ORIENT", "ICON_DLG_MESH_ORIENTATION" );
3659 createSMESHAction( 410, "UNION", "ICON_UNIONTRI" );
3660 createSMESHAction( 411, "CUT", "ICON_CUTQUAD" );
3661 createSMESHAction( 412, "SMOOTH", "ICON_DLG_SMOOTHING" );
3662 createSMESHAction( 413, "EXTRUSION", "ICON_EXTRUSION" );
3663 createSMESHAction( 414, "REVOLUTION", "ICON_REVOLUTION" );
3664 createSMESHAction( 415, "MAP", "ICON_MAP" );
3665 createSMESHAction( 416, "EXTRUSION_ALONG", "ICON_EXTRUSION_ALONG" );
3666 createSMESHAction( 417, "CONV_TO_QUAD", "ICON_CONV_TO_QUAD" );
3667 createSMESHAction( 418, "2D_FROM_3D", "ICON_2D_FROM_3D" );
3668 createSMESHAction( 419, "SPLIT_TO_TETRA", "ICON_SPLIT_TO_TETRA" );
3669 createSMESHAction( 420, "REORIENT_2D", "ICON_REORIENT_2D" );
3670 createSMESHAction( 200, "RESET" );
3671 createSMESHAction( 201, "SCALAR_BAR_PROP" );
3672 createSMESHAction( 2021, "SAVE_DISTRIBUTION" );
3673 createSMESHAction( 2022, "SHOW_DISTRIBUTION","",0, true );
3674 #ifndef DISABLE_PLOT2DVIEWER
3675 createSMESHAction( 2023, "PLOT_DISTRIBUTION" );
3677 createSMESHAction( 211, "WIRE", "ICON_WIRE", 0, true );
3678 createSMESHAction( 212, "SHADE", "ICON_SHADE", 0, true );
3679 createSMESHAction( 213, "SHRINK", "ICON_SHRINK", 0, true );
3680 createSMESHAction( 214, "UPDATE", "ICON_UPDATE" );
3681 createSMESHAction( 215, "NODES", "ICON_POINTS", 0, true );
3682 createSMESHAction( 222, "BALLS", "ICON_DLG_BALL", 0, true );
3683 createSMESHAction( 216, "ELEMS0D", "ICON_DLG_ELEM0D", 0, true );
3684 createSMESHAction( 217, "EDGES", "ICON_DLG_EDGE", 0, true );
3685 createSMESHAction( 218, "FACES", "ICON_DLG_TRIANGLE", 0, true );
3686 createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
3687 createSMESHAction( 220, "ALL" );
3688 createSMESHAction( 221, "FACE_ORIENTATION", "", 0, true );
3690 createSMESHAction( 231, "LINE_REPRESENTATION", "", 0, true );
3691 createSMESHAction( 232, "ARC_REPRESENTATION", "", 0, true );
3693 createSMESHAction( 1100, "EDIT_HYPO" );
3694 createSMESHAction( 1102, "UNASSIGN" );
3695 createSMESHAction( 9010, "NUM_NODES", "", 0, true );
3696 createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
3697 createSMESHAction( 1131, "DISPMODE" );
3698 createSMESHAction( 1132, "COLORS" );
3699 createSMESHAction( 1133, "TRANSP" );
3700 createSMESHAction( 1134, "CLIP" );
3701 createSMESHAction( 1135, "DISP_ENT" );
3702 createSMESHAction( 1136, "AUTO_COLOR" );
3703 createSMESHAction( 1137, "DISABLE_AUTO_COLOR" );
3704 createSMESHAction( 2000, "CTRL" );
3706 createSMESHAction( 501, "MEASURE_MIN_DIST", "ICON_MEASURE_MIN_DIST" );
3707 createSMESHAction( 502, "MEASURE_BND_BOX", "ICON_MEASURE_BND_BOX" );
3709 createSMESHAction( 300, "HIDE" );
3710 createSMESHAction( 301, "SHOW" );
3711 createSMESHAction( 302, "DISPLAY_ONLY" );
3713 // ----- create menu --------------
3714 int fileId = createMenu( tr( "MEN_FILE" ), -1, 1 ),
3715 editId = createMenu( tr( "MEN_EDIT" ), -1, 3 ),
3716 toolsId = createMenu( tr( "MEN_TOOLS" ), -1, 5, 50 ),
3717 meshId = createMenu( tr( "MEN_MESH" ), -1, 70, 10 ),
3718 ctrlId = createMenu( tr( "MEN_CTRL" ), -1, 60, 10 ),
3719 modifyId = createMenu( tr( "MEN_MODIFY" ), -1, 40, 10 ),
3720 measureId = createMenu( tr( "MEN_MEASURE" ), -1, 50, 10 ),
3721 viewId = createMenu( tr( "MEN_VIEW" ), -1, 2 );
3723 createMenu( separator(), fileId );
3725 int importId = createMenu( tr( "MEN_IMPORT" ), fileId, -1, 10 ),
3726 exportId = createMenu( tr( "MEN_EXPORT" ), fileId, -1, 10 ),
3727 nodeId = createMenu( tr( "MEN_NODE_CTRL" ), ctrlId, -1, 10 ),
3728 edgeId = createMenu( tr( "MEN_EDGE_CTRL" ), ctrlId, -1, 10 ),
3729 faceId = createMenu( tr( "MEN_FACE_CTRL" ), ctrlId, -1, 10 ),
3730 volumeId = createMenu( tr( "MEN_VOLUME_CTRL" ), ctrlId, -1, 10 ),
3731 addId = createMenu( tr( "MEN_ADD" ), modifyId, 402 ),
3732 removeId = createMenu( tr( "MEN_REMOVE" ), modifyId, 403 ),
3733 renumId = createMenu( tr( "MEN_RENUM" ), modifyId, 404 ),
3734 transfId = createMenu( tr( "MEN_TRANSF" ), modifyId, 405 );
3736 //createMenu( 111, importId, -1 );
3737 createMenu( 112, importId, -1 );
3738 createMenu( 113, importId, -1 );
3739 createMenu( 115, importId, -1 );
3741 createMenu( 116, importId, -1 );
3743 createMenu( 117, importId, -1 );
3744 createMenu( 118, importId, -1 );
3745 createMenu( 121, exportId, -1 );
3746 createMenu( 122, exportId, -1 );
3747 createMenu( 123, exportId, -1 );
3748 createMenu( 140, exportId, -1 ); // export to STL
3750 createMenu( 142, exportId, -1 ); // export to CGNS
3752 createMenu( 144, exportId, -1 ); // export to SAUV
3753 createMenu( 146, exportId, -1 ); // export to GMF
3754 createMenu( separator(), fileId, 10 );
3756 createMenu( 33, editId, -1 );
3758 createMenu( 5105, toolsId, -1 );
3760 createMenu( 702, meshId, -1 ); // "Mesh" menu
3761 createMenu( 703, meshId, -1 );
3762 createMenu( 704, meshId, -1 );
3763 createMenu( 710, meshId, -1 );
3764 createMenu( 705, meshId, -1 );
3765 createMenu( separator(), meshId, -1 );
3766 createMenu( 701, meshId, -1 );
3767 createMenu( 711, meshId, -1 );
3768 createMenu( 712, meshId, -1 );
3769 createMenu( 713, meshId, -1 );
3770 createMenu( separator(), meshId, -1 );
3771 createMenu( 801, meshId, -1 );
3772 createMenu( 806, meshId, -1 );
3773 createMenu( 802, meshId, -1 );
3774 createMenu( 803, meshId, -1 );
3775 createMenu( 815, meshId, -1 );
3776 createMenu( separator(), meshId, -1 );
3777 createMenu( 810, meshId, -1 );
3778 createMenu( 811, meshId, -1 );
3779 createMenu( 812, meshId, -1 );
3780 createMenu( separator(), meshId, -1 );
3781 createMenu( 814, meshId, -1 );
3782 createMenu( separator(), meshId, -1 );
3783 createMenu( 900, meshId, -1 );
3784 //createMenu( 902, meshId, -1 );
3785 //createMenu( 903, meshId, -1 ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3786 createMenu( 904, meshId, -1 );
3787 createMenu( separator(), meshId, -1 );
3789 createMenu( 6005, nodeId, -1 );
3790 createMenu( 6028, nodeId, -1 );
3791 createMenu( 6002, edgeId, -1 );
3792 createMenu( 6003, edgeId, -1 );
3793 createMenu( 6001, edgeId, -1 );
3794 createMenu( 6004, edgeId, -1 );
3795 createMenu( 6029, edgeId, -1 );
3796 createMenu( 6021, faceId, -1 );
3797 createMenu( 6025, faceId, -1 );
3798 createMenu( 6027, faceId, -1 );
3799 createMenu( 6018, faceId, -1 );
3800 createMenu( 6019, faceId, -1 );
3801 createMenu( 6011, faceId, -1 );
3802 createMenu( 6012, faceId, -1 );
3803 createMenu( 6013, faceId, -1 );
3804 createMenu( 6014, faceId, -1 );
3805 createMenu( 6015, faceId, -1 );
3806 createMenu( 6016, faceId, -1 );
3807 createMenu( 6022, faceId, -1 );
3808 createMenu( 6030, faceId, -1 );
3809 createMenu( 6017, volumeId, -1 );
3810 createMenu( 6009, volumeId, -1 );
3811 createMenu( 6023, volumeId, -1 );
3812 createMenu( 6024, volumeId, -1 );
3813 createMenu( 6026, volumeId, -1 );
3814 createMenu( 6031, volumeId, -1 );
3816 createMenu( 4000, addId, -1 );
3817 createMenu( 4009, addId, -1 );
3818 createMenu( 4070, addId, -1 );
3819 createMenu( 4008, addId, -1 );
3820 createMenu( 4010, addId, -1 );
3821 createMenu( 4021, addId, -1 );
3822 createMenu( 4022, addId, -1 );
3823 createMenu( 4023, addId, -1 );
3824 createMenu( 4031, addId, -1 );
3825 createMenu( 4032, addId, -1 );
3826 createMenu( 4133, addId, -1 );
3827 createMenu( 4134, addId, -1 );
3828 createMenu( 4135, addId, -1 );
3829 createMenu( 4033, addId, -1 );
3830 createMenu( separator(), addId, -1 );
3831 createMenu( 4034, addId, -1 );
3832 createMenu( 4035, addId, -1 );
3833 createMenu( 4036, addId, -1 );
3834 createMenu( 4136, addId, -1 );
3835 createMenu( 4037, addId, -1 );
3836 createMenu( 4038, addId, -1 );
3837 createMenu( 4039, addId, -1 );
3838 createMenu( 4040, addId, -1 );
3839 createMenu( 4140, addId, -1 );
3841 createMenu( 4041, removeId, -1 );
3842 createMenu( 4042, removeId, -1 );
3843 createMenu( 4044, removeId, -1 );
3844 createMenu( separator(), removeId, -1 );
3845 createMenu( 813, removeId, -1 );
3846 createMenu( separator(), removeId, -1 );
3847 createMenu( 4043, removeId, -1 );
3849 createMenu( 4051, renumId, -1 );
3850 createMenu( 4052, renumId, -1 );
3852 createMenu( 4061, transfId, -1 );
3853 createMenu( 4062, transfId, -1 );
3854 createMenu( 4063, transfId, -1 );
3855 createMenu( 4068, transfId, -1 );
3856 createMenu( 4064, transfId, -1 );
3857 createMenu( 4065, transfId, -1 );
3858 createMenu( 4066, transfId, -1 );
3859 createMenu( 4069, transfId, -1 );
3861 createMenu( 4067,modifyId, -1 );
3862 createMenu( 407, modifyId, -1 );
3863 createMenu( 408, modifyId, -1 );
3864 createMenu( 409, modifyId, -1 );
3865 createMenu( 420, modifyId, -1 );
3866 createMenu( 410, modifyId, -1 );
3867 createMenu( 411, modifyId, -1 );
3868 createMenu( 419, modifyId, -1 );
3869 createMenu( 412, modifyId, -1 );
3870 createMenu( 413, modifyId, -1 );
3871 createMenu( 416, modifyId, -1 );
3872 createMenu( 414, modifyId, -1 );
3873 createMenu( 415, modifyId, -1 );
3874 createMenu( 417, modifyId, -1 );
3875 createMenu( 418, modifyId, -1 );
3877 createMenu( 501, measureId, -1 );
3878 createMenu( 502, measureId, -1 );
3879 createMenu( 214, viewId, -1 );
3881 // ----- create toolbars --------------
3882 int meshTb = createTool( tr( "TB_MESH" ) ),
3883 ctrlTb = createTool( tr( "TB_CTRL" ) ),
3884 addRemTb = createTool( tr( "TB_ADD_REMOVE" ) ),
3885 modifyTb = createTool( tr( "TB_MODIFY" ) ),
3886 dispModeTb = createTool( tr( "TB_DISP_MODE" ) );
3888 createTool( 702, meshTb );
3889 createTool( 703, meshTb );
3890 createTool( 704, meshTb );
3891 createTool( 710, meshTb );
3892 createTool( 705, meshTb );
3893 createTool( separator(), meshTb );
3894 createTool( 701, meshTb );
3895 createTool( 711, meshTb );
3896 createTool( 712, meshTb );
3897 createTool( 713, meshTb );
3898 createTool( separator(), meshTb );
3899 createTool( 801, meshTb );
3900 createTool( 806, meshTb );
3901 createTool( 802, meshTb );
3902 createTool( 803, meshTb );
3903 //createTool( 815, meshTb );
3904 createTool( separator(), meshTb );
3905 createTool( 900, meshTb );
3906 //createTool( 902, meshTb );
3907 //createTool( 903, meshTb ); // VSR: issue #0021242 (eliminate "Mesh Element Information" command)
3908 createTool( 904, meshTb );
3909 createTool( separator(), meshTb );
3911 createTool( 6005, ctrlTb );
3912 createTool( 6028, ctrlTb );
3913 createTool( separator(), ctrlTb );
3914 createTool( 6002, ctrlTb );
3915 createTool( 6003, ctrlTb );
3916 createTool( 6001, ctrlTb );
3917 createTool( 6004, ctrlTb );
3918 createTool( 6029, ctrlTb );
3919 createTool( separator(), ctrlTb );
3920 createTool( 6021, ctrlTb );
3921 createTool( 6025, ctrlTb );
3922 createTool( 6027, ctrlTb );
3923 createTool( 6018, ctrlTb );
3924 createTool( 6019, ctrlTb );
3925 createTool( 6011, ctrlTb );
3926 createTool( 6012, ctrlTb );
3927 createTool( 6013, ctrlTb );
3928 createTool( 6014, ctrlTb );
3929 createTool( 6015, ctrlTb );
3930 createTool( 6016, ctrlTb );
3931 createTool( 6022, ctrlTb );
3932 createTool( 6030, ctrlTb );
3933 createTool( separator(), ctrlTb );
3934 createTool( 6017, ctrlTb );
3935 createTool( 6009, ctrlTb );
3936 createTool( 6023, ctrlTb );
3937 createTool( 6024, ctrlTb );
3938 createTool( 6026, ctrlTb );
3939 createTool( 6031, ctrlTb );
3940 createTool( separator(), ctrlTb );
3942 createTool( 4000, addRemTb );
3943 createTool( 4009, addRemTb );
3944 createTool( 4070, addRemTb );
3945 createTool( 4008, addRemTb );
3946 createTool( 4010, addRemTb );
3947 createTool( 4021, addRemTb );
3948 createTool( 4022, addRemTb );
3949 createTool( 4023, addRemTb );
3950 createTool( 4031, addRemTb );
3951 createTool( 4032, addRemTb );
3952 createTool( 4133, addRemTb );
3953 createTool( 4134, addRemTb );
3954 createTool( 4135, addRemTb );
3955 createTool( 4033, addRemTb );
3956 createTool( separator(), addRemTb );
3957 createTool( 4034, addRemTb );
3958 createTool( 4035, addRemTb );
3959 createTool( 4036, addRemTb );
3960 createTool( 4136, addRemTb );
3961 createTool( 4037, addRemTb );
3962 createTool( 4038, addRemTb );
3963 createTool( 4039, addRemTb );
3964 createTool( 4040, addRemTb );
3965 createTool( 4140, addRemTb );
3966 createTool( separator(), addRemTb );
3967 createTool( 4041, addRemTb );
3968 createTool( 4042, addRemTb );
3969 createTool( 4044, addRemTb );
3970 createTool( 4043, addRemTb );
3971 createTool( separator(), addRemTb );
3972 createTool( 4051, addRemTb );
3973 createTool( 4052, addRemTb );
3974 createTool( separator(), addRemTb );
3975 createTool( 4061, addRemTb );
3976 createTool( 4062, addRemTb );
3977 createTool( 4063, addRemTb );
3978 createTool( 4068, addRemTb );
3979 createTool( 4064, addRemTb );
3980 createTool( 4065, addRemTb );
3981 createTool( 4066, addRemTb );
3982 createTool( 4069, addRemTb );
3983 createTool( separator(), addRemTb );
3985 createTool( 4067,modifyTb );
3986 createTool( 407, modifyTb );
3987 createTool( 408, modifyTb );
3988 createTool( 409, modifyTb );
3989 createTool( 420, modifyTb );
3990 createTool( 410, modifyTb );
3991 createTool( 411, modifyTb );
3992 createTool( 419, modifyTb );
3993 createTool( 412, modifyTb );
3994 createTool( 413, modifyTb );
3995 createTool( 416, modifyTb );
3996 createTool( 414, modifyTb );
3997 createTool( 415, modifyTb );
3998 createTool( 417, modifyTb );
3999 createTool( 418, modifyTb );
4001 createTool( 214, dispModeTb );
4003 QString lc = "$"; // VSR : instead of QtxPopupSelection::defEquality();
4004 QString dc = "selcount"; // VSR : instead of QtxPopupSelection::defSelCountParam()
4007 QString OB = "'ObjectBrowser'",
4008 View = "'" + SVTK_Viewer::Type() + "'",
4010 mesh = pat.arg( SMESHGUI_Selection::typeName( SMESH::MESH ) ),
4011 group = pat.arg( SMESHGUI_Selection::typeName( SMESH::GROUP ) ),
4012 hypo = pat.arg( SMESHGUI_Selection::typeName( SMESH::HYPOTHESIS ) ),
4013 algo = pat.arg( SMESHGUI_Selection::typeName( SMESH::ALGORITHM ) ),
4014 elems = QString( "'%1' '%2' '%3' '%4' '%5' '%6'" ).
4015 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_VERTEX ) ).
4016 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_EDGE ) ).
4017 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_FACE ) ).
4018 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_SOLID ) ).
4019 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH_COMPOUND ) ).
4020 arg( SMESHGUI_Selection::typeName( SMESH::SUBMESH ) ),
4022 mesh_part = mesh + " " + subMesh + " " + group,
4023 mesh_group = mesh + " " + group,
4024 hyp_alg = hypo + " " + algo;
4026 // popup for object browser
4028 isInvisible("not( isVisible )"),
4029 isEmpty("numberOfNodes = 0"),
4030 isNotEmpty("numberOfNodes <> 0"),
4032 // has nodes, edges, etc in VISIBLE! actor
4033 hasNodes("(numberOfNodes > 0 )"),//&& isVisible)"),
4034 hasElems("(count( elemTypes ) > 0)"),
4035 hasDifferentElems("(count( elemTypes ) > 1)"),
4036 hasBalls("({'BallElem'} in elemTypes)"),
4037 hasElems0d("({'Elem0d'} in elemTypes)"),
4038 hasEdges("({'Edge'} in elemTypes)"),
4039 hasFaces("({'Face'} in elemTypes)"),
4040 hasVolumes("({'Volume'} in elemTypes)");
4042 createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
4043 createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
4044 createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
4045 createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
4046 createPopupItem( 803, OB, group ); // EDIT_GROUP
4047 createPopupItem( 815, OB, group, "&& groupType != 'Group'" ); // EDIT AS STANDALONE
4049 popupMgr()->insert( separator(), -1, 0 );
4050 createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
4051 createPopupItem( 711, OB, mesh, "&& isComputable && isPreComputable" ); // PRECOMPUTE
4052 createPopupItem( 712, OB, mesh, "&& isComputable" ); // EVALUATE
4053 createPopupItem( 713, OB, mesh, "&& isComputable" ); // MESH ORDER
4054 createPopupItem( 214, OB, mesh_part ); // UPDATE
4055 createPopupItem( 900, OB, mesh_part ); // ADV_INFO
4056 createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
4057 popupMgr()->insert( separator(), -1, 0 );
4058 createPopupItem( 801, OB, mesh ); // CREATE_GROUP
4059 createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
4060 createPopupItem( 802, OB, subMesh ); // CONSTRUCT_GROUP
4061 popupMgr()->insert( separator(), -1, 0 );
4062 createPopupItem( 1100, OB, hypo); // EDIT HYPOTHESIS
4063 createPopupItem( 1102, OB, hyp_alg ); // REMOVE HYPOTHESIS / ALGORITHMS
4064 popupMgr()->insert( separator(), -1, 0 );
4065 createPopupItem( 4043, OB, mesh ); // CLEAR_MESH
4066 popupMgr()->insert( separator(), -1, 0 );
4067 createPopupItem( 417, OB, mesh + " " + subMesh ); // convert to quadratic
4068 createPopupItem( 418, OB, mesh + " " + group, // create 2D mesh from 3D
4070 popupMgr()->insert( separator(), -1, 0 );
4072 QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( dc );
4073 QString multiple_non_empty = QString( " && %1>0 && numberOfNodes>0" ).arg( dc );
4074 QString only_one_2D = only_one_non_empty + " && dim>1";
4076 int anId = popupMgr()->insert( tr( "MEN_EXPORT" ), -1, -1 ); // EXPORT submenu
4077 createPopupItem( 125, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_MED
4078 createPopupItem( 126, OB, mesh_group, only_one_non_empty, anId ); // EXPORT_UNV
4079 createPopupItem( 141, OB, mesh_group, only_one_2D, anId ); // EXPORT_STL
4081 createPopupItem( 143, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_CGNS
4083 createPopupItem( 145, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_SAUV
4084 createPopupItem( 147, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_GMF
4085 createPopupItem( 124, OB, mesh_group, multiple_non_empty, anId ); // EXPORT_DAT
4086 createPopupItem( 33, OB, mesh_part + " " + hyp_alg ); // DELETE
4087 createPopupItem( 813, OB, group ); // DEL_GROUP with contents
4088 popupMgr()->insert( separator(), -1, 0 );
4091 createPopupItem( 803, View, group ); // EDIT_GROUP
4092 createPopupItem( 804, View, elems ); // ADD
4093 createPopupItem( 805, View, elems ); // REMOVE
4095 popupMgr()->insert( separator(), -1, 0 );
4096 createPopupItem( 214, View, mesh_part ); // UPDATE
4097 createPopupItem( 900, View, mesh_part ); // ADV_INFO
4098 createPopupItem( 904, View, mesh ); // FIND_ELEM
4099 popupMgr()->insert( separator(), -1, 0 );
4101 createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
4102 createPopupItem( 1137, OB + " " + View, mesh, "&& isAutoColor" ); // DISABLE_AUTO_COLOR
4103 popupMgr()->insert( separator(), -1, 0 );
4105 QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" );
4106 QString aType = QString( "%1type in {%2}" ).arg( lc );
4107 aType = aType.arg( mesh_part );
4108 QString aMeshInVTK = aClient + "&&" + aType;
4110 aClient = "($client in {'VTKViewer' 'ObjectBrowser'})";
4111 QString anActiveVTK = QString("activeView = '%1'").arg(SVTK_Viewer::Type());
4112 QString aSelCount = QString( "%1 > 0" ).arg( dc );
4114 //-------------------------------------------------
4116 //-------------------------------------------------
4117 anId = popupMgr()->insert( tr( "MEN_NUM" ), -1, -1 );
4119 popupMgr()->insert( action( 9010 ), anId, -1 );
4120 popupMgr()->setRule( action( 9010 ), aMeshInVTK + "&& isVisible &&" + hasNodes, QtxPopupMgr::VisibleRule );
4121 popupMgr()->setRule( action( 9010 ), "{'Point'} in labeledTypes", QtxPopupMgr::ToggleRule );
4123 popupMgr()->insert( action( 9011 ), anId, -1 );
4124 popupMgr()->setRule( action( 9011 ), aMeshInVTK + "&& isVisible &&" + hasElems, QtxPopupMgr::VisibleRule );
4125 popupMgr()->setRule( action( 9011 ), "{'Cell'} in labeledTypes", QtxPopupMgr::ToggleRule );
4127 popupMgr()->insert( separator(), -1, -1 );
4129 //-------------------------------------------------
4131 //-------------------------------------------------
4132 anId = popupMgr()->insert( tr( "MEN_DISPMODE" ), -1, -1 );
4134 popupMgr()->insert( action( 211 ), anId, -1 ); // WIRE
4135 popupMgr()->setRule( action( 211 ), aMeshInVTK + "&&" + hasElems, QtxPopupMgr::VisibleRule );
4136 popupMgr()->setRule( action( 211 ), "displayMode = 'eEdge'", QtxPopupMgr::ToggleRule );
4138 popupMgr()->insert( action( 212 ), anId, -1 ); // SHADE
4139 popupMgr()->setRule( action( 212 ),aMeshInVTK+ "&& (" + hasFaces + "||" + hasVolumes + ")", QtxPopupMgr::VisibleRule);
4140 popupMgr()->setRule( action( 212 ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
4142 popupMgr()->insert( action( 215 ), anId, -1 ); // POINTS
4143 popupMgr()->setRule( action( 215 ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule );
4144 popupMgr()->setRule( action( 215 ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
4146 popupMgr()->insert( separator(), anId, -1 );
4148 popupMgr()->insert( action( 213 ), anId, -1 ); // SHRINK
4149 popupMgr()->setRule( action( 213 ), aMeshInVTK + "&& shrinkMode <> 'IsNotShrinkable' && displayMode <> 'ePoint'", QtxPopupMgr::VisibleRule);
4150 popupMgr()->setRule( action( 213 ), "shrinkMode = 'IsShrunk'", QtxPopupMgr::ToggleRule );
4152 //-------------------------------------------------
4154 //-------------------------------------------------
4155 QString aDiffElemsInVTK = aMeshInVTK + "&&" + hasDifferentElems;
4157 anId = popupMgr()->insert( tr( "MEN_DISP_ENT" ), -1, -1 );
4159 popupMgr()->insert( action(216), anId, -1 ); // ELEMS 0D
4160 popupMgr()->setRule(action(216), aDiffElemsInVTK + "&& isVisible &&" + hasElems0d, QtxPopupMgr::VisibleRule);
4161 popupMgr()->setRule(action(216), "{'Elem0d'} in entityMode", QtxPopupMgr::ToggleRule);
4163 popupMgr()->insert( action( 217 ), anId, -1 ); // EDGES
4164 popupMgr()->setRule( action( 217 ), aDiffElemsInVTK + "&& isVisible &&" + hasEdges, QtxPopupMgr::VisibleRule );
4165 popupMgr()->setRule( action( 217 ), "{'Edge'} in entityMode", QtxPopupMgr::ToggleRule );
4167 popupMgr()->insert( action( 218 ), anId, -1 ); // FACES
4168 popupMgr()->setRule( action( 218 ), aDiffElemsInVTK + "&& isVisible &&" + hasFaces, QtxPopupMgr::VisibleRule );
4169 popupMgr()->setRule( action( 218 ), "{'Face'} in entityMode", QtxPopupMgr::ToggleRule );
4171 popupMgr()->insert( action( 219 ), anId, -1 ); // VOLUMES
4172 popupMgr()->setRule( action( 219 ), aDiffElemsInVTK + "&& isVisible &&" + hasVolumes, QtxPopupMgr::VisibleRule );
4173 popupMgr()->setRule( action( 219 ), "{'Volume'} in entityMode", QtxPopupMgr::ToggleRule );
4175 popupMgr()->insert( action( 222 ), anId, -1 ); // BALLS
4176 popupMgr()->setRule( action( 222 ), aDiffElemsInVTK + "&& isVisible &&" + hasBalls, QtxPopupMgr::VisibleRule );
4177 popupMgr()->setRule( action( 222 ), "{'BallElem'} in entityMode", QtxPopupMgr::ToggleRule );
4179 popupMgr()->insert( separator(), anId, -1 );
4181 popupMgr()->insert( action( 220 ), anId, -1 ); // ALL
4182 popupMgr()->setRule( action( 220 ), aDiffElemsInVTK + "&& isVisible && not( elemTypes in entityMode )", QtxPopupMgr::VisibleRule );
4185 //-------------------------------------------------
4186 // Representation of the 2D Quadratic elements
4187 //-------------------------------------------------
4188 anId = popupMgr()->insert( tr( "MEN_QUADRATIC_REPRESENT" ), -1, -1 );
4189 popupMgr()->insert( action( 231 ), anId, -1 ); // LINE REPRESENTATION
4190 popupMgr()->setRule( action( 231 ), aMeshInVTK + "and isVisible",QtxPopupMgr::VisibleRule );
4191 popupMgr()->setRule( action( 231 ), "quadratic2DMode = 'eLines'", QtxPopupMgr::ToggleRule );
4193 popupMgr()->insert( action( 232 ), anId, -1 ); // ARC REPRESENTATION
4194 popupMgr()->setRule( action( 232 ), aMeshInVTK + "and isVisible", QtxPopupMgr::VisibleRule );
4195 popupMgr()->setRule( action( 232 ), "quadratic2DMode = 'eArcs'", QtxPopupMgr::ToggleRule );
4197 //-------------------------------------------------
4198 // Orientation of faces
4199 //-------------------------------------------------
4200 popupMgr()->insert( action( 221 ), -1, -1 );
4201 popupMgr()->setRule( action( 221 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule);
4202 popupMgr()->setRule( action( 221 ), "facesOrientationMode = 'IsOriented'", QtxPopupMgr::ToggleRule );
4204 //-------------------------------------------------
4206 //-------------------------------------------------
4207 popupMgr()->insert( action( 1132 ), -1, -1 );
4208 popupMgr()->setRule( action( 1132 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4210 //-------------------------------------------------
4212 //-------------------------------------------------
4213 popupMgr()->insert( action( 1133 ), -1, -1 );
4214 popupMgr()->setRule( action( 1133 ), aMeshInVTK + "&& isVisible", QtxPopupMgr::VisibleRule );
4216 //-------------------------------------------------
4218 //-------------------------------------------------
4220 aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
4221 aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
4222 aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
4223 aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
4225 anId = popupMgr()->insert( tr( "MEN_CTRL" ), -1, -1 );
4227 popupMgr()->insert( action( 200 ), anId, -1 ); // RESET
4228 popupMgr()->setRule( action( 200 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4230 popupMgr()->insert( separator(), anId, -1 );
4232 int aSubId = popupMgr()->insert( tr( "MEN_NODE_CTRL" ), anId, -1 ); // NODE CONTROLS
4234 popupMgr()->insert( action( 6005 ), aSubId, -1 ); // FREE_NODE
4235 popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4236 popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
4238 popupMgr()->insert ( action( 6028 ), aSubId, -1 ); // EQUAL_NODE
4239 popupMgr()->setRule( action( 6028 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
4240 popupMgr()->setRule( action( 6028 ), "controlMode = 'eCoincidentNodes'", QtxPopupMgr::ToggleRule);
4242 aSubId = popupMgr()->insert( tr( "MEN_EDGE_CTRL" ), anId, -1 ); // EDGE CONTROLS
4244 popupMgr()->insert( action( 6002 ), aSubId, -1 ); // FREE_EDGE
4245 popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4246 popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
4248 popupMgr()->insert( action( 6003 ), aSubId, -1 ); // FREE_BORDER
4249 popupMgr()->setRule( action( 6003 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4250 popupMgr()->setRule( action( 6003 ), "controlMode = 'eFreeBorders'", QtxPopupMgr::ToggleRule );
4252 popupMgr()->insert( action( 6001 ), aSubId, -1 ); // LENGTH
4253 popupMgr()->setRule( action( 6001 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4254 popupMgr()->setRule( action( 6001 ), "controlMode = 'eLength'", QtxPopupMgr::ToggleRule );
4256 popupMgr()->insert( action( 6004 ), aSubId, -1 ); // CONNECTION
4257 popupMgr()->setRule( action( 6004 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4258 popupMgr()->setRule( action( 6004 ), "controlMode = 'eMultiConnection'", QtxPopupMgr::ToggleRule );
4259 popupMgr()->insert ( action( 6029 ), aSubId, -1 ); // EQUAL_EDGE
4260 popupMgr()->setRule( action( 6029 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
4261 popupMgr()->setRule( action( 6029 ), "controlMode = 'eCoincidentElems1D'", QtxPopupMgr::ToggleRule);
4263 aSubId = popupMgr()->insert( tr( "MEN_FACE_CTRL" ), anId, -1 ); // FACE CONTROLS
4265 popupMgr()->insert ( action( 6021 ), aSubId, -1 ); // FREE_FACE
4266 popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
4267 QtxPopupMgr::VisibleRule );
4268 popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
4270 popupMgr()->insert ( action( 6018 ), aSubId, -1 ); // LENGTH_2D
4271 popupMgr()->setRule( action( 6018 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4272 popupMgr()->setRule( action( 6018 ), "controlMode = 'eLength2D'", QtxPopupMgr::ToggleRule );
4274 popupMgr()->insert ( action( 6019 ), aSubId, -1 ); // CONNECTION_2D
4275 popupMgr()->setRule( action( 6019 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4276 popupMgr()->setRule( action( 6019 ), "controlMode = 'eMultiConnection2D'", QtxPopupMgr::ToggleRule );
4278 popupMgr()->insert ( action( 6011 ), aSubId, -1 ); // AREA
4279 popupMgr()->setRule( action( 6011 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4280 popupMgr()->setRule( action( 6011 ), "controlMode = 'eArea'", QtxPopupMgr::ToggleRule );
4282 popupMgr()->insert ( action( 6012 ), aSubId, -1 ); // TAPER
4283 popupMgr()->setRule( action( 6012 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4284 popupMgr()->setRule( action( 6012 ), "controlMode = 'eTaper'", QtxPopupMgr::ToggleRule );
4286 popupMgr()->insert ( action( 6013 ), aSubId, -1 ); // ASPECT
4287 popupMgr()->setRule( action( 6013 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4288 popupMgr()->setRule( action( 6013 ), "controlMode = 'eAspectRatio'", QtxPopupMgr::ToggleRule );
4290 popupMgr()->insert ( action( 6014 ), aSubId, -1 ); // MIN_ANG
4291 popupMgr()->setRule( action( 6014 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4292 popupMgr()->setRule( action( 6014 ), "controlMode = 'eMinimumAngle'", QtxPopupMgr::ToggleRule );
4294 popupMgr()->insert ( action( 6015 ), aSubId, -1 ); // WARP
4295 popupMgr()->setRule( action( 6015 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4296 popupMgr()->setRule( action( 6015 ), "controlMode = 'eWarping'", QtxPopupMgr::ToggleRule );
4298 popupMgr()->insert ( action( 6016 ), aSubId, -1 ); // SKEW
4299 popupMgr()->setRule( action( 6016 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4300 popupMgr()->setRule( action( 6016 ), "controlMode = 'eSkew'", QtxPopupMgr::ToggleRule );
4302 popupMgr()->insert ( action( 6022 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_2D
4303 popupMgr()->setRule( action( 6022 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4304 popupMgr()->setRule( action( 6022 ), "controlMode = 'eMaxElementLength2D'", QtxPopupMgr::ToggleRule );
4306 popupMgr()->insert ( action( 6025 ), aSubId, -1 ); // BARE_BORDER_FACE
4307 popupMgr()->setRule( action( 6025 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4308 popupMgr()->setRule( action( 6025 ), "controlMode = 'eBareBorderFace'", QtxPopupMgr::ToggleRule );
4310 popupMgr()->insert ( action( 6027 ), aSubId, -1 ); // OVER_CONSTRAINED_FACE
4311 popupMgr()->setRule( action( 6027 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4312 popupMgr()->setRule( action( 6027 ), "controlMode = 'eOverConstrainedFace'", QtxPopupMgr::ToggleRule );
4313 popupMgr()->insert ( action( 6030 ), aSubId, -1 ); // EQUAL_FACE
4314 popupMgr()->setRule( action( 6030 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
4315 popupMgr()->setRule( action( 6030 ), "controlMode = 'eCoincidentElems2D'", QtxPopupMgr::ToggleRule );
4317 aSubId = popupMgr()->insert( tr( "MEN_VOLUME_CTRL" ), anId, -1 ); // VOLUME CONTROLS
4319 popupMgr()->insert ( action( 6017 ), aSubId, -1 ); // ASPECT_3D
4320 popupMgr()->setRule( action( 6017 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4321 popupMgr()->setRule( action( 6017 ), "controlMode = 'eAspectRatio3D'", QtxPopupMgr::ToggleRule );
4323 popupMgr()->insert ( action( 6009 ), aSubId, -1 ); // VOLUME_3D
4324 popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4325 popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
4327 popupMgr()->insert ( action( 6023 ), aSubId, -1 ); // MAX_ELEMENT_LENGTH_3D
4328 popupMgr()->setRule( action( 6023 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4329 popupMgr()->setRule( action( 6023 ), "controlMode = 'eMaxElementLength3D'", QtxPopupMgr::ToggleRule );
4331 popupMgr()->insert ( action( 6024 ), aSubId, -1 ); // BARE_BORDER_VOLUME
4332 popupMgr()->setRule( action( 6024 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4333 popupMgr()->setRule( action( 6024 ), "controlMode = 'eBareBorderVolume'", QtxPopupMgr::ToggleRule );
4335 popupMgr()->insert ( action( 6026 ), aSubId, -1 ); // OVER_CONSTRAINED_VOLUME
4336 popupMgr()->setRule( action( 6026 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4337 popupMgr()->setRule( action( 6026 ), "controlMode = 'eOverConstrainedVolume'", QtxPopupMgr::ToggleRule );
4339 popupMgr()->insert ( action( 6031 ), aSubId, -1 ); // EQUAL_VOLUME
4340 popupMgr()->setRule( action( 6031 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
4341 popupMgr()->setRule( action( 6031 ), "controlMode = 'eCoincidentElems3D'", QtxPopupMgr::ToggleRule );
4343 popupMgr()->insert( separator(), anId, -1 );
4345 popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
4346 popupMgr()->setRule( action( 201 ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
4348 popupMgr()->insert( separator(), anId, -1 );
4350 aSubId = popupMgr()->insert( tr( "MEN_DISTRIBUTION_CTRL" ), anId, -1 ); // NODE CONTROLS
4352 popupMgr()->insert( action( 2021 ), aSubId, -1 ); // SAVE_DISTRIBUTION
4353 popupMgr()->setRule( action( 2021 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4355 popupMgr()->insert( action( 2022 ), aSubId, -1 ); // SHOW_DISTRIBUTION
4356 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4357 popupMgr()->setRule( action( 2022 ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
4359 #ifndef DISABLE_PLOT2DVIEWER
4360 popupMgr()->insert( action( 2023 ), aSubId, -1 ); // PLOT_DISTRIBUTION
4361 popupMgr()->setRule( action( 2023 ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
4364 //-------------------------------------------------
4366 //-------------------------------------------------
4367 popupMgr()->insert( separator(), -1, -1 );
4368 QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
4369 aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
4370 popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
4371 popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), QtxPopupMgr::VisibleRule );
4373 popupMgr()->insert( action( 300 ), -1, -1 ); // ERASE
4374 popupMgr()->setRule( action( 300 ), aRule.arg( "and isVisible" ), QtxPopupMgr::VisibleRule );
4376 popupMgr()->insert( action( 302 ), -1, -1 ); // DISPLAY_ONLY
4377 popupMgr()->setRule( action( 302 ), aRule.arg( "" ), QtxPopupMgr::VisibleRule );
4379 popupMgr()->insert( separator(), -1, -1 );
4381 //-------------------------------------------------
4383 //-------------------------------------------------
4384 popupMgr()->insert( action( 1134 ), -1, -1 );
4385 popupMgr()->setRule( action( 1134 ), "client='VTKViewer'", QtxPopupMgr::VisibleRule );
4387 popupMgr()->insert( separator(), -1, -1 );
4389 connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
4390 this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
4392 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
4393 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
4396 //================================================================================
4398 * \brief Return true if SMESH or GEOM objects are selected.
4399 * Is called form LightApp_Module::activateModule() which clear selection if
4400 * not isSelectionCompatible()
4402 //================================================================================
4404 bool SMESHGUI::isSelectionCompatible()
4406 bool isCompatible = true;
4407 SALOME_ListIO selected;
4408 if ( LightApp_SelectionMgr *Sel = selectionMgr() )
4409 Sel->selectedObjects( selected );
4411 SALOME_ListIteratorOfListIO It( selected );
4412 for ( ; isCompatible && It.More(); It.Next())
4414 ( strcmp("GEOM", It.Value()->getComponentDataType()) == 0 ) ||
4415 ( strcmp("SMESH", It.Value()->getComponentDataType()) == 0 );
4417 return isCompatible;
4421 bool SMESHGUI::reusableOperation( const int id )
4423 // compute, evaluate and precompute are not reusable operations
4424 return ( id == 701 || id == 711 || id == 712 ) ? false : SalomeApp_Module::reusableOperation( id );
4427 bool SMESHGUI::activateModule( SUIT_Study* study )
4429 bool res = SalomeApp_Module::activateModule( study );
4431 setMenuShown( true );
4432 setToolShown( true );
4434 // import Python module that manages SMESH plugins (need to be here because SalomePyQt API uses active module)
4435 PyGILState_STATE gstate = PyGILState_Ensure();
4436 PyObject* pluginsmanager=PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager");
4437 if(pluginsmanager==NULL)
4441 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"smesh",tr("MEN_MESH").toStdString().c_str(),tr("SMESH_PLUGINS_OTHER").toStdString().c_str());
4446 PyGILState_Release(gstate);
4447 // end of GEOM plugins loading
4449 // Reset actions accelerator keys
4450 //action(111)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); // Import DAT
4451 action(112)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_U)); // Import UNV
4452 action(113)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); // Import MED
4454 action( 33)->setEnabled(true); // Delete: Key_Delete
4456 // 0020210. Make SMESH_Gen update meshes at switching GEOM->SMESH
4457 GetSMESHGen()->SetCurrentStudy(SALOMEDS::Study::_nil());
4458 if ( SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study ))
4459 if ( _PTR(Study) aStudy = s->studyDS()) {
4460 GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() );
4461 updateObjBrowser(); // objects can be removed
4464 // get all view currently opened in the study and connect their signals to
4465 // the corresponding slots of the class.
4466 SUIT_Desktop* aDesk = study->application()->desktop();
4468 QList<SUIT_ViewWindow*> wndList = aDesk->windows();
4469 SUIT_ViewWindow* wnd;
4470 foreach ( wnd, wndList )
4477 bool SMESHGUI::deactivateModule( SUIT_Study* study )
4479 setMenuShown( false );
4480 setToolShown( false );
4482 EmitSignalCloseAllDialogs();
4484 // Unset actions accelerator keys
4485 //action(111)->setShortcut(QKeySequence()); // Import DAT
4486 action(112)->setShortcut(QKeySequence()); // Import UNV
4487 action(113)->setShortcut(QKeySequence()); // Import MED
4489 action( 33)->setEnabled(false); // Delete: Key_Delete
4491 return SalomeApp_Module::deactivateModule( study );
4494 void SMESHGUI::studyClosed( SUIT_Study* s )
4496 SMESH::RemoveVisuData( s->id() );
4497 SalomeApp_Module::studyClosed( s );
4500 void SMESHGUI::OnGUIEvent()
4502 const QObject* obj = sender();
4503 if ( !obj || !obj->inherits( "QAction" ) )
4505 int id = actionId((QAction*)obj);
4510 SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen()
4512 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
4513 if ( CORBA::is_nil( myComponentSMESH ) )
4515 SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH
4517 aGUI.myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4518 return aGUI.myComponentSMESH;
4521 myComponentSMESH->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
4522 return myComponentSMESH;
4525 QString SMESHGUI::engineIOR() const
4527 CORBA::ORB_var anORB = getApp()->orb();
4528 CORBA::String_var anIOR = anORB->object_to_string(GetSMESHGen());
4529 return QString( anIOR.in() );
4532 void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
4534 SalomeApp_Module::contextMenuPopup( client, menu, title );
4536 selectionMgr()->selectedObjects( lst );
4537 if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
4538 Handle(SALOME_InteractiveObject) io = lst.First();
4539 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
4540 _PTR(Study) study = appStudy->studyDS();
4541 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
4543 QString aName = QString( obj->GetName().c_str() );
4544 while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup
4545 aName.remove( (aName.length() - 1), 1 );
4551 LightApp_Selection* SMESHGUI::createSelection() const
4553 return new SMESHGUI_Selection();
4556 void SMESHGUI::windows( QMap<int, int>& aMap ) const
4558 aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
4559 aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
4562 void SMESHGUI::viewManagers( QStringList& list ) const
4564 list.append( SVTK_Viewer::Type() );
4567 void SMESHGUI::onViewManagerActivated( SUIT_ViewManager* mgr )
4569 if ( dynamic_cast<SVTK_ViewManager*>( mgr ) ) {
4570 SMESH::UpdateSelectionProp( this );
4572 QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
4573 for(int i = 0; i < aViews.count() ; i++){
4574 SUIT_ViewWindow *sf = aViews[i];
4580 void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
4582 if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
4583 myClippingPlaneInfoMap.erase( theViewManager );
4586 void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
4588 theActor->AddObserver( SMESH::DeleteActorEvent,
4589 myEventCallbackCommand.GetPointer(),
4593 void SMESHGUI::ProcessEvents( vtkObject* theObject,
4594 unsigned long theEvent,
4595 void* theClientData,
4598 if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
4599 if( theObject && theEvent == SMESH::DeleteActorEvent ) {
4600 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
4601 SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
4602 SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
4603 for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
4604 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
4605 SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
4606 for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
4607 SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
4608 std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
4609 SMESH::TActorList::iterator anIter3 = anActorList.begin();
4610 for ( ; anIter3 != anActorList.end(); anIter3++ ) {
4611 if( anActor == *anIter3 ) {
4612 anActorList.erase( anIter3 );
4623 void SMESHGUI::createPreferences()
4625 // General tab ------------------------------------------------------------------------
4626 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
4628 int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
4629 int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
4630 setPreferenceProperty( lim, "min", 0 );
4631 setPreferenceProperty( lim, "max", 100000000 );
4632 setPreferenceProperty( lim, "step", 1000 );
4633 setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4635 int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
4636 setPreferenceProperty( qaGroup, "columns", 2 );
4637 addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
4638 addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
4639 int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
4640 setPreferenceProperty( prec, "min", 0 );
4641 setPreferenceProperty( prec, "max", 16 );
4642 int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
4643 setPreferenceProperty( doubleNodesTol, "precision", 10 );
4644 setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
4645 setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
4646 setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
4648 int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
4649 setPreferenceProperty( dispgroup, "columns", 2 );
4650 int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
4652 modes.append( tr("MEN_WIRE") );
4653 modes.append( tr("MEN_SHADE") );
4654 modes.append( tr("MEN_NODES") );
4655 modes.append( tr("MEN_SHRINK") );
4656 QList<QVariant> indices;
4657 indices.append( 0 );
4658 indices.append( 1 );
4659 indices.append( 2 );
4660 indices.append( 3 );
4661 setPreferenceProperty( dispmode, "strings", modes );
4662 setPreferenceProperty( dispmode, "indexes", indices );
4664 int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
4665 setPreferenceProperty( arcgroup, "columns", 2 );
4666 int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
4667 QStringList quadraticModes;
4668 quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
4669 quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
4671 indices.append( 0 );
4672 indices.append( 1 );
4673 setPreferenceProperty( quadraticmode, "strings", quadraticModes );
4674 setPreferenceProperty( quadraticmode, "indexes", indices );
4676 int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
4677 "SMESH", "max_angle" );
4678 setPreferenceProperty( maxAngle, "min", 1 );
4679 setPreferenceProperty( maxAngle, "max", 90 );
4683 int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
4684 setPreferenceProperty( exportgroup, "columns", 2 );
4685 addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
4686 addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
4688 int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
4689 setPreferenceProperty( computeGroup, "columns", 2 );
4690 int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
4692 modes.append( tr( "PREF_NOTIFY_NEVER" ) );
4693 modes.append( tr( "PREF_NOTIFY_ERROR" ) );
4694 modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
4696 indices.append( 0 );
4697 indices.append( 1 );
4698 indices.append( 2 );
4699 setPreferenceProperty( notifyMode, "strings", modes );
4700 setPreferenceProperty( notifyMode, "indexes", indices );
4702 int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
4703 setPreferenceProperty( infoGroup, "columns", 4 );
4704 int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
4706 modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
4707 modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
4709 indices.append( 0 );
4710 indices.append( 1 );
4711 setPreferenceProperty( elemInfo, "strings", modes );
4712 setPreferenceProperty( elemInfo, "indexes", indices );
4713 int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
4714 setPreferenceProperty( nodesLim, "min", 0 );
4715 setPreferenceProperty( nodesLim, "max", 10000000 );
4716 setPreferenceProperty( nodesLim, "step", 10000 );
4717 setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
4719 int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
4720 setPreferenceProperty( segGroup, "columns", 2 );
4721 int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
4722 "SMESH", "segmentation" );
4723 setPreferenceProperty( segLen, "min", 1 );
4724 setPreferenceProperty( segLen, "max", 10000000 );
4725 int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
4726 "SMESH", "nb_segments_per_edge" );
4727 setPreferenceProperty( nbSeg, "min", 1 );
4728 setPreferenceProperty( nbSeg, "max", 10000000 );
4730 int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
4731 addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
4732 "SMESH", "forget_mesh_on_hyp_modif" );
4735 // Quantities with individual precision settings
4736 int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
4737 setPreferenceProperty( precGroup, "columns", 2 );
4739 const int nbQuantities = 6;
4740 int precs[nbQuantities], ii = 0;
4741 precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
4742 LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
4743 precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
4744 LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
4745 precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
4746 LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
4747 precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
4748 LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
4749 precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
4750 LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
4751 precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
4752 LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
4754 // Set property for precision value for spinboxes
4755 for ( ii = 0; ii < nbQuantities; ii++ ){
4756 setPreferenceProperty( precs[ii], "min", -14 );
4757 setPreferenceProperty( precs[ii], "max", 14 );
4758 setPreferenceProperty( precs[ii], "precision", 2 );
4761 int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
4762 setPreferenceProperty( previewGroup, "columns", 2 );
4763 int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
4764 setPreferenceProperty( chunkSize, "min", 1 );
4765 setPreferenceProperty( chunkSize, "max", 1000 );
4766 setPreferenceProperty( chunkSize, "step", 50 );
4768 int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
4769 addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
4771 // Mesh tab ------------------------------------------------------------------------
4772 int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
4773 int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
4774 setPreferenceProperty( nodeGroup, "columns", 3 );
4776 addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
4778 int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
4780 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4781 QList<QVariant> aMarkerTypeIndicesList;
4782 QList<QVariant> aMarkerTypeIconsList;
4783 for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
4784 QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
4785 QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
4786 aMarkerTypeIndicesList << i;
4787 aMarkerTypeIconsList << pixmap;
4789 setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
4790 setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
4792 int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
4794 QList<QVariant> aMarkerScaleIndicesList;
4795 QStringList aMarkerScaleValuesList;
4796 for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
4797 aMarkerScaleIndicesList << i;
4798 aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
4800 setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
4801 setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
4803 int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
4804 //setPreferenceProperty( elemGroup, "columns", 2 );
4806 int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
4807 setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
4808 ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
4809 setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
4810 addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
4811 addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
4812 addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
4813 addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
4816 int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
4817 setPreferenceProperty( grpGroup, "columns", 2 );
4819 addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
4820 addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
4822 int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
4823 LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
4824 int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
4825 LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
4826 int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
4827 LightApp_Preferences::IntSpin, "SMESH", "element_width");
4828 int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
4829 LightApp_Preferences::IntSpin, "SMESH", "outline_width");
4830 int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
4831 LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
4833 setPreferenceProperty( size0d, "min", 1 );
4834 setPreferenceProperty( size0d, "max", 10 );
4836 setPreferenceProperty( ballSize, "min", 1 );
4837 setPreferenceProperty( ballSize, "max", 10 );
4839 setPreferenceProperty( elemW, "min", 1 );
4840 setPreferenceProperty( elemW, "max", 5 );
4842 setPreferenceProperty( outW, "min", 1 );
4843 setPreferenceProperty( outW, "max", 5 );
4845 setPreferenceProperty( shrink, "min", 0 );
4846 setPreferenceProperty( shrink, "max", 100 );
4848 int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
4849 setPreferenceProperty( orientGroup, "columns", 1 );
4851 addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
4852 int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
4854 setPreferenceProperty( orientScale, "min", 0.05 );
4855 setPreferenceProperty( orientScale, "max", 0.5 );
4856 setPreferenceProperty( orientScale, "step", 0.05 );
4858 addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
4860 // Selection tab ------------------------------------------------------------------------
4861 int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
4863 int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
4864 setPreferenceProperty( selGroup, "columns", 2 );
4866 addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
4867 addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
4869 int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
4870 setPreferenceProperty( preGroup, "columns", 2 );
4872 addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
4874 int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
4875 setPreferenceProperty( precSelGroup, "columns", 2 );
4877 addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
4878 addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
4879 addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
4881 // Scalar Bar tab ------------------------------------------------------------------------
4882 int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
4883 int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
4884 setPreferenceProperty( fontGr, "columns", 2 );
4886 addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
4887 addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
4889 addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
4890 addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
4892 int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
4893 setPreferenceProperty( colorsLabelsGr, "columns", 2 );
4895 int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
4896 setPreferenceProperty( numcol, "min", 2 );
4897 setPreferenceProperty( numcol, "max", 256 );
4899 int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
4900 setPreferenceProperty( numlab, "min", 2 );
4901 setPreferenceProperty( numlab, "max", 65 );
4903 int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
4904 setPreferenceProperty( orientGr, "columns", 2 );
4905 int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
4906 QStringList orients;
4907 orients.append( tr( "SMESH_VERTICAL" ) );
4908 orients.append( tr( "SMESH_HORIZONTAL" ) );
4909 indices.clear(); indices.append( 0 ); indices.append( 1 );
4910 setPreferenceProperty( orient, "strings", orients );
4911 setPreferenceProperty( orient, "indexes", indices );
4913 int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
4914 setPreferenceProperty( posVSizeGr, "columns", 2 );
4915 int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
4916 int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
4917 int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
4918 int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
4919 setPreferenceProperty( xv, "step", 0.1 );
4920 setPreferenceProperty( xv, "min", 0.0 );
4921 setPreferenceProperty( xv, "max", 1.0 );
4922 setPreferenceProperty( yv, "step", 0.1 );
4923 setPreferenceProperty( yv, "min", 0.0 );
4924 setPreferenceProperty( yv, "max", 1.0 );
4925 setPreferenceProperty( wv, "step", 0.1 );
4926 setPreferenceProperty( wv, "min", 0.0 );
4927 setPreferenceProperty( wv, "max", 1.0 );
4928 setPreferenceProperty( hv, "min", 0.0 );
4929 setPreferenceProperty( hv, "max", 1.0 );
4930 setPreferenceProperty( hv, "step", 0.1 );
4932 int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
4933 setPreferenceProperty( posHSizeGr, "columns", 2 );
4934 int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
4935 int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
4936 int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
4937 int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
4938 setPreferenceProperty( xv, "min", 0.0 );
4939 setPreferenceProperty( xv, "max", 1.0 );
4940 setPreferenceProperty( xv, "step", 0.1 );
4941 setPreferenceProperty( xh, "min", 0.0 );
4942 setPreferenceProperty( xh, "max", 1.0 );
4943 setPreferenceProperty( xh, "step", 0.1 );
4944 setPreferenceProperty( yh, "min", 0.0 );
4945 setPreferenceProperty( yh, "max", 1.0 );
4946 setPreferenceProperty( yh, "step", 0.1 );
4947 setPreferenceProperty( wh, "min", 0.0 );
4948 setPreferenceProperty( wh, "max", 1.0 );
4949 setPreferenceProperty( wh, "step", 0.1 );
4950 setPreferenceProperty( hh, "min", 0.0 );
4951 setPreferenceProperty( hh, "max", 1.0 );
4952 setPreferenceProperty( hh, "step", 0.1 );
4954 int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
4955 int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
4956 setPreferenceProperty( distributionGr, "columns", 3 );
4958 types.append( tr( "SMESH_MONOCOLOR" ) );
4959 types.append( tr( "SMESH_MULTICOLOR" ) );
4960 indices.clear(); indices.append( 0 ); indices.append( 1 );
4961 setPreferenceProperty( coloringType, "strings", types );
4962 setPreferenceProperty( coloringType, "indexes", indices );
4963 addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
4967 void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
4969 if( sect=="SMESH" ) {
4970 float sbX1,sbY1,sbW,sbH;
4971 float aTol = 1.00000009999999;
4972 std::string aWarning;
4973 SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
4974 if( name=="selection_object_color" || name=="selection_element_color" ||
4975 name=="highlight_color" ||
4976 name=="selection_precision_node" || name=="selection_precision_element" ||
4977 name=="selection_precision_object")
4978 SMESH::UpdateSelectionProp( this );
4979 else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
4980 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
4981 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
4982 if(sbX1+sbW > aTol){
4983 aWarning = "Origin and Size Vertical: X+Width > 1\n";
4986 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
4987 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
4990 else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
4991 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
4992 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
4993 if(sbY1+sbH > aTol){
4994 aWarning = "Origin and Size Vertical: Y+Height > 1\n";
4995 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
4996 aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
4999 else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
5000 sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5001 sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
5002 if(sbX1+sbW > aTol){
5003 aWarning = "Origin and Size Horizontal: X+Width > 1\n";
5006 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
5007 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
5010 else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
5011 sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5012 sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
5013 if(sbY1+sbH > aTol){
5014 aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
5017 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
5018 aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
5021 else if ( name == "segmentation" ) {
5022 int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
5023 myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
5025 else if ( name == "nb_segments_per_edge" ) {
5026 int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
5027 myComponentSMESH->SetDefaultNbSegments( nbSeg );
5029 else if ( name == "historical_python_dump" ||
5030 name == "forget_mesh_on_hyp_modif") {
5031 QString val = aResourceMgr->stringValue( "SMESH", name );
5032 myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
5035 if(aWarning.size() != 0){
5036 aWarning += "The default values are applied instead.";
5037 SUIT_MessageBox::warning(SMESHGUI::desktop(),
5038 QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
5039 QObject::tr(aWarning.c_str()));
5044 //================================================================================
5046 * \brief Update something in accordance with update flags
5047 * \param theFlags - update flags
5049 * Update viewer or/and object browser etc. in accordance with update flags ( see
5050 * LightApp_UpdateFlags enumeration ).
5052 //================================================================================
5053 void SMESHGUI::update( const int flags )
5055 if ( (flags & UF_Viewer) | (flags & UF_Forced) )
5056 SMESH::UpdateView();
5058 SalomeApp_Module::update( flags );
5061 //================================================================================
5063 * \brief Set default selection mode
5065 * SLOT called when operation commited. Sets default selection mode
5067 //================================================================================
5068 void SMESHGUI::onOperationCommited( SUIT_Operation* )
5070 SVTK_ViewWindow* vtkWnd =
5071 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5073 vtkWnd->SetSelectionMode( ActorSelection );
5076 //================================================================================
5078 * \brief Set default selection mode
5080 * SLOT called when operation aborted. Sets default selection mode
5082 //================================================================================
5083 void SMESHGUI::onOperationAborted( SUIT_Operation* )
5085 SVTK_ViewWindow* vtkWnd =
5086 dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
5088 vtkWnd->SetSelectionMode( ActorSelection );
5091 //================================================================================
5093 * \brief Creates operation with given identifier
5094 * \param id - identifier of operation to be started
5095 * \return Pointer on created operation or NULL if operation is not created
5097 * Virtual method redefined from the base class creates operation with given id.
5098 * It is called called automatically from startOperation method of base class.
5100 //================================================================================
5101 LightApp_Operation* SMESHGUI::createOperation( const int id ) const
5103 LightApp_Operation* op = 0;
5104 // to do : create operation here
5107 case 417: //convert to quadratic
5108 op = new SMESHGUI_ConvToQuadOp();
5110 case 418: // create 2D mesh as boundary on 3D
5111 op = new SMESHGUI_Make2DFrom3DOp();
5113 case 420: // Reorient faces
5114 op = new SMESHGUI_ReorientFacesOp();
5116 case 701: // Compute mesh
5117 op = new SMESHGUI_ComputeOp();
5119 case 702: // Create mesh
5120 op = new SMESHGUI_MeshOp( true, true );
5122 case 703: // Create sub-mesh
5123 op = new SMESHGUI_MeshOp( true, false );
5125 case 704: // Edit mesh/sub-mesh
5126 op = new SMESHGUI_MeshOp( false );
5128 case 711: // Precompute mesh
5129 op = new SMESHGUI_PrecomputeOp();
5131 case 712: // Evaluate mesh
5132 op = new SMESHGUI_EvaluateOp();
5134 case 713: // Evaluate mesh
5135 op = new SMESHGUI_MeshOrderOp();
5137 case 806: // Create group on geom
5138 op = new SMESHGUI_GroupOnShapeOp();
5140 case 904: // Find element
5141 op = new SMESHGUI_FindElemByPointOp();
5143 case 4067: // Make mesh pass through point
5144 op = new SMESHGUI_MakeNodeAtPointOp();
5146 case 4070: // Create 0D elements on all nodes
5147 op = new SMESHGUI_Add0DElemsOnAllNodesOp();
5154 op = SalomeApp_Module::createOperation( id );
5158 //================================================================================
5160 * \brief Stops current operations and starts a given one
5161 * \param id - The id of the operation to start
5163 //================================================================================
5165 void SMESHGUI::switchToOperation(int id)
5167 if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
5168 activeStudy()->abortAllOperations();
5169 startOperation( id );
5172 LightApp_Displayer* SMESHGUI::displayer()
5175 myDisplayer = new SMESHGUI_Displayer( getApp() );
5179 SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
5182 int aTolerance = 64;
5183 int anIterations = 0;
5189 if( anIterations % aPeriod == 0 )
5192 if( aTolerance < 1 )
5196 aHue = (int)( 360.0 * rand() / RAND_MAX );
5199 QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
5200 QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
5201 for( ; it != itEnd; ++it )
5203 SALOMEDS::Color anAutoColor = *it;
5204 QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
5207 aQColor.getHsv( &h, &s, &v );
5208 if( abs( h - aHue ) < aTolerance )
5220 aColor.setHsv( aHue, 255, 255 );
5222 SALOMEDS::Color aSColor;
5223 aSColor.R = aColor.redF();
5224 aSColor.G = aColor.greenF();
5225 aSColor.B = aColor.blueF();
5230 const char* gSeparator = "_"; // character used to separate parameter names
5231 const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
5232 const char* gPathSep = "|"; // character used to separate paths
5235 * \brief Store visual parameters
5237 * This method is called just before the study document is saved.
5238 * Store visual parameters in AttributeParameter attribue(s)
5240 void SMESHGUI::storeVisualParameters (int savePoint)
5243 Kernel_Utils::Localizer loc;
5245 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5246 if (!appStudy || !appStudy->studyDS())
5248 _PTR(Study) studyDS = appStudy->studyDS();
5250 // componentName is used for encoding of entries when storing them in IParameters
5251 std::string componentName = myComponentSMESH->ComponentDataType();
5252 //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
5253 //if (!aSComponent) return;
5256 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5257 componentName.c_str(),
5259 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5261 // store map of custom markers
5262 const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5263 if( !aMarkerMap.empty() )
5265 VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
5266 for( ; anIter != aMarkerMap.end(); anIter++ )
5268 int anId = anIter->first;
5269 VTK::MarkerData aMarkerData = anIter->second;
5270 std::string aMarkerFileName = aMarkerData.first;
5271 VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
5272 if( aMarkerTexture.size() < 3 )
5273 continue; // should contain at least width, height and the first value
5275 QString aPropertyName( "texture" );
5276 aPropertyName += gSeparator;
5277 aPropertyName += QString::number( anId );
5279 QString aPropertyValue = aMarkerFileName.c_str();
5280 aPropertyValue += gPathSep;
5282 VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
5283 ushort aWidth = *aTextureIter++;
5284 ushort aHeight = *aTextureIter++;
5285 aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
5286 aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
5287 for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
5288 aPropertyValue += QString::number( *aTextureIter );
5290 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5294 // viewers counters are used for storing view_numbers in IParameters
5297 // main cycle to store parameters of displayed objects
5298 QList<SUIT_ViewManager*> lst;
5299 QList<SUIT_ViewManager*>::Iterator it;
5300 getApp()->viewManagers(lst);
5301 for (it = lst.begin(); it != lst.end(); it++)
5303 SUIT_ViewManager* vman = *it;
5304 QString vType = vman->getType();
5306 // saving VTK actors properties
5307 if (vType == SVTK_Viewer::Type())
5309 // store the clipping planes attached to the view manager
5310 SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
5311 SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
5312 if( anIter != myClippingPlaneInfoMap.end() )
5313 aClippingPlaneInfoList = anIter->second;
5315 if( !aClippingPlaneInfoList.empty() ) {
5316 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
5317 for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
5319 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
5320 SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
5322 QString aPropertyName( "ClippingPlane" );
5323 aPropertyName += gSeparator;
5324 aPropertyName += QString::number( vtkViewers );
5325 aPropertyName += gSeparator;
5326 aPropertyName += QString::number( anId );
5328 QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
5329 aPropertyValue += gDigitsSep;
5330 aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
5331 aPropertyValue += gDigitsSep;
5332 aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
5333 aPropertyValue += gDigitsSep;
5334 aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
5336 ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
5340 QVector<SUIT_ViewWindow*> views = vman->getViews();
5341 for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
5343 if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
5345 VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
5346 vtkActorCollection* allActors = aCopy.GetActors();
5347 allActors->InitTraversal();
5348 while (vtkActor* actor = allActors->GetNextActor())
5350 if (actor->GetVisibility()) // store only visible actors
5352 SMESH_Actor* aSmeshActor = 0;
5353 if (actor->IsA("SMESH_Actor"))
5354 aSmeshActor = SMESH_Actor::SafeDownCast(actor);
5355 if (aSmeshActor && aSmeshActor->hasIO())
5357 Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
5360 // entry is "encoded" = it does NOT contain component adress,
5361 // since it is a subject to change on next component loading
5362 std::string entry = ip->encodeEntry(io->getEntry(), componentName);
5364 std::string param, vtkParam = vType.toLatin1().data();
5365 vtkParam += gSeparator;
5366 vtkParam += QString::number(vtkViewers).toLatin1().data();
5367 vtkParam += gSeparator;
5370 param = vtkParam + "Visibility";
5371 ip->setParameter(entry, param, "On");
5374 param = vtkParam + "Representation";
5375 ip->setParameter(entry, param, QString::number
5376 ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
5379 param = vtkParam + "IsShrunk";
5380 ip->setParameter(entry, param, QString::number
5381 ((int)aSmeshActor->IsShrunk()).toLatin1().data());
5383 // Displayed entities
5384 unsigned int aMode = aSmeshActor->GetEntityMode();
5385 bool isE = aMode & SMESH_Actor::eEdges;
5386 bool isF = aMode & SMESH_Actor::eFaces;
5387 bool isV = aMode & SMESH_Actor::eVolumes;
5388 bool is0d = aMode & SMESH_Actor::e0DElements;
5389 bool isB = aMode & SMESH_Actor::eBallElem;
5391 QString modeStr ("e");
5392 modeStr += gDigitsSep; modeStr += QString::number(isE);
5393 modeStr += gDigitsSep; modeStr += "f";
5394 modeStr += gDigitsSep; modeStr += QString::number(isF);
5395 modeStr += gDigitsSep; modeStr += "v";
5396 modeStr += gDigitsSep; modeStr += QString::number(isV);
5397 modeStr += gDigitsSep; modeStr += "0d";
5398 modeStr += gDigitsSep; modeStr += QString::number(is0d);
5399 modeStr += gDigitsSep; modeStr += "b";
5400 modeStr += gDigitsSep; modeStr += QString::number(isB);
5402 param = vtkParam + "Entities";
5403 ip->setParameter(entry, param, modeStr.toLatin1().data());
5406 vtkFloatingPointType r, g, b;
5409 aSmeshActor->GetSufaceColor(r, g, b, delta);
5410 QStringList colorStr;
5411 colorStr << "surface";
5412 colorStr << QString::number(r);
5413 colorStr << QString::number(g);
5414 colorStr << QString::number(b);
5416 colorStr << "backsurface";
5417 colorStr << QString::number(delta);
5419 aSmeshActor->GetVolumeColor(r, g, b, delta);
5420 colorStr << "volume";
5421 colorStr << QString::number(r);
5422 colorStr << QString::number(g);
5423 colorStr << QString::number(b);
5424 colorStr << QString::number(delta);
5426 aSmeshActor->GetEdgeColor(r, g, b);
5428 colorStr << QString::number(r);
5429 colorStr << QString::number(g);
5430 colorStr << QString::number(b);
5432 aSmeshActor->GetNodeColor(r, g, b);
5434 colorStr << QString::number(r);
5435 colorStr << QString::number(g);
5436 colorStr << QString::number(b);
5438 aSmeshActor->GetOutlineColor(r, g, b);
5439 colorStr << "outline";
5440 colorStr << QString::number(r);
5441 colorStr << QString::number(g);
5442 colorStr << QString::number(b);
5444 aSmeshActor->Get0DColor(r, g, b);
5445 colorStr << "elem0d";
5446 colorStr << QString::number(r);
5447 colorStr << QString::number(g);
5448 colorStr << QString::number(b);
5450 aSmeshActor->GetBallColor(r, g, b);
5452 colorStr << QString::number(r);
5453 colorStr << QString::number(g);
5454 colorStr << QString::number(b);
5456 aSmeshActor->GetFacesOrientationColor(r, g, b);
5457 colorStr << "orientation";
5458 colorStr << QString::number(r);
5459 colorStr << QString::number(g);
5460 colorStr << QString::number(b);
5462 param = vtkParam + "Colors";
5463 ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
5466 QStringList sizeStr;
5468 sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
5469 sizeStr << "outline";
5470 sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
5471 sizeStr << "elem0d";
5472 sizeStr << QString::number((int)aSmeshActor->Get0DSize());
5474 sizeStr << QString::number((int)aSmeshActor->GetBallSize());
5475 sizeStr << "shrink";
5476 sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
5477 sizeStr << "orientation";
5478 sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
5479 sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
5481 param = vtkParam + "Sizes";
5482 ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
5487 VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
5488 if( aMarkerType == VTK::MT_USER ) {
5489 markerStr += "custom";
5490 markerStr += gDigitsSep;
5491 markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
5495 markerStr += gDigitsSep;
5496 markerStr += QString::number( (int)aMarkerType );
5497 markerStr += gDigitsSep;
5498 markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
5501 param = vtkParam + "PointMarker";
5502 ip->setParameter(entry, param, markerStr.toLatin1().data());
5505 param = vtkParam + "Opacity";
5506 ip->setParameter(entry, param,
5507 QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
5510 param = vtkParam + "ClippingPlane";
5512 if( !aClippingPlaneInfoList.empty() ) {
5513 SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
5514 for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
5516 const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
5517 std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
5518 SMESH::TActorList::iterator anIter2 = anActorList.begin();
5519 for ( ; anIter2 != anActorList.end(); anIter2++ ) {
5520 if( aSmeshActor == *anIter2 ) {
5521 ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
5522 QString::number( anId ).toLatin1().constData() );
5529 ip->setParameter( entry, param, "Off" );
5530 } // if (io->hasEntry())
5531 } // SMESH_Actor && hasIO
5533 } // while.. actors traversal
5537 } // if (SVTK view model)
5538 } // for (viewManagers)
5541 // data structures for clipping planes processing
5544 vtkIdType Orientation;
5545 vtkFloatingPointType Distance;
5546 vtkFloatingPointType Angle[2];
5548 typedef std::list<TPlaneData> TPlaneDataList;
5549 typedef std::map<int, TPlaneDataList> TPlaneDataMap;
5551 typedef std::list<vtkActor*> TActorList;
5554 TActorList ActorList;
5555 SUIT_ViewManager* ViewManager;
5557 typedef std::list<TPlaneInfo> TPlaneInfoList;
5558 typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
5561 * \brief Restore visual parameters
5563 * This method is called after the study document is opened.
5564 * Restore visual parameters from AttributeParameter attribue(s)
5566 void SMESHGUI::restoreVisualParameters (int savePoint)
5569 Kernel_Utils::Localizer loc;
5571 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
5572 if (!appStudy || !appStudy->studyDS())
5574 _PTR(Study) studyDS = appStudy->studyDS();
5576 // componentName is used for encoding of entries when storing them in IParameters
5577 std::string componentName = myComponentSMESH->ComponentDataType();
5578 //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
5579 //if (!aSComponent) return;
5582 _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
5583 componentName.c_str(),
5585 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
5587 // restore map of custom markers and map of clipping planes
5588 VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
5589 TPlaneDataMap aPlaneDataMap;
5591 std::vector<std::string> properties = ip->getProperties();
5592 for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
5594 std::string property = *propIt;
5595 QString aPropertyName( property.c_str() );
5596 QString aPropertyValue( ip->getProperty( property ).c_str() );
5598 QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
5599 if( aPropertyNameList.isEmpty() )
5602 QString aPropertyType = aPropertyNameList[0];
5603 if( aPropertyType == "texture" )
5605 if( aPropertyNameList.size() != 2 )
5609 int anId = aPropertyNameList[1].toInt( &ok );
5610 if( !ok || anId < 1 )
5613 QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
5614 if( aPropertyValueList.size() != 2 )
5617 std::string aMarkerFileName = aPropertyValueList[0].toStdString();
5618 QString aMarkerTextureString = aPropertyValueList[1];
5619 QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
5620 if( aMarkerTextureStringList.size() != 3 )
5624 ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
5629 ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
5633 VTK::MarkerTexture aMarkerTexture;
5634 aMarkerTexture.push_back( aWidth );
5635 aMarkerTexture.push_back( aHeight );
5637 QString aMarkerTextureData = aMarkerTextureStringList[2];
5638 for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
5640 QChar aChar = aMarkerTextureData.at( i );
5641 if( aChar.isDigit() )
5642 aMarkerTexture.push_back( aChar.digitValue() );
5645 aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
5647 else if( aPropertyType == "ClippingPlane" )
5649 if( aPropertyNameList.size() != 3 )
5653 int aViewId = aPropertyNameList[1].toInt( &ok );
5654 if( !ok || aViewId < 0 )
5658 int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
5659 if( !ok || aClippingPlaneId < 0 )
5662 QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
5663 if( aPropertyValueList.size() != 4 )
5666 TPlaneData aPlaneData;
5667 aPlaneData.Id = aClippingPlaneId;
5670 aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
5675 aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
5680 aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
5685 aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
5689 TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
5690 aPlaneDataList.push_back( aPlaneData );
5694 TPlaneInfoMap aPlaneInfoMap;
5696 std::vector<std::string> entries = ip->getEntries();
5698 for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
5700 // entry is a normal entry - it should be "decoded" (setting base adress of component)
5701 QString entry (ip->decodeEntry(*entIt).c_str());
5703 // Check that the entry corresponds to a real object in the Study
5704 // as the object may be deleted or modified after the visual state is saved.
5705 _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
5706 if (!so) continue; //Skip the not existent entry
5708 std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
5709 std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
5711 std::vector<std::string>::iterator namesIt = paramNames.begin();
5712 std::vector<std::string>::iterator valuesIt = paramValues.begin();
5714 // actors are stored in a map after displaying of them for
5715 // quicker access in the future: map < viewID to actor >
5716 NCollection_DataMap<int, SMESH_Actor*> vtkActors;
5718 for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
5720 // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
5721 // '_' is used as separator and should not be used in viewer type or parameter names.
5722 QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
5723 if (lst.size() != 3)
5726 QString viewerTypStr = lst[0];
5727 QString viewIndexStr = lst[1];
5728 QString paramNameStr = lst[2];
5731 int viewIndex = viewIndexStr.toUInt(&ok);
5732 if (!ok) // bad conversion of view index to integer
5736 if (viewerTypStr == SVTK_Viewer::Type())
5738 SMESH_Actor* aSmeshActor = 0;
5739 if (vtkActors.IsBound(viewIndex))
5740 aSmeshActor = vtkActors.Find(viewIndex);
5742 QList<SUIT_ViewManager*> lst;
5743 getApp()->viewManagers(viewerTypStr, lst);
5745 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
5746 SUIT_ViewManager* vman = NULL;
5747 if (viewIndex >= 0 && viewIndex < lst.count())
5748 vman = lst.at(viewIndex);
5750 if (paramNameStr == "Visibility")
5752 if (!aSmeshActor && displayer() && vman)
5754 SUIT_ViewModel* vmodel = vman->getViewModel();
5755 // SVTK view model can be casted to SALOME_View
5756 displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
5758 // store displayed actor in a temporary map for quicker
5759 // access later when restoring other parameters
5760 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
5761 vtkRenderer* Renderer = vtkView->getRenderer();
5762 VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
5763 vtkActorCollection* theActors = aCopy.GetActors();
5764 theActors->InitTraversal();
5765 bool isFound = false;
5766 vtkActor *ac = theActors->GetNextActor();
5767 for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
5768 if (ac->IsA("SMESH_Actor")) {
5769 SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
5770 if (aGeomAc->hasIO()) {
5771 Handle(SALOME_InteractiveObject) io =
5772 Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
5773 if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
5775 vtkActors.Bind(viewIndex, aGeomAc);
5781 } // if (paramNameStr == "Visibility")
5784 // the rest properties "work" with SMESH_Actor
5787 QString val ((*valuesIt).c_str());
5790 if (paramNameStr == "Representation") {
5791 aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
5794 else if (paramNameStr == "IsShrunk") {
5796 if (!aSmeshActor->IsShrunk())
5797 aSmeshActor->SetShrink();
5800 if (aSmeshActor->IsShrunk())
5801 aSmeshActor->UnShrink();
5804 // Displayed entities
5805 else if (paramNameStr == "Entities") {
5806 QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
5807 int aEntityMode = SMESH_Actor::eAllEntity;
5808 for ( int i = 0; i < mode.count(); i+=2 ) {
5809 if ( i < mode.count()-1 ) {
5810 QString type = mode[i];
5811 bool val = mode[i+1].toInt();
5812 if ( type == "e" && !val )
5813 aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
5814 else if ( type == "f" && !val )
5815 aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
5816 else if ( type == "v" && !val )
5817 aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
5818 else if ( type == "0d" && !val )
5819 aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
5820 else if ( type == "b" && !val )
5821 aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
5824 aSmeshActor->SetEntityMode( aEntityMode );
5827 else if (paramNameStr == "Colors") {
5828 QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
5835 QColor outlineColor;
5836 QColor orientationColor;
5842 // below lines are required to get default values for delta coefficients
5843 // of backface color for faces and color of reversed volumes
5844 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
5845 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
5846 for ( int i = 0; i < colors.count(); i++ ) {
5847 QString type = colors[i];
5848 if ( type == "surface" ) {
5849 // face color is set by 3 values r:g:b, where
5850 // - r,g,b - is rgb color components
5851 if ( i+1 >= colors.count() ) break; // format error
5852 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5853 if ( i+2 >= colors.count() ) break; // format error
5854 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5855 if ( i+3 >= colors.count() ) break; // format error
5856 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5857 faceColor.setRgbF( r, g, b );
5860 else if ( type == "backsurface" ) {
5861 // backface color can be defined in several ways
5862 // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
5863 // - in latest versions, it is set as delta coefficient
5864 bool rgbOk = false, deltaOk;
5865 if ( i+1 >= colors.count() ) break; // format error
5866 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5867 int delta = colors[i+1].toInt( &deltaOk );
5869 if ( i+1 < colors.count() ) // index is shifted to 1
5870 g = colors[i+1].toDouble( &rgbOk );
5871 if ( rgbOk ) i++; // shift index
5872 if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
5873 b = colors[i+1].toDouble( &rgbOk );
5875 // - as currently there's no way to set directly backsurface color as it was before,
5876 // we ignore old dump where r,g,b triple was set
5877 // - also we check that delta parameter is set properly
5878 if ( !rgbOk && deltaOk )
5881 else if ( type == "volume" ) {
5882 // volume color is set by 4 values r:g:b:delta, where
5883 // - r,g,b - is a normal volume rgb color components
5884 // - delta - is a reversed volume color delta coefficient
5885 if ( i+1 >= colors.count() ) break; // format error
5886 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5887 if ( i+2 >= colors.count() ) break; // format error
5888 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5889 if ( i+3 >= colors.count() ) break; // format error
5890 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5891 if ( i+4 >= colors.count() ) break; // format error
5892 int delta = colors[i+4].toInt( &bOk );
5893 if ( !bOk ) break; // format error
5894 volumeColor.setRgbF( r, g, b );
5898 else if ( type == "edge" ) {
5899 // edge color is set by 3 values r:g:b, where
5900 // - r,g,b - is rgb color components
5901 if ( i+1 >= colors.count() ) break; // format error
5902 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5903 if ( i+2 >= colors.count() ) break; // format error
5904 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5905 if ( i+3 >= colors.count() ) break; // format error
5906 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5907 edgeColor.setRgbF( r, g, b );
5910 else if ( type == "node" ) {
5911 // node color is set by 3 values r:g:b, where
5912 // - r,g,b - is rgb color components
5913 if ( i+1 >= colors.count() ) break; // format error
5914 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5915 if ( i+2 >= colors.count() ) break; // format error
5916 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5917 if ( i+3 >= colors.count() ) break; // format error
5918 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5919 nodeColor.setRgbF( r, g, b );
5922 else if ( type == "elem0d" ) {
5923 // 0d element color is set by 3 values r:g:b, where
5924 // - r,g,b - is rgb color components
5925 if ( i+1 >= colors.count() ) break; // format error
5926 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5927 if ( i+2 >= colors.count() ) break; // format error
5928 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5929 if ( i+3 >= colors.count() ) break; // format error
5930 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5931 elem0dColor.setRgbF( r, g, b );
5934 else if ( type == "ball" ) {
5935 // ball color is set by 3 values r:g:b, where
5936 // - r,g,b - is rgb color components
5937 if ( i+1 >= colors.count() ) break; // format error
5938 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5939 if ( i+2 >= colors.count() ) break; // format error
5940 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5941 if ( i+3 >= colors.count() ) break; // format error
5942 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5943 ballColor.setRgbF( r, g, b );
5946 else if ( type == "outline" ) {
5947 // outline color is set by 3 values r:g:b, where
5948 // - r,g,b - is rgb color components
5949 if ( i+1 >= colors.count() ) break; // format error
5950 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5951 if ( i+2 >= colors.count() ) break; // format error
5952 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5953 if ( i+3 >= colors.count() ) break; // format error
5954 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5955 outlineColor.setRgbF( r, g, b );
5958 else if ( type == "orientation" ) {
5959 // orientation color is set by 3 values r:g:b, where
5960 // - r,g,b - is rgb color components
5961 if ( i+1 >= colors.count() ) break; // format error
5962 r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
5963 if ( i+2 >= colors.count() ) break; // format error
5964 g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
5965 if ( i+3 >= colors.count() ) break; // format error
5966 b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
5967 orientationColor.setRgbF( r, g, b );
5972 if ( nodeColor.isValid() )
5973 aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
5975 if ( edgeColor.isValid() )
5976 aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
5978 if ( faceColor.isValid() )
5979 aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
5981 if ( volumeColor.isValid() )
5982 aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
5983 else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
5984 aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
5986 if ( elem0dColor.isValid() )
5987 aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
5989 if ( ballColor.isValid() )
5990 aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
5992 if ( outlineColor.isValid() )
5993 aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
5994 // orientation color
5995 if ( orientationColor.isValid() )
5996 aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
5999 else if (paramNameStr == "Sizes") {
6000 QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
6003 int outlineWidth = -1;
6004 int elem0dSize = -1;
6006 double shrinkSize = -1;
6007 double orientationSize = -1;
6008 bool orientation3d = false;
6009 for ( int i = 0; i < sizes.count(); i++ ) {
6010 QString type = sizes[i];
6011 if ( type == "line" ) {
6012 // line (wireframe) width is given as single integer value
6013 if ( i+1 >= sizes.count() ) break; // format error
6014 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6018 if ( type == "outline" ) {
6019 // outline width is given as single integer value
6020 if ( i+1 >= sizes.count() ) break; // format error
6021 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6025 else if ( type == "elem0d" ) {
6026 // 0d element size is given as single integer value
6027 if ( i+1 >= sizes.count() ) break; // format error
6028 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6032 else if ( type == "ball" ) {
6033 // ball size is given as single integer value
6034 if ( i+1 >= sizes.count() ) break; // format error
6035 int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
6039 else if ( type == "shrink" ) {
6040 // shrink factor is given as single floating point value
6041 if ( i+1 >= sizes.count() ) break; // format error
6042 double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6046 else if ( type == "orientation" ) {
6047 // orientation vectors are specified by two values size:3d, where
6048 // - size - is a floating point value specifying scale factor
6049 // - 3d - is a boolean
6050 if ( i+1 >= sizes.count() ) break; // format error
6051 double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
6052 if ( i+2 >= sizes.count() ) break; // format error
6053 int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
6054 orientationSize = v1;
6055 orientation3d = (bool)v2;
6059 // line (wireframe) width
6060 if ( lineWidth > 0 )
6061 aSmeshActor->SetLineWidth( lineWidth );
6063 if ( outlineWidth > 0 )
6064 aSmeshActor->SetOutlineWidth( outlineWidth );
6065 else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
6066 aSmeshActor->SetOutlineWidth( lineWidth );
6068 if ( elem0dSize > 0 )
6069 aSmeshActor->Set0DSize( elem0dSize );
6072 aSmeshActor->SetBallSize( ballSize );
6074 if ( shrinkSize > 0 )
6075 aSmeshActor->SetShrinkFactor( shrinkSize );
6076 // orientation vectors
6077 if ( orientationSize > 0 ) {
6078 aSmeshActor->SetFacesOrientationScale( orientationSize );
6079 aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
6083 else if (paramNameStr == "PointMarker") {
6084 QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
6085 if( data.count() >= 2 ) {
6087 int aParam1 = data[1].toInt( &ok );
6089 if( data[0] == "std" && data.count() == 3 ) {
6090 int aParam2 = data[2].toInt( &ok );
6091 aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
6093 else if( data[0] == "custom" ) {
6094 VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
6095 if( markerIt != aMarkerMap.end() ) {
6096 VTK::MarkerData aMarkerData = markerIt->second;
6097 aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
6104 else if (paramNameStr == "Opacity") {
6105 aSmeshActor->SetOpacity(val.toFloat());
6108 else if (paramNameStr.startsWith("ClippingPlane")) {
6109 QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
6110 // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
6111 // new format - val looks like "Off" or "0" (plane id)
6112 // (note: in new format "Off" value is used only for consistency,
6113 // so it is processed together with values in old format)
6114 bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
6115 if( anIsOldFormat ) {
6116 if (paramNameStr == "ClippingPlane1" || val == "Off")
6117 aSmeshActor->RemoveAllClippingPlanes();
6119 SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
6120 double aDistance = vals[1].toFloat();
6121 vtkFloatingPointType anAngle[2];
6122 anAngle[0] = vals[2].toFloat();
6123 anAngle[1] = vals[3].toFloat();
6125 QList<SUIT_ViewManager*> lst;
6126 getApp()->viewManagers(viewerTypStr, lst);
6127 // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
6128 if (viewIndex >= 0 && viewIndex < lst.count()) {
6129 SUIT_ViewManager* vman = lst.at(viewIndex);
6130 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
6132 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
6134 SMESH::TActorList anActorList;
6135 anActorList.push_back( aSmeshActor );
6136 SMESH::OrientedPlane* aPlane =
6137 SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
6139 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6140 aClippingPlaneInfo.Plane = aPlane;
6141 aClippingPlaneInfo.ActorList = anActorList;
6142 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6149 int aPlaneId = val.toInt( &ok );
6150 if( ok && aPlaneId >= 0 ) {
6151 bool anIsDefinedPlane = false;
6152 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
6153 TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
6154 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6155 TPlaneInfo& aPlaneInfo = *anIter;
6156 if( aPlaneInfo.PlaneId == aPlaneId ) {
6157 aPlaneInfo.ActorList.push_back( aSmeshActor );
6158 anIsDefinedPlane = true;
6162 if( !anIsDefinedPlane ) {
6163 TPlaneInfo aPlaneInfo;
6164 aPlaneInfo.PlaneId = aPlaneId;
6165 aPlaneInfo.ActorList.push_back( aSmeshActor );
6166 aPlaneInfo.ViewManager = vman;
6168 // to make the list sorted by plane id
6169 anIter = aPlaneInfoList.begin();
6170 for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
6171 const TPlaneInfo& aPlaneInfoRef = *anIter;
6172 if( aPlaneInfoRef.PlaneId > aPlaneId )
6175 aPlaneInfoList.insert( anIter, aPlaneInfo );
6180 } // if (aSmeshActor)
6181 } // other parameters than Visibility
6183 } // for names/parameters iterator
6184 } // for entries iterator
6186 // take into account planes with empty list of actors referred to them
6187 QList<SUIT_ViewManager*> aVMList;
6188 getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
6190 TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
6191 for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
6192 int aViewId = aPlaneDataIter->first;
6193 if( aViewId >= 0 && aViewId < aVMList.count() ) {
6194 SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
6196 const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
6198 TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
6199 TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
6200 for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
6201 const TPlaneData& aPlaneData = *anIter2;
6202 int aPlaneId = aPlaneData.Id;
6204 bool anIsFound = false;
6205 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6206 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6207 const TPlaneInfo& aPlaneInfo = *anIter3;
6208 if( aPlaneInfo.PlaneId == aPlaneId ) {
6215 TPlaneInfo aPlaneInfo; // ActorList field is empty
6216 aPlaneInfo.PlaneId = aPlaneId;
6217 aPlaneInfo.ViewManager = aViewManager;
6219 // to make the list sorted by plane id
6220 TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
6221 for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
6222 const TPlaneInfo& aPlaneInfoRef = *anIter4;
6223 if( aPlaneInfoRef.PlaneId > aPlaneId )
6226 aPlaneInfoList.insert( anIter4, aPlaneInfo );
6232 // add clipping planes to actors according to the restored parameters
6233 // and update the clipping plane map
6234 TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
6235 for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
6236 int aViewId = anIter1->first;
6237 const TPlaneInfoList& aPlaneInfoList = anIter1->second;
6239 TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
6240 if( anIter2 == aPlaneDataMap.end() )
6242 const TPlaneDataList& aPlaneDataList = anIter2->second;
6244 TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
6245 for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
6246 const TPlaneInfo& aPlaneInfo = *anIter3;
6247 int aPlaneId = aPlaneInfo.PlaneId;
6248 const TActorList& anActorList = aPlaneInfo.ActorList;
6249 SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
6253 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
6257 SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
6259 TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
6260 for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
6261 const TPlaneData& aPlaneData = *anIter4;
6262 if( aPlaneData.Id == aPlaneId ) {
6263 SMESH::OrientedPlane* aPlane =
6264 SMESHGUI_ClippingDlg::AddPlane( anActorList,
6266 (SMESH::Orientation)aPlaneData.Orientation,
6267 aPlaneData.Distance,
6270 SMESH::ClippingPlaneInfo aClippingPlaneInfo;
6271 aClippingPlaneInfo.Plane = aPlane;
6272 aClippingPlaneInfo.ActorList = anActorList;
6273 aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
6281 // update all VTK views
6282 QList<SUIT_ViewManager*> lst;
6283 getApp()->viewManagers(lst);
6284 for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
6285 SUIT_ViewModel* vmodel = (*it)->getViewModel();
6286 if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
6287 SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
6288 vtkView->getRenderer()->ResetCameraClippingRange();
6295 \brief Adds preferences for dfont of VTK viewer
6297 \param pIf group identifier
6298 \param param parameter
6299 \return identifier of preferences
6301 int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
6303 int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
6305 setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
6308 fam.append( tr( "SMESH_FONT_ARIAL" ) );
6309 fam.append( tr( "SMESH_FONT_COURIER" ) );
6310 fam.append( tr( "SMESH_FONT_TIMES" ) );
6312 setPreferenceProperty( tfont, "fonts", fam );
6314 int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
6315 setPreferenceProperty( tfont, "features", f );
6321 \brief Actions after hypothesis edition
6322 Updates object browser after hypothesis edition
6324 void SMESHGUI::onHypothesisEdit( int result )
6327 SMESHGUI::Modified();
6328 updateObjBrowser( true );
6333 \brief Signal handler closing(SUIT_ViewWindow*) of a view
6334 \param pview view being closed
6336 void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
6337 #ifndef DISABLE_PLOT2DVIEWER
6338 //Crear all Plot2d Viewers if need.
6339 SMESH::ClearPlot2Viewers(pview);
6343 void SMESHGUI::message( const QString& msg )
6346 QStringList data = msg.split("/");
6347 if ( data.count() > 0 ) {
6348 if ( data.first() == "mesh_loading" ) {
6350 QString entry = data.count() > 1 ? data[1] : QString();
6351 if ( entry.isEmpty() )
6354 _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
6356 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
6359 name = obj->GetName().c_str();
6360 if ( name.isEmpty() )
6363 if ( data.last() == "stop" )
6364 application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
6366 application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
6367 QApplication::processEvents();
6373 \brief Connects or disconnects signals about activating and cloning view on the module slots
6374 \param pview view which is connected/disconnected
6376 void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
6380 SUIT_ViewManager* viewMgr = pview->getViewManager();
6382 disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6383 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6385 connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
6386 this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
6391 \brief Return \c true if object can be renamed
6393 bool SMESHGUI::renameAllowed( const QString& entry) const {
6394 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6398 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6402 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
6407 if(appStudy->isComponent(entry) || obj->isReference())
6410 // check type to prevent renaming of inappropriate objects
6411 int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
6412 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6413 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6414 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6415 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6416 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
6423 Rename object by entry.
6424 \param entry entry of the object
6425 \param name new name of the object
6426 \brief Return \c true if rename operation finished successfully, \c false otherwise.
6428 bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
6430 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
6434 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
6439 _PTR(Study) aStudy = appStudy->studyDS();
6444 bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
6446 SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
6451 _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
6452 _PTR(GenericAttribute) anAttr;
6453 _PTR(AttributeName) aName;
6455 if ( obj->FindAttribute(anAttr, "AttributeName") ) {
6457 // check type to prevent renaming of inappropriate objects
6458 int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
6459 if (aType == SMESH::MESH || aType == SMESH::GROUP ||
6460 aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
6461 aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
6462 aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
6463 aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
6464 if ( !name.isEmpty() ) {
6465 SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
6467 // update name of group object and its actor
6468 Handle(SALOME_InteractiveObject) IObject =
6469 new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
6471 SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
6472 if( !aGroupObject->_is_nil() ) {
6473 aGroupObject->SetName( qPrintable(name) );
6474 if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
6475 anActor->setName( qPrintable(name) );